Esempio n. 1
0
        public Variation GetByName(StringKey name, double weight = 1.0)
        {
            if (!_variations.ContainsKey(name.Normalize()))
            {
                throw new KeyNotFoundException($"The variation \"{name}\" is not registered.");
            }

            return(_variations[name.Normalize()](weight));
        }
        internal void AddElement(StringKey key)
        {
            if (mElementNames.Contains(key.Normalize()))
            {
                return;
            }

            mElementNames.Add(key.Normalize());
            mOriginalNames.Add(key);
        }
        public override IBlobStore GetChildStore(StringKey childStorageKey, bool?isReadOnly = null)
        {
            if (!mChildFolders.ContainsKey(childStorageKey.Normalize()))
            {
                var childStore = new CompressedBlobStoreSection(mThisFolderName.Concat(childStorageKey), mArchive);

                AddChildFolder(childStorageKey, childStore);

                return(childStore);
            }

            return(mChildFolders[childStorageKey.Normalize()]);
        }
        internal void AddChildFolder(StringKey key, [NotNull] CompressedBlobStoreSection folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            if (mChildFolders.ContainsKey(key.Normalize()))
            {
                mChildFolders[key.Normalize()] = folder;
                return;
            }

            mChildFolders.Add(key.Normalize(), folder);
            mOriginalChildFolderNames.Add(key);
        }
Esempio n. 5
0
        protected IKeyValueStore <string> LoadSettingGroup(StringKey settingGroupKey)
        {
            if (mSettingGroups.ContainsKey(settingGroupKey.Normalize()))
            {
                return(mSettingGroups[settingGroupKey.Normalize()]);
            }

            var settingGroupBlobStore = mStore
                                        .GetChildStore("Settings", false);

            var settingGroup = CreateKeyValueStore(settingGroupBlobStore, settingGroupKey);

            mSettingGroups.AddOrUpdate(settingGroupKey.Normalize(), settingGroup);

            return(settingGroup);
        }
Esempio n. 6
0
        protected override object GetValue(StringKey key)
        {
            if (mInstance == null)
            {
                return(null);
            }

            return(mProperties.GetValueByKeyOrDefault(key.Normalize())?.GetValue(mInstance));
        }
Esempio n. 7
0
        public void Register([NotNull] Type variationType, StringKey variationName = default)
        {
            if (variationType == null)
            {
                throw new ArgumentNullException(nameof(variationType));
            }

            if (variationName.IsEmpty)
            {
                var attribute = variationType.GetCustomAttribute <VariationAttribute>();
                if (attribute == null)
                {
                    throw new TypeLoadException($"The type \"{variationType.FullName}\" is not decorated with a \"{nameof(VariationAttribute)}\" and no specific variation name has been provided.");
                }

                variationName = attribute.Name;
            }

            _variations.AddOrUpdate(variationName.Normalize(), d => Create(variationType, d));
            _names.AddOrUpdate(variationName.Normalize(), variationName);
        }
Esempio n. 8
0
 public override bool Exists(StringKey key)
 {
     return(mProperties.ContainsKey(key.Normalize()));
 }
 public override bool HasChildStore(StringKey childStorageKey)
 {
     return(mChildFolders.ContainsKey(childStorageKey.Normalize()));
 }
 public override bool Exists(StringKey key)
 {
     return(mElementNames.Contains(key.Normalize()));
 }