public static void ApplyProperties(this PluginContainer pluginContainer, IEnumerable <ExtendedProperty> properties)
        {
            if (pluginContainer.IsLoaded)
            {
                IEnumerable <PropertyInfo> reflectedProperties = pluginContainer.GetReflectedProperties();

                foreach (ExtendedProperty item in properties)
                {
                    PropertyInfo property = reflectedProperties.FirstOrDefault(p => string.Compare(p.Name, item.Name, true) == 0);

                    if (property != null && property.CanWrite)
                    {
                        property.SetValue(pluginContainer.Instance, item.Value, null);
                    }
                }
            }
        }
        public static bool GetRequired(this PluginContainer plugin, string propertyName)
        {
            bool?required = plugin.GetPropertyDefinition <bool?>(propertyName, "Required");

            if (required.HasValue)
            {
                return(required.Value);
            }

            PropertyInfo property = plugin.GetReflectedProperties().FirstOrDefault(rp => rp.Name == propertyName);

            if (property != null)
            {
                return(!property.PropertyType.IsClass);
            }

            return(false);
        }
        private static IEnumerable <ExtendedProperty> getProperties(PluginContainer pluginContainer, bool useDefaultValues)
        {
            List <ExtendedProperty> properties = new List <ExtendedProperty>();

            if (pluginContainer.IsLoaded)
            {
                IEnumerable <PropertyInfo> reflectedProperties = pluginContainer.GetReflectedProperties();

                foreach (PropertyInfo property in reflectedProperties)
                {
                    if (property.CanRead && property.CanWrite)
                    {
                        object value = property.GetValue(pluginContainer.Instance, null);

                        if (useDefaultValues)
                        {
                            object defaultValue = pluginContainer.GetDefaultValue(property.Name);

                            if (defaultValue != null)
                            {
                                if (defaultValue.GetType() != property.PropertyType)
                                {
                                    throw new InvalidOperationException(string.Format("DefaultValueAttribute on property {0} is invalid. Default value type '{1}' does not match property type '{2}'", property.Name, defaultValue.GetType().FullName, value.GetType().FullName));
                                }

                                value = defaultValue;
                            }
                        }

                        properties.Add(new ExtendedProperty(property.Name, property.PropertyType, useDefaultValues ? pluginContainer.GetDefaultValue(property.Name) ?? property.GetValue(pluginContainer.Instance, null) : property.GetValue(pluginContainer.Instance, null)));
                    }
                }
            }

            return(properties);
        }