Smeedee.Model.SmeedeeApp.GetModelFromType C# (CSharp) Method

GetModelFromType() private static method

private static GetModelFromType ( Type type ) : WidgetModel
type System.Type
return WidgetModel
        private static WidgetModel GetModelFromType(Type type)
        {
            var widgetAttributes = type.GetCustomAttributes(typeof(WidgetAttribute), true);
            var typeHasAttributes = (widgetAttributes.Count() > 0 && widgetAttributes is WidgetAttribute[]);
            if (!typeHasAttributes)
                throw new ArgumentException("A widget was passed without class attributes");

            var model = ModelFromAttributes(((WidgetAttribute[])widgetAttributes)[0], type);
            return model;
        }