コード例 #1
0
ファイル: ToBinaryFile.cs プロジェクト: malinich/assist-lib
    protected override void LoadSaves(string key, Action <Dictionary <string, object>, Exception> complete)
    {
        StringBuilder sb       = new StringBuilder();
        string        allLines = null;

        //GetFileByName(key).Open(FileMode.OpenOrCreate);
        using (BinaryReader br = new BinaryReader((GetFileByName(key).Open(FileMode.OpenOrCreate)))) {
            if (br.BaseStream.Length > 0)
            {
                allLines = br.ReadString();
                br.ReadInt32();
            }
        }
        if (complete != null)
        {
            if (string.IsNullOrEmpty(allLines))
            {
                complete(null, null);
            }
            else
            {
                complete(JSONUtuls.Deserialize(allLines), null);
            }
        }
    }
コード例 #2
0
ファイル: ToTXTFile.cs プロジェクト: malinich/assist-lib
    protected override void LoadSaves(string key, System.Action <Dictionary <string, object>, System.Exception> complete)
    {
        StringBuilder sb = new StringBuilder();

        using (StreamReader sr = new StreamReader(GetFileByName(key).ToString())) {
            String line;
            while ((line = sr.ReadLine()) != null)
            {
                sb.AppendLine(line);
            }
            sr.Close();
        }
        string allines = sb.ToString();

        if (complete != null)
        {
            if (string.IsNullOrEmpty(allines))
            {
                complete(null, null);
            }
            else
            {
                complete(JSONUtuls.Deserialize(allines), null);
            }
        }
    }
コード例 #3
0
        public T LoadISavable <T>(string key, T savable) where T : ISaveble
        {
            string json = LoadString(key);
            var    hash = JSONUtuls.Deserialize(json);

            savable.FromJSON(hash);
            return(savable);
        }
コード例 #4
0
 public static Dictionary <string, object> GetDataNode(string key)
 {
     CheckLoading();
     return(_playerPrefsLocalData.ContainsKey(key)
         ? _playerPrefsLocalData[key] is string
            ?JSONUtuls.Deserialize(_playerPrefsLocalData[key].ToString())
             : (Dictionary <string, object>)_playerPrefsLocalData[key]
            : new Dictionary <string, object>());
 }
コード例 #5
0
 private static void CheckLoading()
 {
     if (_playerPrefsLocalData == null)
     {
         var settingsJson = PlayerPrefs.GetString(editorSettingsKey);
         if (string.IsNullOrEmpty(settingsJson))
         {
             _playerPrefsLocalData = new Dictionary <string, object>();
         }
         else
         {
             _playerPrefsLocalData = JSONUtuls.Deserialize(settingsJson);
         }
     }
 }
コード例 #6
0
 private static void CheckLoading()
 {
     if (_editorSettingsData == null || _editorSettingsData.Count == 0)
     {
         var settingsJson = EditorPrefs.GetString(editorSettingsKey);
         if (string.IsNullOrEmpty(settingsJson))
         {
             _editorSettingsData = new Dictionary <string, object>();
         }
         else
         {
             var deserialized = JSONUtuls.Deserialize(settingsJson);
             if (deserialized != null)
             {
                 _editorSettingsData.AddOrSetRange(deserialized);
             }
         }
     }
 }
コード例 #7
0
        private static void Init()
        {
            if (!_inited)
            {
                _settingsDBEntry = DB.Get <LocalizationSettingsDBEntry>();

                _defaultLanguage = DB.Get <LanguageItem>(_defaultSystemLanguage.ToString());

                var localizationSettingsData = PlayerPrefsLocalData.GetDataNode(LOCALIZATION_SETTINGS_KEY);

                _settings = JSONUtuls.Deserialize <Settings>(localizationSettingsData);

                if (_settings == null)
                {
                    _settings = new Settings();
                }

                if (string.IsNullOrEmpty(_settings.savedLanguage))
                {
                    ChangeLanguage(_currentSystemLanguage.ToString());
                }
                else
                {
                    var savedLanguage = DB.Get <LanguageItem>(_settings.savedLanguage);
                    if (savedLanguage != null)
                    {
                        ChangeLanguage(savedLanguage);
                    }
                    else
                    {
                        Debug.LogWarning(string.Format("Language not found: {0}", _settings.savedLanguage));
                    }
                }

                _inited = true;
            }
        }
コード例 #8
0
        public static T Get <T>(string key) where T : IJsonDeserializable
        {
            var node = GetDataNode(key);

            return(JSONUtuls.Deserialize <T>(node));
        }