private static void AddPlistVariables(string projectPath) { var infoPlist = new PlistDocument(); var infoPlistPath = projectPath + "/Info.plist"; infoPlist.ReadFromFile(infoPlistPath); foreach (var variable in ISD_Settings.Instance.PlistVariables) { PlistElement plistVariable = null; switch (variable.Type) { case ISD_PlistKeyType.String: plistVariable = new PlistElementString(variable.StringValue); break; case ISD_PlistKeyType.Integer: plistVariable = new PlistElementInteger(variable.IntegerValue); break; case ISD_PlistKeyType.Boolean: plistVariable = new PlistElementBoolean(variable.BooleanValue); break; case ISD_PlistKeyType.Array: plistVariable = CreatePlistArray(variable); break; case ISD_PlistKeyType.Dictionary: plistVariable = CreatePlistDict(variable); break; } infoPlist.root[variable.Name] = plistVariable; } // Get root PlistElementDict rootDict = infoPlist.root; /* * // Set encryption usage boolean * string encryptKey = "ITSAppUsesNonExemptEncryption"; * rootDict.SetBoolean(encryptKey, false);*/ // remove exit on suspend if it exists. string exitsOnSuspendKey = "UIApplicationExitsOnSuspend"; if (rootDict.values.ContainsKey(exitsOnSuspendKey)) { rootDict.values.Remove(exitsOnSuspendKey); } infoPlist.WriteToFile(infoPlistPath); }
/// <summary> /// 更新内容到PList /// </summary> /// <param name="key"></param> /// <param name="value"></param> public void Update(string key, string value, XcodeInfoPListType infoType = XcodeInfoPListType.StringInfo, bool isAdd = true) { PlistElementDict root = _plist.root; if (isAdd) { switch (infoType) { case XcodeInfoPListType.BoolInfo: bool vb = bool.Parse(value); if (root[key] != null) { root[key] = new PlistElementBoolean(vb); } else if (isAdd) { root.SetBoolean(key, vb); } break; case XcodeInfoPListType.IntInfo: int vi = int.Parse(value); if (root[key] != null) { root[key] = new PlistElementInteger(vi); } else if (isAdd) { root.SetInteger(key, vi); } break; case XcodeInfoPListType.StringInfo: if (root[key] != null) { root[key] = new PlistElementString(value); } else { root.SetString(key, value); } break; } } else { root.values.Remove(key); } }
static void AddPlistVariables(string projectPath) { var infoPlist = new PlistDocument(); var infoPlistPath = projectPath + "/Info.plist"; infoPlist.ReadFromFile(infoPlistPath); foreach (var variable in XCodeProjectSettings.Instance.PlistVariables) { PlistElement plistVariable = null; switch (variable.Type) { case InfoPlistKeyType.String: plistVariable = new PlistElementString(variable.StringValue); break; case InfoPlistKeyType.Integer: plistVariable = new PlistElementInteger(variable.IntegerValue); break; case InfoPlistKeyType.Boolean: plistVariable = new PlistElementBoolean(variable.BooleanValue); break; case InfoPlistKeyType.Array: plistVariable = CreatePlistArray(variable); break; case InfoPlistKeyType.Dictionary: plistVariable = CreatePlistDict(variable); break; } infoPlist.root[variable.Name] = plistVariable; } // Get root var rootDict = infoPlist.root; // remove exit on suspend if it exists. var exitsOnSuspendKey = "UIApplicationExitsOnSuspend"; if (rootDict.values.ContainsKey(exitsOnSuspendKey)) { rootDict.values.Remove(exitsOnSuspendKey); } infoPlist.WriteToFile(infoPlistPath); }
private static void AddPlistVariables(string projectPath) { var infoPlist = new PlistDocument(); var infoPlistPath = projectPath + "/Info.plist"; infoPlist.ReadFromFile(infoPlistPath); foreach (var variable in ISD_Settings.Instance.PlistVariables) { PlistElement plistVariable = null; switch (variable.Type) { case ISD_PlistKeyType.String: plistVariable = new PlistElementString(variable.StringValue); break; case ISD_PlistKeyType.Integer: plistVariable = new PlistElementInteger(variable.IntegerValue); break; case ISD_PlistKeyType.Boolean: plistVariable = new PlistElementBoolean(variable.BooleanValue); break; case ISD_PlistKeyType.Array: plistVariable = CreatePlistArray(variable); break; case ISD_PlistKeyType.Dictionary: plistVariable = CreatePlistDict(variable); break; } infoPlist.root[variable.Name] = plistVariable; } infoPlist.WriteToFile(infoPlistPath); }
// convenience methods public void SetInteger(string key, int val) { values[key] = new PlistElementInteger(val); }