Ejemplo n.º 1
0
        /// <summary>
        /// Fills the plugindescriptor with the plugins settings.
        /// </summary>
        /// <param name="plugin">The plugindescriptor.</param>
        /// <param name="type">The plugintype.</param>
        private static void SetPluginSettings(PluginDescriptor plugin, Type type)
        {
            // Fetch plugin settings
            foreach (var property in type.GetProperties())
            {
                CustomAttributeData attribute = CustomAttributeData.GetCustomAttributes(property).FirstOrDefault(x => x.Constructor.DeclaringType.FullName == typeof(PluginSettingAttribute).FullName);
                if (attribute == null)
                {
                    continue;
                }

                PluginSettingDescriptor setting = new PluginSettingDescriptor();
                setting.Name        = property.Name;
                setting.SettingType = property.PropertyType;

                foreach (var namedArg in attribute.NamedArguments)
                {
                    if (namedArg.MemberInfo.Name == "Name")
                    {
                        setting.Name = (string)namedArg.TypedValue.Value;
                    }
                    else if (namedArg.MemberInfo.Name == "Required")
                    {
                        setting.Required = (bool)namedArg.TypedValue.Value;
                    }
                }

                plugin.Settings.Add(setting);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fills the plugindescriptor with the plugins settings.
        /// </summary>
        /// <param name="plugin">The plugindescriptor.</param>
        /// <param name="type">The plugintype.</param>
        private static void SetPluginSettings(PluginDescriptor plugin, Type type)
        {
            // Fetch plugin settings
              foreach (var property in type.GetProperties())
              {
            CustomAttributeData attribute = CustomAttributeData.GetCustomAttributes(property).FirstOrDefault(x => x.Constructor.DeclaringType.FullName == typeof(PluginSettingAttribute).FullName);
            if (attribute == null)
              continue;

            PluginSettingDescriptor setting = new PluginSettingDescriptor();
            setting.Name = property.Name;
            setting.SettingType = property.PropertyType;

            foreach (var namedArg in attribute.NamedArguments)
            {
              if (namedArg.MemberInfo.Name == "Name")
            setting.Name = (string)namedArg.TypedValue.Value;
              else if (namedArg.MemberInfo.Name == "Required")
            setting.Required = (bool)namedArg.TypedValue.Value;
            }

            plugin.Settings.Add(setting);
              }
        }