示例#1
0
        /// <summary>
        /// Adds the URL scheme to the plist.
        /// If the key already exists, the value is updated to the given value.
        /// If the key cannot be found, it is added.
        /// </summary>
        /// <param name="buddy">buddy - the plist helper to use.</param>
        /// <param name="key">Key - the url scheme key to look for</param>
        /// <param name="value">Value - the value of the scheme.</param>
        private static void AddURLScheme(PlistBuddyHelper buddy, string key, string value)
        {
            int index = 0;

            while (buddy.EntryValue(UrlTypes, index) != null)
            {
                string urlName = buddy.EntryValue(UrlTypes, index, UrlBundleName);

                if (key.Equals(urlName))
                {
                    // remove the existing value
                    buddy.RemoveEntry(UrlTypes, index, UrlScheme);
                    //add the array back
                    buddy.AddArray(UrlTypes, index, UrlScheme);
                    //add the value
                    buddy.AddString(PlistBuddyHelper.ToEntryName(UrlTypes, index, UrlScheme, 0),
                                    value);
                    return;
                }

                index++;
            }

            // not found, add new entry
            buddy.AddDictionary(UrlTypes, index);
            buddy.AddString(PlistBuddyHelper.ToEntryName(UrlTypes, index, UrlBundleName),
                            key);
            //add the array
            buddy.AddArray(UrlTypes, index, UrlScheme);
            //add the value
            buddy.AddString(PlistBuddyHelper.ToEntryName(UrlTypes, index, UrlScheme, 0),
                            value);
        }
示例#2
0
    /// <summary>
    /// Finds the index of the CFBundleURLTypes array where the entry for Play Games is stored. If
    /// this is not present, a new entry will be appended to the end of this array.
    /// </summary>
    /// <returns>The index in the CFBundleURLTypes array corresponding to Play Games.</returns>
    /// <param name="buddy">The helper corresponding to the plist file.</param>
    private static int GamesUrlSchemeIndex(PlistBuddyHelper buddy) {
        int index = 0;

        while(buddy.EntryValue(UrlTypes, index) != null) {
            var urlName = buddy.EntryValue(UrlTypes, index, UrlBundleName);

            if (GetBundleId().Equals(urlName)) {
                return index;
            }

            index++;
        }

        // The current array does not contain the Games url scheme - add a value to the end.
        buddy.AddDictionary(UrlTypes, index);
        buddy.AddString(PlistBuddyHelper.ToEntryName(UrlTypes, index, UrlBundleName),
            GetBundleId());

        return index;
    }
        /// <summary>
        /// Adds the URL scheme to the plist.
        /// If the key already exists, the value is updated to the given value.
        /// If the key cannot be found, it is added.
        /// </summary>
        /// <param name="buddy">buddy - the plist helper to use.</param>
        /// <param name="key">Key - the url scheme key to look for</param>
        /// <param name="value">Value - the value of the scheme.</param>
        private static void AddURLScheme(PlistBuddyHelper buddy, string key, string value)
        {
            int index = 0;

            while (buddy.EntryValue(UrlTypes, index) != null)
            {
               string urlName = buddy.EntryValue(UrlTypes, index, UrlBundleName);

                if (key.Equals(urlName))
                {
                    // remove the existing value
                    buddy.RemoveEntry (UrlTypes, index, UrlScheme);
                    //add the array back
                    buddy.AddArray(UrlTypes, index, UrlScheme);
                    //add the value
                    buddy.AddString (PlistBuddyHelper.ToEntryName (UrlTypes, index, UrlScheme, 0),
                        value);
                    return;
                }

                index++;
            }

            // not found, add new entry
            buddy.AddDictionary(UrlTypes, index);
            buddy.AddString(PlistBuddyHelper.ToEntryName(UrlTypes, index, UrlBundleName),
                key);
            //add the array
            buddy.AddArray(UrlTypes, index, UrlScheme);
            //add the value
            buddy.AddString (PlistBuddyHelper.ToEntryName (UrlTypes, index, UrlScheme, 0),
                value);
        }
示例#4
0
 /// <summary>
 /// Ensures the games URL scheme is well formed. This is done by removing the UrlScheme field
 /// and adding a fresh one in a known-good state.
 /// </summary>
 /// <param name="buddy">Buddy.</param>
 /// <param name="index">Index.</param>
 private static void EnsureGamesUrlScheme(PlistBuddyHelper buddy, int index) {
     buddy.RemoveEntry(UrlTypes, index, UrlScheme);
     buddy.AddArray(UrlTypes, index, UrlScheme);
     buddy.AddString(PlistBuddyHelper.ToEntryName(UrlTypes, index, UrlScheme, 0),
         GetBundleId());
 }