public static bool Exists <TEntity>(string entityId)
 {
     foreach (string entityKey in GetEntityKeys(typeof(TEntity), entityId))
     {
         if (PlayerPrefsProvider.HasKey(entityKey))
         {
             return(true);
         }
     }
     return(false);
 }
        public static void Load(object entity, string entityId)
        {
            Type entityType = entity.GetType();
            List <DataMemberInfo> dataMemberInfos = PlayerPrefsCache.GetDataMemberInfoWithFieldAttribute(entityType);

            foreach (DataMemberInfo dataMemberInfo in dataMemberInfos)
            {
                string fieldKey  = GetFieldKey(entityId, entityType, dataMemberInfo);
                Type   fieldType = dataMemberInfo.GetMemberInfoType();
                if (PlayerPrefsProvider.HasKey(fieldKey))
                {
                    PlayerPrefsFieldHandler fieldHandler = PlayerPrefsFieldFactory.Get(fieldType);
                    dataMemberInfo.SetValue(entity, fieldHandler.GetValue(fieldKey));
                }
            }
        }
Пример #3
0
        private Dictionary <string, object> LoadForMacOS()
        {
            // Plist from from https://github.com/animetrics/PlistCS:
            string fullPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/Library/Preferences/unity." + PlayerSettings.companyName + "." + PlayerSettings.productName + ".plist";
            Dictionary <string, object> plistDic = new Dictionary <string, object>();

            if (File.Exists(fullPath))
            {
                plistDic = (Dictionary <string, object>)Plist.readPlist(fullPath);
                foreach (string key in plistDic.Keys.ToArray())
                {
                    if (!PlayerPrefsProvider.HasKey(key))
                    {
                        plistDic.Remove(key);
                    }
                }
            }
            return(plistDic);
        }
Пример #4
0
        private Dictionary <string, object> LoadForWindows()
        {
            Dictionary <string, object> values = new Dictionary <string, object>();
            string      registryPath           = GetWindowsRegestryPath();
            RegistryKey registryKey            = Registry.CurrentUser.OpenSubKey(registryPath);

            //When there are no any records, OpenSubKey return null but not object with no values.
            if (registryKey != null)
            {
                foreach (string valueName in registryKey.GetValueNames())
                {
                    object ppValue = registryKey.GetValue(valueName);
                    string ppKey   = valueName.Remove(valueName.LastIndexOf("_"));
                    if (PlayerPrefsProvider.HasKey(ppKey))
                    {
                        values.Add(ppKey, ppValue);
                    }
                }
            }
            return(values);
        }
        public static bool HasKey <TEntity, TProperty>(TEntity entity, Expression <Func <TEntity, TProperty> > expr)
        {
            string fieldKey = GetFieldKey(entity, expr);

            return(PlayerPrefsProvider.HasKey(fieldKey));
        }