public static PropertyAppearance GetAppearance(this PluginContainer pluginContainer, string propertyName)
        {
            object appearanceValue = pluginContainer.GetPropertyDefinition <object>(propertyName, "Appearance");

            if (appearanceValue == null)
            {
                return(null);
            }

            if (appearanceValue is PropertyAppearance)
            {
                PropertyAppearance propertyAppearance = (PropertyAppearance)appearanceValue;

                propertyAppearance.Width  = verifyWidth(propertyAppearance.Width);
                propertyAppearance.Height = verifyHeight(propertyAppearance.Height);

                return(propertyAppearance);
            }

            IDictionary <string, object> values = new RouteValueDictionary(appearanceValue);
            object widthValue  = values.ContainsKey("Width") ? values["Width"] : null;
            object heightValue = values.ContainsKey("Height") ? values["Height"] : null;

            if (widthValue != null || heightValue != null)
            {
                return new PropertyAppearance()
                       {
                           Width = verifyWidth(widthValue), Height = verifyHeight(heightValue)
                       }
            }
            ;

            return(null);
        }
        public static PropertyGroup GetGroup(this PluginContainer pluginContainer, string propertyName)
        {
            object groupValue = pluginContainer.GetPropertyDefinition <object>(propertyName, "Group");

            if (groupValue == null)
            {
                return(null);
            }

            if (groupValue is PropertyGroup)
            {
                return((PropertyGroup)groupValue);
            }

            IDictionary <string, object> values = new RouteValueDictionary(groupValue);
            object nameValue  = values.ContainsKey("Name") ? values["Name"] : null;
            object orderValue = values.ContainsKey("Order") ? values["Order"] : null;

            if (nameValue != null || orderValue != null)
            {
                string name  = nameValue as string;
                int    order = int.MaxValue;

                if (orderValue is int)
                {
                    order = (int)orderValue;
                }

                return(new PropertyGroup(name, order));
            }

            return(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);
        }
        public static int GetOrder(this PluginContainer pluginContainer, string propertyName)
        {
            object orderValue = pluginContainer.GetPropertyDefinition <object>(propertyName, "Order");

            if (orderValue is int)
            {
                return((int)orderValue);
            }

            if (orderValue is string)
            {
                int order;

                if (int.TryParse((string)orderValue, out order))
                {
                    return(order);
                }
            }

            return(int.MaxValue);
        }
 public static string GetLabelText(this PluginContainer pluginContainer, string propertyName)
 {
     return(pluginContainer.GetPropertyDefinition <string>(propertyName, "LabelText"));
 }
 public static string GetHelpUrl(this PluginContainer pluginContainer, string propertyName)
 {
     return(pluginContainer.GetPropertyDefinition <string>(propertyName, "HelpUrl"));
 }
 public static object GetDefaultValue(this PluginContainer pluginContainer, string propertyName)
 {
     return(pluginContainer.GetPropertyDefinition <object>(propertyName, "DefaultValue"));
 }