Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="generatorComponent"></param>
        /// <param name="project"></param>
        public static void UpdateProjectSettingsForPlugin(SupportedPluginComponent generatorComponent, Project project)
        {
            _logger.Trace("PluginsManager.UpdateProjectSettingsForPlugin()");

            if (generatorComponent != null)
            {
                var template = generatorComponent.Item as IGeneratorTemplate;
                if (template != null)
                {
                    var type = template.GetType();

                    string guid = ((GuidAttribute)(type.Assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0])).Value;

                    var pluginProperties = Data.ProjectsController.GetPluginProperties(project, guid);

                    if (pluginProperties != null && pluginProperties.Parameters != null)
                    {
                        PluginSettings settings = new PluginSettings();
                        foreach (PluginParameter parameter in pluginProperties.Parameters)
                        {
                            var value = new PluginSettingValue();
                            value.Key        = parameter.Code;
                            value.Value      = parameter.Value;
                            value.UseDefault = parameter.UseDefault;
                            value.Type       = parameter.Type;
                            settings.Add(value);
                        }

                        template.UpdateSettings(settings);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the settings.
        /// </summary>
        /// <returns></returns>
        public PluginSettings GetSettings()
        {
            PluginSettings settings = new PluginSettings();

            foreach (var entry in _parameters)
            {
                PluginSettingValue value = new PluginSettingValue();
                value.Key        = entry.Value.ParameterCode;
                value.Value      = entry.Value.ParameterValue;
                value.UseDefault = entry.Value.IsDefaultValue;
                value.Type       = typeof(string);
                settings.Add(value);
            }

            return(settings);
        }
 /// <summary>
 /// Return plugin settings with specified name
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public PluginSetting this[string name]
 {
     get
     {
         foreach (var pluginSetting in PluginSettings)
         {
             if (pluginSetting.Name == name)
             {
                 return(pluginSetting);
             }
         }
         var pl = new PluginSetting()
         {
             Name = name
         };
         PluginSettings.Add(pl);
         return(pl);
     }
 }
 public void AddPluginSetting(PluginSetting pluginSetting)
 {
     PluginSettings.Add(pluginSetting);
 }