예제 #1
0
        private static void SetCFBundleURLSchemes(
            PListDict plistDict,
            string appID,
            string urlSuffix,
            ICollection <string> appLinkSchemes)
        {
            IList <object> currentSchemas;

            if (ContainsKeyWithValueType(plistDict, PListParser.CFBundleURLTypesKey, typeof(IList <object>)))
            {
                currentSchemas = (IList <object>)plistDict[PListParser.CFBundleURLTypesKey];
            }
            else
            {
                // Didn't find any CFBundleURLTypes, let's create one
                currentSchemas = new List <object>();
                plistDict[PListParser.CFBundleURLTypesKey] = currentSchemas;
            }

            PListDict facebookBundleUrlSchemes = PListParser.GetFacebookUrlSchemes(currentSchemas);

            // Clear and set the CFBundleURLSchemes for the facebook schemes
            var facebookUrlSchemes = new List <object>();

            facebookBundleUrlSchemes[PListParser.CFBundleURLSchemesKey] = facebookUrlSchemes;
            AddAppID(facebookUrlSchemes, appID, urlSuffix);
            AddAppLinkSchemes(facebookUrlSchemes, appLinkSchemes);
        }
예제 #2
0
        private object ParseValueForLoad(XElement val)
        {
            switch (val.Name.ToString())
            {
            case "string":
                return(val.Value);

            case "integer":
                return(int.Parse(val.Value));

            case "real":
                return(float.Parse(val.Value));

            case "true":
                return(true);

            case "false":
                return(false);

            case "dict":
                PListDict plist = new PListDict();
                this.ParseDictForLoad(plist, val.Elements());
                return(plist);

            case "array":
                return(this.ParseArrayForLoad(val.Elements()));

            default:
                throw new ArgumentException("Format unsupported, Parser update needed");
            }
        }
예제 #3
0
        private static void SetCFBundleURLSchemes(PListDict plistDict, string appID, string urlSuffix, ICollection <string> appLinkSchemes)
        {
            IList <object> plistSchemes      = (IList <object>)(ContainsKeyWithValueType(plistDict, "CFBundleURLTypes", typeof(IList <object>)) ? ((IList <object>)plistDict["CFBundleURLTypes"]) : (plistDict["CFBundleURLTypes"] = new List <object>()));
            List <object>  schemesCollection = (List <object>)(GetFacebookUrlSchemes(plistSchemes)["CFBundleURLSchemes"] = new List <object>());

            AddAppID(schemesCollection, appID, urlSuffix);
            AddAppLinkSchemes(schemesCollection, appLinkSchemes);
        }
예제 #4
0
 private void ParseDictForLoad(PListDict dict, IEnumerable <XElement> elements)
 {
     for (int i = 0; i < elements.Count(); i += 2)
     {
         XElement key = elements.ElementAt(i);
         XElement val = elements.ElementAt(i + 1);
         dict[key.Value] = this.ParseValueForLoad(val);
     }
 }
예제 #5
0
        private XElement ParseDictForSave(PListDict dict)
        {
            XElement xElement = new XElement("dict");

            foreach (string key in dict.Keys)
            {
                xElement.Add(new XElement("key", key));
                xElement.Add(ParseValueForSave(dict[key]));
            }
            return(xElement);
        }
예제 #6
0
        private XElement ParseDictForSave(PListDict dict)
        {
            XElement dictNode = new XElement("dict");

            foreach (string key in dict.Keys)
            {
                dictNode.Add(new XElement("key", key));
                dictNode.Add(this.ParseValueForSave(dict[key]));
            }

            return(dictNode);
        }
예제 #7
0
        public PListParser(string fullPath)
        {
            filePath = fullPath;
            XmlReaderSettings settings = new XmlReaderSettings
            {
                ProhibitDtd = false
            };
            XmlReader xmlReader = XmlReader.Create(filePath, settings);
            XElement  dict      = XDocument.Load(xmlReader).Element("plist").Element("dict");

            XMLDict = new PListDict(dict);
            xmlReader.Close();
        }
예제 #8
0
        private static PListDict GetFacebookUrlSchemes(ICollection <object> plistSchemes)
        {
            foreach (object plistScheme in plistSchemes)
            {
                PListDict pListDict = plistScheme as PListDict;
                if (pListDict != null && pListDict.TryGetValue("CFBundleURLName", out string value) && value == "facebook-unity-sdk")
                {
                    return(pListDict);
                }
            }
            PListDict pListDict2 = new PListDict(FacebookUrlSchemes);

            plistSchemes.Add(pListDict2);
            return(pListDict2);
        }
예제 #9
0
        public void UpdateInfolist()
        {
            if (PListParser.ContainsKeyWithValueType(this.XMLDict, "UIApplicationExitsOnSuspend", typeof(bool)))
            {
                this.XMLDict.Remove("UIApplicationExitsOnSuspend");
            }
            PListDict desPlist = new PListDict(DescriptionSchemes);

            foreach (var item in desPlist)
            {
                if (!this.XMLDict.ContainsKey(item.Key))
                {
                    this.XMLDict.Add(item.Key, item.Value);
                }
            }
        }
예제 #10
0
        private static void WhitelistFacebookApps(PListDict plistDict)
        {
            if (!ContainsKeyWithValueType(plistDict, "LSApplicationQueriesSchemes", typeof(IList <object>)))
            {
                plistDict["LSApplicationQueriesSchemes"] = FacebookLSApplicationQueriesSchemes;
                return;
            }
            IList <object> list = (IList <object>)plistDict["LSApplicationQueriesSchemes"];

            foreach (object facebookLSApplicationQueriesScheme in FacebookLSApplicationQueriesSchemes)
            {
                if (!list.Contains(facebookLSApplicationQueriesScheme))
                {
                    list.Add(facebookLSApplicationQueriesScheme);
                }
            }
        }
예제 #11
0
        private static void WhitelistFacebookApps(PListDict plistDict)
        {
            if (!ContainsKeyWithValueType(plistDict, PListParser.LSApplicationQueriesSchemesKey, typeof(IList <object>)))
            {
                // We don't have a LSApplicationQueriesSchemes entry. We can easily add one
                plistDict[PListParser.LSApplicationQueriesSchemesKey] = PListParser.FacebookLSApplicationQueriesSchemes;
                return;
            }

            var applicationQueriesSchemes = (IList <object>)plistDict[PListParser.LSApplicationQueriesSchemesKey];

            foreach (var scheme in PListParser.FacebookLSApplicationQueriesSchemes)
            {
                if (!applicationQueriesSchemes.Contains(scheme))
                {
                    applicationQueriesSchemes.Add(scheme);
                }
            }
        }
예제 #12
0
        private static PListDict GetFacebookUrlSchemes(ICollection <object> plistSchemes)
        {
            foreach (var plistScheme in plistSchemes)
            {
                var bundleTypeNode = plistScheme as PListDict;
                if (bundleTypeNode != null)
                {
                    // Check to see if the url scheme name is facebook
                    string bundleURLName;
                    if (bundleTypeNode.TryGetValue <string>(PListParser.CFBundleURLName, out bundleURLName) &&
                        bundleURLName == PListParser.FacebookCFBundleURLName)
                    {
                        return(bundleTypeNode);
                    }
                }
            }

            // We didn't find a facebook scheme so lets create one
            PListDict facebookUrlSchemes = new PListDict(PListParser.FacebookUrlSchemes);

            plistSchemes.Add(facebookUrlSchemes);
            return(facebookUrlSchemes);
        }
예제 #13
0
 public PListDict(PListDict dict) : base(dict)
 {
 }
예제 #14
0
 public PListDict(PListDict dict)
     : base((IDictionary <string, object>)dict)
 {
 }