Example #1
0
        private void DoImport()
        {
            List <SettingsGroupDescriptor> groups = SettingsGroupDescriptor.ListInstalledSettingsGroups(true);
            BackgroundTask task = new BackgroundTask(
                delegate(IBackgroundTaskContext context)
            {
                for (int i = 0; i < groups.Count; i++)
                {
                    if (context.CancelRequested)
                    {
                        context.Cancel();
                        break;
                    }

                    SettingsGroupDescriptor group = groups[i];
                    context.ReportProgress(new BackgroundTaskProgress(i, groups.Count, string.Format("Importing {0}", group.Name)));

                    List <SettingsPropertyDescriptor> props = SettingsPropertyDescriptor.ListSettingsProperties(group);
                    _configStore.ImportSettingsGroup(group, props);
                }
            },
                true);

            ProgressDialog.Show(task, this.Host.DesktopWindow, true);
        }
        private void DoImport()
        {
            var groups = SettingsGroupDescriptor.ListInstalledSettingsGroups(SettingsGroupFilter.SupportEnterpriseStorage);
            var task   = new BackgroundTask(
                delegate(IBackgroundTaskContext context)
            {
                for (var i = 0; i < groups.Count; i++)
                {
                    if (context.CancelRequested)
                    {
                        context.Cancel();
                        break;
                    }

                    var group = groups[i];
                    context.ReportProgress(new BackgroundTaskProgress(i, groups.Count, string.Format("Importing {0}", group.Name)));

                    var props = SettingsPropertyDescriptor.ListSettingsProperties(group);
                    _settingsStore.ImportSettingsGroup(group, props);
                }
            },
                true)
            {
                ThreadUICulture = Desktop.Application.CurrentUICulture
            };

            ProgressDialog.Show(task, this.Host.DesktopWindow);
        }
 /// <summary>
 /// Updates this instance from the specified descriptor.
 /// </summary>
 /// <param name="descriptor"></param>
 public void UpdateFromDescriptor(SettingsPropertyDescriptor descriptor)
 {
     _name         = descriptor.Name;
     _typeName     = descriptor.TypeName;
     _scope        = descriptor.Scope.ToString();
     _description  = descriptor.Description;
     _defaultValue = descriptor.DefaultValue;
 }
Example #4
0
            private Property CreateProperty(PropertyInfo property, SettingsProperty settingsProperty, SettingsPropertyValueCollection settingsPropertyValues)
            {
                var descriptor            = new SettingsPropertyDescriptor(property);
                var settingsPropertyValue = settingsPropertyValues[settingsProperty.Name];
                var defaultValue          = settingsProperty.DefaultValue;
                var serializedValue       = settingsPropertyValue == null ? null : settingsPropertyValue.SerializedValue;

                return(new Property(descriptor, (serializedValue ?? defaultValue).ToString()));
            }
Example #5
0
 private static IList <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group, IApplicationConfigurationReadService service)
 {
     try
     {
         // try to get the information from the local plugins
         return(SettingsPropertyDescriptor.ListSettingsProperties(group));
     }
     catch (SettingsException)
     {
         // guess it's not a local group, so use the configuration service to obtain the properties
         return(service.ListSettingsProperties(new ListSettingsPropertiesRequest(group)).Properties);
     }
 }
Example #6
0
        public static Dictionary <string, string> CreateSettingsValues(Type type, MigrationScope migrationScope, SettingValue settingValue)
        {
            var values = new Dictionary <string, string>();
            SettingsGroupDescriptor group = new SettingsGroupDescriptor(type);

            foreach (var property in SettingsPropertyDescriptor.ListSettingsProperties(group))
            {
                var value = CreateSettingValue(property, migrationScope, settingValue);
                if (value != null)
                {
                    values[property.Name] = value;
                }
            }
            return(values);
        }
Example #7
0
        public static string CreateSettingValue(SettingsPropertyDescriptor property, MigrationScope migrationScope, SettingValue settingValue)
        {
            if (settingValue == SettingValue.Default)
            {
                return(property.DefaultValue);
            }

            if (migrationScope == MigrationScope.User && property.Scope == SettingScope.Application)
            {
                return(null);
            }

            if (property.Scope == SettingScope.User && migrationScope == MigrationScope.Shared)
            {
                return(CreateUserDefaultSettingValue(property.Name, settingValue));
            }

            return(CreateSettingValue(property.Name, settingValue));
        }
Example #8
0
        /// <summary>
        /// Import settings groups defined in local plugins.
        /// </summary>
        private static void ImportSettingsGroups()
        {
            var groups = SettingsGroupDescriptor.ListInstalledSettingsGroups(SettingsGroupFilter.SupportEnterpriseStorage);

            foreach (var g in groups)
            {
                Platform.Log(LogLevel.Info, "Import settings group {0}, Version={1}, Type={2}", g.Name, g.Version.ToString(), g.AssemblyQualifiedTypeName);
            }

            Platform.GetService(
                delegate(Configuration.IConfigurationService service)
            {
                foreach (var group in groups)
                {
                    var props = SettingsPropertyDescriptor.ListSettingsProperties(group);
                    service.ImportSettingsGroup(new Configuration.ImportSettingsGroupRequest(group, props));
                }
            });
        }
 /// <summary>
 /// Returns settings properties for specified group, assuming plugin containing group resides on local machine
 /// </summary>
 /// <param name="group"></param>
 /// <returns></returns>
 public IList <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group)
 {
     return(SettingsPropertyDescriptor.ListSettingsProperties(group));
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="descriptor">The descriptor for the property.</param>
 /// <param name="value">The current value of the property.</param>
 public Property(SettingsPropertyDescriptor descriptor, string value)
 {
     _descriptor    = descriptor;
     _startingValue = _value = value;
 }
Example #11
0
		public static string CreateSettingValue(SettingsPropertyDescriptor property, MigrationScope migrationScope, SettingValue settingValue)
		{
			if (settingValue == SettingValue.Default)
				return property.DefaultValue;

			if (migrationScope == MigrationScope.User && property.Scope == SettingScope.Application)
				return null;

			if (property.Scope == SettingScope.User && migrationScope == MigrationScope.Shared)
				return CreateUserDefaultSettingValue(property.Name, settingValue);

			return CreateSettingValue(property.Name, settingValue);
		}