public static void Delete <TEntity, TProperty>(TEntity entity, Expression <Func <TEntity, TProperty> > expr)
        {
            string fieldKey = GetFieldKey(entity, expr);

            PlayerPrefsProvider.DeleteKey(fieldKey);
            PlayerPrefsProvider.Save();
        }
 public static void Delete <TEntity>(string entityId)
 {
     foreach (string entityKey in GetEntityKeys(typeof(TEntity), entityId))
     {
         PlayerPrefsProvider.DeleteKey(entityKey);
     }
     PlayerPrefsProvider.Save();
 }
 public static void Delete(object entity)
 {
     foreach (string entityKey in GetEntityKeys(entity))
     {
         PlayerPrefsProvider.DeleteKey(entityKey);
     }
     PlayerPrefsProvider.Save();
 }
 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 Save(object entity)
        {
            string entityId   = GetEntityId(entity);
            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();
                PlayerPrefsFieldHandler fieldHandler = PlayerPrefsFieldFactory.Get(fieldType);
                fieldHandler.SetValue(fieldKey, dataMemberInfo, entity);
            }
            PlayerPrefsProvider.Save();
        }
        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));
                }
            }
        }
예제 #7
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);
        }
예제 #8
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));
        }