コード例 #1
0
ファイル: ApplicationInfo.cs プロジェクト: Eye-Soft/HSDK
        public ApplicationDataSettings <T> Settings <T>(
            string key, bool isProtected, string[] subFolders = null, DataScope scope = DataScope.CurrentUser)
        {
            var applicationData = new ApplicationData(this, scope, subFolders);

            key = DataSettingsKey.KeyOrTypeName <T>(key);

            var fullKey = DataSettingsKey.GetFullPath(applicationData, key);

            ApplicationDataSettings <T> applicationDataSettings;

            if (settingsDictionary.ContainsKey(fullKey))
            {
                applicationDataSettings = (ApplicationDataSettings <T>)settingsDictionary[fullKey];

                var fullKeyWithExtension = DataSettingsKey.GetFullPathWithExtension(applicationData, key, isProtected);

                if (!applicationDataSettings.Configuration.Path.Equals(fullKeyWithExtension))
                {
                    var message = string.Format("Cannot change the ApplicationDataSettings with key {0} if already exists.", key);

                    throw new InvalidOperationException(message);
                }

                return(applicationDataSettings);
            }

            applicationDataSettings = applicationData.Settings <T>(isProtected, key);

            return(applicationDataSettings);
        }
コード例 #2
0
ファイル: ApplicationInfo.cs プロジェクト: Eye-Soft/HSDK
        internal void RegisterSettings <T>(ApplicationDataSettings <T> applicationDataSettings)
        {
            var key = DataSettingsKey.GetFullPath(applicationDataSettings.Configuration.Data, applicationDataSettings.Configuration.Key);

            settingsDictionary.Add(key, applicationDataSettings);
        }