private PlistElementDict GetOrCreateUniqueDictElementInArray(PlistElementArray root) { PlistElementDict plistElementDict; if (root.values.Count == 0) { plistElementDict = root.values[0] as PlistElementDict; } else { plistElementDict = new PlistElementDict(); root.values.Add((PlistElement)plistElementDict); } return(plistElementDict); }
private PlistElementDict GetOrCreateUniqueDictElementInArray(PlistElementArray root) { PlistElementDict r; if (root.values.Count == 0) { r = root.values[0] as PlistElementDict; } else { r = new PlistElementDict(); root.values.Add(r); } return(r); }
public void AddiCloud(bool enableKeyValueStorage, bool enableiCloudDocument, bool enablecloudKit, bool addDefaultContainers, string[] customContainers) { PlistDocument createEntitlementDoc = this.GetOrCreateEntitlementDoc(); PlistElementArray plistElementArray1 = (createEntitlementDoc.root[ICloudEntitlements.ContainerIdKey] = (PlistElement) new PlistElementArray()) as PlistElementArray; PlistElementArray plistElementArray2 = (PlistElementArray)null; if (enableiCloudDocument | enablecloudKit) { plistElementArray2 = (createEntitlementDoc.root[ICloudEntitlements.ServicesKey] = (PlistElement) new PlistElementArray()) as PlistElementArray; } if (enableiCloudDocument) { plistElementArray1.values.Add((PlistElement) new PlistElementString(ICloudEntitlements.ContainerIdValue)); plistElementArray2.values.Add((PlistElement) new PlistElementString(ICloudEntitlements.ServicesDocValue)); PlistElementArray plistElementArray3 = (createEntitlementDoc.root[ICloudEntitlements.UbiquityContainerIdKey] = (PlistElement) new PlistElementArray()) as PlistElementArray; if (addDefaultContainers) { plistElementArray3.values.Add((PlistElement) new PlistElementString(ICloudEntitlements.UbiquityContainerIdValue)); } if (customContainers != null && (uint)customContainers.Length > 0U) { for (int index = 0; index < customContainers.Length; ++index) { plistElementArray3.values.Add((PlistElement) new PlistElementString(customContainers[index])); } } } if (enablecloudKit) { if (addDefaultContainers && !enableiCloudDocument) { plistElementArray1.values.Add((PlistElement) new PlistElementString(ICloudEntitlements.ContainerIdValue)); } if (customContainers != null && (uint)customContainers.Length > 0U) { for (int index = 0; index < customContainers.Length; ++index) { plistElementArray1.values.Add((PlistElement) new PlistElementString(customContainers[index])); } } plistElementArray2.values.Add((PlistElement) new PlistElementString(ICloudEntitlements.ServicesKitValue)); } if (enableKeyValueStorage) { createEntitlementDoc.root[ICloudEntitlements.KeyValueStoreKey] = (PlistElement) new PlistElementString(ICloudEntitlements.KeyValueStoreValue); } this.project.AddCapability(this.m_TargetGuid, PBXCapabilityType.iCloud, this.m_EntitlementFilePath, enablecloudKit); }
public void AddBackgroundModes(BackgroundModesOptions options) { PlistElement plistElement1 = this.GetOrCreateInfoDoc().root[BackgroundInfo.Key]; if (plistElement1 == null) { PlistElement plistElement2 = (PlistElement) new PlistElementArray(); this.GetOrCreateInfoDoc().root[BackgroundInfo.Key] = plistElement2; plistElement1 = plistElement2; } PlistElementArray root = plistElement1 as PlistElementArray; if ((options & BackgroundModesOptions.ActsAsABluetoothLEAccessory) == BackgroundModesOptions.ActsAsABluetoothLEAccessory) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeActsBluetoothValue); } if ((options & BackgroundModesOptions.AudioAirplayPiP) == BackgroundModesOptions.AudioAirplayPiP) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeAudioValue); } if ((options & BackgroundModesOptions.BackgroundFetch) == BackgroundModesOptions.BackgroundFetch) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeFetchValue); } if ((options & BackgroundModesOptions.ExternalAccessoryCommunication) == BackgroundModesOptions.ExternalAccessoryCommunication) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeExtAccessoryValue); } if ((options & BackgroundModesOptions.LocationUpdates) == BackgroundModesOptions.LocationUpdates) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeLocationValue); } if ((options & BackgroundModesOptions.NewsstandDownloads) == BackgroundModesOptions.NewsstandDownloads) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeNewsstandValue); } if ((options & BackgroundModesOptions.RemoteNotifications) == BackgroundModesOptions.RemoteNotifications) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModePushValue); } if ((options & BackgroundModesOptions.VoiceOverIP) == BackgroundModesOptions.VoiceOverIP) { this.GetOrCreateStringElementInArray(root, BackgroundInfo.ModeVOIPValue); } this.project.AddCapability(this.m_TargetGuid, PBXCapabilityType.BackgroundModes, (string)null, false); }
public void AddKeychainSharing(string[] accessGroups) { PlistElementArray plistElementArray = (this.GetOrCreateEntitlementDoc().root[KeyChainEntitlements.Key] = (PlistElement) new PlistElementArray()) as PlistElementArray; if (accessGroups != null) { for (int index = 0; index < accessGroups.Length; ++index) { plistElementArray.values.Add((PlistElement) new PlistElementString(accessGroups[index])); } } else { plistElementArray.values.Add((PlistElement) new PlistElementString(KeyChainEntitlements.DefaultValue)); } this.project.AddCapability(this.m_TargetGuid, PBXCapabilityType.KeychainSharing, this.m_EntitlementFilePath, false); }
public void AddWallet(string[] passSubset) { PlistElementArray plistElementArray = (this.GetOrCreateEntitlementDoc().root[WalletEntitlements.Key] = (PlistElement) new PlistElementArray()) as PlistElementArray; if ((passSubset == null || passSubset.Length == 0) && plistElementArray != null) { plistElementArray.values.Add((PlistElement) new PlistElementString(WalletEntitlements.BaseValue + WalletEntitlements.BaseValue)); } else { for (int index = 0; index < passSubset.Length; ++index) { if (plistElementArray != null) { plistElementArray.values.Add((PlistElement) new PlistElementString(WalletEntitlements.BaseValue + passSubset[index])); } } } this.project.AddCapability(this.m_TargetGuid, PBXCapabilityType.Wallet, this.m_EntitlementFilePath, false); }
private PlistElementString GetOrCreateStringElementInArray(PlistElementArray root, string value) { PlistElementString r = null; var c = root.values.Count; var exist = false; for (var i = 0; i < c; i++) { if (root.values[i] is PlistElementString && (root.values[i] as PlistElementString).value == value) { r = root.values[i] as PlistElementString; exist = true; } } if (!exist) { r = new PlistElementString(value); root.values.Add(r); } return(r); }
private PlistElementString GetOrCreateStringElementInArray(PlistElementArray root, string value) { PlistElementString plistElementString = (PlistElementString)null; int count = root.values.Count; bool flag = false; for (int index = 0; index < count; ++index) { if (root.values[index] is PlistElementString && (root.values[index] as PlistElementString).value == value) { plistElementString = root.values[index] as PlistElementString; flag = true; } } if (!flag) { plistElementString = new PlistElementString(value); root.values.Add((PlistElement)plistElementString); } return(plistElementString); }
private static void SetPlist(PBXProject proj, PlistElementArray node, ArrayList arg) { if (arg != null) { foreach (object i in arg) { object val = i; var vType = i.GetType(); if (vType == typeof(string)) { node.AddString((string)val); } else if (vType == typeof(bool)) { node.AddBoolean((bool)val); } else if (vType == typeof(double)) { int v = int.Parse(val.ToString()); node.AddInteger(v); } else if (vType == typeof(ArrayList)) { var t = node.AddArray(); var array = val as ArrayList; SetPlist(proj, t, array); } else if (vType == typeof(Hashtable)) { var t = node.AddDict(); var table = val as Hashtable; SetPlist(proj, t, table); } } } }
private static PlistElement ReadElement(XElement xml) { switch (xml.Name.LocalName) { case "dict": { List <XElement> children = xml.Elements().ToList(); var el = new PlistElementDict(); if (children.Count % 2 == 1) { throw new Exception("Malformed plist file"); } for (int i = 0; i < children.Count - 1; i++) { if (children[i].Name != "key") { throw new Exception("Malformed plist file"); } string key = GetText(children[i]).Trim(); var newChild = ReadElement(children[i + 1]); if (newChild != null) { i++; el[key] = newChild; } } return(el); } case "array": { List <XElement> children = xml.Elements().ToList(); var el = new PlistElementArray(); foreach (var childXml in children) { var newChild = ReadElement(childXml); if (newChild != null) { el.values.Add(newChild); } } return(el); } case "string": return(new PlistElementString(GetText(xml))); case "integer": { int r; if (int.TryParse(GetText(xml), out r)) { return(new PlistElementInteger(r)); } return(null); } case "true": return(new PlistElementBoolean(true)); case "false": return(new PlistElementBoolean(false)); default: return(null); } }
private static PlistElement ReadElement(XElement xml) { string localName = xml.Name.LocalName; // ISSUE: reference to a compiler-generated method uint stringHash = PrivateImplementationDetails.ComputeStringHash(localName); if (stringHash <= 1303515621U) { if (stringHash <= 398550328U) { if ((int)stringHash != 184981848) { if ((int)stringHash == 398550328 && localName == "string") { return((PlistElement) new PlistElementString(PlistDocument.GetText(xml))); } } else if (localName == "false") { return((PlistElement) new PlistElementBoolean(false)); } } else if ((int)stringHash != 1278716217) { if ((int)stringHash == 1303515621 && localName == "true") { return((PlistElement) new PlistElementBoolean(true)); } } else if (localName == "dict") { List <XElement> list = Enumerable.ToList <XElement>(xml.Elements()); PlistElementDict plistElementDict = new PlistElementDict(); if (list.Count % 2 == 1) { throw new Exception("Malformed plist file"); } for (int index1 = 0; index1 < list.Count - 1; ++index1) { if (list[index1].Name != (XName)"key") { throw new Exception("Malformed plist file. Found '" + (object)list[index1].Name + "' where 'key' was expected."); } string index2 = PlistDocument.GetText(list[index1]).Trim(); PlistElement plistElement = PlistDocument.ReadElement(list[index1 + 1]); if (plistElement != null) { ++index1; plistElementDict[index2] = plistElement; } } return((PlistElement)plistElementDict); } } else if (stringHash <= 3218261061U) { if ((int)stringHash != -1973899994) { int result; if ((int)stringHash == -1076706235 && localName == "integer" && int.TryParse(PlistDocument.GetText(xml), out result)) { return((PlistElement) new PlistElementInteger(result)); } } else if (localName == "array") { List <XElement> list = Enumerable.ToList <XElement>(xml.Elements()); PlistElementArray plistElementArray = new PlistElementArray(); foreach (XElement xml1 in list) { PlistElement plistElement = PlistDocument.ReadElement(xml1); if (plistElement != null) { plistElementArray.values.Add(plistElement); } } return((PlistElement)plistElementArray); } } else if ((int)stringHash != -730669991) { float result; if ((int)stringHash == -689983395 && localName == "real" && float.TryParse(PlistDocument.GetText(xml), out result)) { return((PlistElement) new PlistElementReal(result)); } } else { DateTime result; if (localName == "date" && DateTime.TryParse(PlistDocument.GetText(xml), out result)) { return((PlistElement) new PlistElementDate(result.ToUniversalTime())); } } return((PlistElement)null); }
public static void PatchInfoPlist(string pathToBuiltProject) { string plistPath = Path.Combine(pathToBuiltProject, "Info.plist"); PlistDocument plist = new PlistDocument(); plist.ReadFromFile(plistPath); // ================================= // We must do this here instead of passing the plist to // a useful helper function because Unity refuses to build functions // where a variable of type PlistDocument is passed. string key = "UISupportedExternalAccessoryProtocols"; string[] values = new string[3] { "io.structure.control", "io.structure.depth", "io.structure.infrared" }; if (plist.root.values.ContainsKey(key)) return; PlistElementArray array = new PlistElementArray(); foreach (string value in values) array.AddString(value); plist.root.values.Add (new PlistEntry(key, array)); // ================================= plist.root.values.Add( new PlistEntry("UIFileSharingEnabled", new PlistElementBoolean(true) ) ); plist.WriteToFile(plistPath); }
public void AddMaps(MapsOptions options) { PlistElementArray root1 = (this.GetOrCreateInfoDoc().root[MapsInfo.BundleKey] ?? (this.GetOrCreateInfoDoc().root[MapsInfo.BundleKey] = (PlistElement) new PlistElementArray())) as PlistElementArray; root1.values.Add((PlistElement) new PlistElementDict()); PlistElementDict dictElementInArray = this.GetOrCreateUniqueDictElementInArray(root1); dictElementInArray[MapsInfo.BundleNameKey] = (PlistElement) new PlistElementString(MapsInfo.BundleNameValue); this.GetOrCreateStringElementInArray((dictElementInArray[MapsInfo.BundleTypeKey] ?? (dictElementInArray[MapsInfo.BundleTypeKey] = (PlistElement) new PlistElementArray())) as PlistElementArray, MapsInfo.BundleTypeValue); PlistElementArray root2 = (this.GetOrCreateInfoDoc().root[MapsInfo.ModeKey] ?? (this.GetOrCreateInfoDoc().root[MapsInfo.ModeKey] = (PlistElement) new PlistElementArray())) as PlistElementArray; if ((options & MapsOptions.Airplane) == MapsOptions.Airplane) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModePlaneValue); } if ((options & MapsOptions.Bike) == MapsOptions.Bike) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeBikeValue); } if ((options & MapsOptions.Bus) == MapsOptions.Bus) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeBusValue); } if ((options & MapsOptions.Car) == MapsOptions.Car) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeCarValue); } if ((options & MapsOptions.Ferry) == MapsOptions.Ferry) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeFerryValue); } if ((options & MapsOptions.Other) == MapsOptions.Other) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeOtherValue); } if ((options & MapsOptions.Pedestrian) == MapsOptions.Pedestrian) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModePedestrianValue); } if ((options & MapsOptions.RideSharing) == MapsOptions.RideSharing) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeRideShareValue); } if ((options & MapsOptions.StreetCar) == MapsOptions.StreetCar) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeStreetCarValue); } if ((options & MapsOptions.Subway) == MapsOptions.Subway) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeSubwayValue); } if ((options & MapsOptions.Taxi) == MapsOptions.Taxi) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeTaxiValue); } if ((options & MapsOptions.Train) == MapsOptions.Train) { this.GetOrCreateStringElementInArray(root2, MapsInfo.ModeTrainValue); } this.project.AddCapability(this.m_TargetGuid, PBXCapabilityType.Maps, (string)null, false); }
public PlistElementArray CreateArray(string key) { PlistElementArray array = new PlistElementArray(); this.values[key] = array; return array; }
public PlistElementArray AddArray() { PlistElementArray item = new PlistElementArray(); this.values.Add(item); return item; }
public PlistElementArray CreateArray(string key) { var v = new PlistElementArray(); values[key] = v; return v; }
public PlistElementArray AddArray() { var v = new PlistElementArray(); values.Add(v); return v; }
private static PlistElement ReadElement(XElement xml) { switch (xml.Name.LocalName) { case "dict": { List<XElement> children = xml.Elements().ToList(); var el = new PlistElementDict(); if (children.Count % 2 == 1) throw new Exception("Malformed plist file"); for (int i = 0; i < children.Count - 1; i++) { if (children[i].Name != "key") throw new Exception("Malformed plist file"); string key = GetText(children[i]).Trim(); var newChild = ReadElement(children[i+1]); if (newChild != null) { i++; el[key] = newChild; } } return el; } case "array": { List<XElement> children = xml.Elements().ToList(); var el = new PlistElementArray(); foreach (var childXml in children) { var newChild = ReadElement(childXml); if (newChild != null) el.values.Add(newChild); } return el; } case "string": return new PlistElementString(GetText(xml)); case "integer": { int r; if (int.TryParse(GetText(xml), out r)) return new PlistElementInteger(r); return null; } case "true": return new PlistElementBoolean(true); case "false": return new PlistElementBoolean(false); default: return null; } }
private static PlistElement ReadElement(XElement xml) { string localName = xml.Name.LocalName; if (localName != null) { Dictionary <string, int> types = new Dictionary <string, int>(8) { { "dict", 0 }, { "array", 1 }, { "string", 2 }, { "integer", 3 }, { "real", 4 }, { "date", 5 }, { "true", 6 }, { "false", 7 } }; int num = 0; if (types.TryGetValue(localName, out num)) { switch (num) { case 0: List <XElement> list1 = Enumerable.ToList <XElement>(xml.Elements()); PlistElementDict plistElementDict = new PlistElementDict(); if (list1.Count % 2 == 1) { throw new Exception("Malformed plist file"); } for (int index1 = 0; index1 < list1.Count - 1; ++index1) { if (list1[index1].Name != (XName)"key") { throw new Exception("Malformed plist file. Found '" + (object)list1[index1].Name + "' where 'key' was expected."); } string index2 = PlistDocument.GetText(list1[index1]).Trim(); PlistElement plistElement = PlistDocument.ReadElement(list1[index1 + 1]); if (plistElement != null) { ++index1; plistElementDict[index2] = plistElement; } } return((PlistElement)plistElementDict); case 1: List <XElement> list2 = Enumerable.ToList <XElement>(xml.Elements()); PlistElementArray plistElementArray = new PlistElementArray(); foreach (XElement xml1 in list2) { PlistElement plistElement = PlistDocument.ReadElement(xml1); if (plistElement != null) { plistElementArray.values.Add(plistElement); } } return((PlistElement)plistElementArray); case 2: return((PlistElement) new PlistElementString(PlistDocument.GetText(xml))); case 3: int result1; if (int.TryParse(PlistDocument.GetText(xml), out result1)) { return((PlistElement) new PlistElementInteger(result1)); } return((PlistElement)null); case 4: float result2; if (float.TryParse(PlistDocument.GetText(xml), out result2)) { return((PlistElement) new PlistElementReal(result2)); } return((PlistElement)null); case 5: DateTime result3; if (DateTime.TryParse(PlistDocument.GetText(xml), out result3)) { return((PlistElement) new PlistElementDate(result3.ToUniversalTime())); } return((PlistElement)null); case 6: return((PlistElement) new PlistElementBoolean(true)); case 7: return((PlistElement) new PlistElementBoolean(false)); } } } return(null); }