66// Copyright (c) 2016 Xamarin Inc. (www.xamarin.com)
77//
88
9+ using System . Collections . Generic ;
10+ using System . Linq ;
11+ using System . Reflection ;
12+
913namespace Xamarin . MacDev
1014{
1115 public static class EntitlementKeys
1216 {
17+ public const string DataProtection = "com.apple.developer.default-data-protection" ;
1318 public const string WirelessAccessoryConfiguration = "com.apple.external-accessory.wireless-configuration" ;
1419 public const string UbiquityKeyValueStore = "com.apple.developer.ubiquity-kvstore-identifier" ;
1520 public const string UbiquityContainers = "com.apple.developer.ubiquity-container-identifiers" ;
@@ -30,6 +35,17 @@ public static class EntitlementKeys
3035 public const string GetTaskAllow = "get-task-allow" ;
3136 public const string Siri = "com.apple.developer.siri" ;
3237 public const string APS = "aps-environment" ;
38+
39+ public static IEnumerable < string > AllKeys {
40+ get {
41+ var entitlementKeys = typeof ( EntitlementKeys ) . GetFields ( BindingFlags . Public | BindingFlags . Static ) .
42+ Where ( f => f . FieldType == typeof ( string ) ) .
43+ Select ( field => ( string ) field . GetValue ( null ) ) .
44+ ToList ( ) ;
45+
46+ return entitlementKeys ;
47+ }
48+ }
3349 }
3450
3551 public static class EntitlementExtensions
@@ -138,5 +154,17 @@ public static void SetPassBookIdentifiers (this PDictionary dict, PArray value)
138154 else
139155 dict [ EntitlementKeys . PassBookIdentifiers ] = value ;
140156 }
157+
158+ public static IEnumerable < string > GetEntitlementKeys ( this PDictionary dict )
159+ {
160+ var enabledEntitlements = new List < string > ( ) ;
161+
162+ foreach ( var key in EntitlementKeys . AllKeys ) {
163+ if ( dict . ContainsKey ( key ) )
164+ enabledEntitlements . Add ( key ) ;
165+ }
166+
167+ return enabledEntitlements ;
168+ }
141169 }
142170}
0 commit comments