Example #1
0
        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);
        }
Example #2
0
        public ApplicationDataSettings <T> Settings <T>(bool isProtected, string key = null)
        {
            key = DataSettingsKey.KeyOrTypeName <T>(key);

            var configuration = new DataSettingsConfiguration(this, isProtected, key);

            var applicationDataSettings = new ApplicationDataSettings <T>(configuration);

            return(applicationDataSettings);
        }