public override T GetValue <T>(string name, T defaultValue = default, TypeScopeSettings scope = TypeScopeSettings.Global)
 {
     try
     {
         if (DominationLocalStorage)
         {
             if (GetStorage(TypeScopeSettings.Local).ContainstKey(name))
             {
                 return(GetStorage(TypeScopeSettings.Local).GetValue <T>(name, defaultValue));
             }
             else
             {
                 return(GetStorage(TypeScopeSettings.Global).GetValue <T>(name, defaultValue));
             }
         }
         else
         {
             return(GetStorage(scope).GetValue <T>(name, defaultValue));
         }
     }
     catch (InvalidCastException exception)
     {
         Debug.LogException(exception);
     }
     return(defaultValue);
 }
        protected JsonFileStorage GetStorage(TypeScopeSettings scope)
        {
            switch (scope)
            {
            case TypeScopeSettings.Local:
                if (localStorage == null)
                {
                    localStorage = new JsonFileStorage(Application.streamingAssetsPath, localFilename, JsonSerializer, converters);
                }
                return(localStorage);

            default:
            case TypeScopeSettings.Global:
            {
                if (globalStorage == null)
                {
                    globalStorage = new JsonFileStorage(Application.streamingAssetsPath, globalFilename, JsonSerializer, converters);
                }
                return(globalStorage);
            }
            }
        }
예제 #3
0
 public T GetValue <T>(string name, string module, T defaultValue = default, TypeScopeSettings scope = TypeScopeSettings.Global)
 {
     return(GetValue <T>(module + "_" + name, default, scope));
예제 #4
0
 public abstract T GetValue <T>(string name, T defaultValue = default, TypeScopeSettings scope = TypeScopeSettings.Global);
 public override void SetValue <T>(string name, T value, TypeScopeSettings scope = TypeScopeSettings.Global)
 {
     GetStorage(scope).SetValue(name, value);
 }