コード例 #1
0
        public void SaveValues <T>(string key, T[] values) where T : IConvertible, IComparable
        {
            Type t = typeof(T);

            ThrowExceptionWhenISaveable("It is forbidden use this method to save an `ISaveable`! Use `SaveRefs` instead!", t);
            if (t.IsClass && !t.IsPrimitive && t != typeof(string))
            {
                throw new Exception(string.Format("Can't save list of values under key `{1}` for they are not of a value or primitive type!", values, key));
            }
            SaveStruct(key, SaveableArray.From(values));
        }
コード例 #2
0
        public ValueStorageDictionary(string parentStorageCapsuleID, Dictionary <string, SaveableValueSection> loadedValues)
        {
            ParentStorageCapsuleID = parentStorageCapsuleID;
            _keyToNormalValue      = loadedValues;

            SaveableValueSection keysToKeepSection = GetValueSection(VALUE_KEYS_TO_KEEP_KEY);

            if (keysToKeepSection.IsValid)
            {
                _keysToKeep = new List <string>(SaveableArray.To <string>((SaveableArray)keysToKeepSection.GetValue(typeof(SaveableArray))));
            }
        }
コード例 #3
0
        public StorageDictionary(string parentStorageCapsuleID, IStorageAccess storageAccess, Dictionary <string, SaveableValueSection> loadedValues, Dictionary <string, object> loadedRefs) : base(parentStorageCapsuleID, loadedValues)
        {
            _storageAccess    = storageAccess;
            _keyToReferenceID = loadedRefs;

            SaveableValueSection keysToKeepSection = GetValueSection(REF_KEYS_TO_KEEP_KEY);

            if (keysToKeepSection.IsValid)
            {
                _keysToKeep = new List <string>(SaveableArray.To <string>((SaveableArray)keysToKeepSection.GetValue(typeof(SaveableArray))));
            }
        }
コード例 #4
0
        public bool LoadStructs <T>(string key, out T[] values) where T : struct
        {
            if (LoadStruct(key, out SaveableArray <T> oldSaveableArray))
            {
                values = SaveableArray <T> .To(oldSaveableArray);

                return(true);
            }
            else if (LoadStruct(key, out SaveableArray newSaveableArray))
            {
                values = SaveableArray.To <T>(newSaveableArray);
                return(true);
            }

            values = null;
            return(false);
        }
コード例 #5
0
        public bool LoadValues <T>(string key, out T[] values) where T : IConvertible, IComparable
        {
            ThrowExceptionWhenISaveable("It is forbidden use this method to load an `ISaveable`! Use `LoadRefs` instead!", typeof(T));

            if (LoadStruct(key, out SaveableArray <T> oldSaveableArray))
            {
                values = SaveableArray <T> .To(oldSaveableArray);

                return(true);
            }
            else if (LoadStruct(key, out SaveableArray newSaveableArray))
            {
                values = SaveableArray.To <T>(newSaveableArray);
                return(true);
            }

            values = null;
            return(false);
        }
コード例 #6
0
 public void SaveStructs <T>(string key, T[] values) where T : struct
 {
     SaveStruct(key, SaveableArray.From(values));
 }
コード例 #7
0
 private void SetKeysToKeep()
 {
     SetValue(REF_KEYS_TO_KEEP_KEY, SaveableArray.From(_keysToKeep.ToArray()));
 }