public IEnumerable<UIOMaticPropertyInfo> GetAllProperties(string typeName, bool includeIgnored = false) { var ar = typeName.Split(','); var currentType = Type.GetType(ar[0] + ", "+ ar[1]); foreach (var prop in currentType.GetProperties()) { var attris = prop.GetCustomAttributes(); if (includeIgnored || attris.All(x => x.GetType() != typeof(UIOMaticIgnoreFieldAttribute))) { if (attris.Any(x => x.GetType() == typeof (UIOMaticFieldAttribute))) { var attri = (UIOMaticFieldAttribute) attris.SingleOrDefault(x => x.GetType() == typeof (UIOMaticFieldAttribute)); var key = prop.Name; string view = attri.GetView(); if (prop.PropertyType == typeof(bool) && attri.View == "textfield") view = "~/App_Plugins/UIOMatic/Backoffice/Views/checkbox.html"; if (prop.PropertyType == typeof(DateTime) && attri.View == "textfield") view = "~/App_Plugins/UIOMatic/Backoffice/Views/datetime.html"; if ((prop.PropertyType == typeof(int) | prop.PropertyType == typeof(long)) && attri.View == "textfield") view = "~/App_Plugins/UIOMatic/Backoffice/Views/number.html"; var pi = new UIOMaticPropertyInfo { Key = key, Name = attri.Name, Tab = string.IsNullOrEmpty(attri.Tab) ? "Misc" : attri.Tab, Description = attri.Description, View = IOHelper.ResolveUrl(view), Type = prop.PropertyType.ToString() , Config = string.IsNullOrEmpty(attri.Config) ? null : (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(attri.Config) }; yield return pi; } else { var key = prop.Name; string view = "~/App_Plugins/UIOMatic/Backoffice/Views/textfield.html"; if(prop.PropertyType == typeof(bool)) view = "~/App_Plugins/UIOMatic/Backoffice/Views/checkbox.html"; if (prop.PropertyType == typeof(DateTime)) view = "~/App_Plugins/UIOMatic/Backoffice/Views/datetime.html"; if (prop.PropertyType == typeof(int) | prop.PropertyType == typeof(long)) view = "~/App_Plugins/UIOMatic/Backoffice/Views/number.html"; var pi = new UIOMaticPropertyInfo { Key = key, Name = prop.Name, Tab = "Misc", Description = string.Empty, View = IOHelper.ResolveUrl(view), Type = prop.PropertyType.ToString() }; yield return pi; } } } }
public IEnumerable<UIOMaticPropertyInfo> GetAllProperties(string typeName) { var ar = typeName.Split(','); var currentType = Type.GetType(ar[0] + ", "+ ar[1]); foreach (var prop in currentType.GetProperties()) { if (prop.Name != "UmbracoTreeNodeName") { var attris = prop.GetCustomAttributes(); if (attris.All(x => x.GetType() != typeof (UIOMaticIgnoreFieldAttribute))) { if (attris.Any(x => x.GetType() == typeof (UIOMaticFieldAttribute))) { var attri = (UIOMaticFieldAttribute) attris.SingleOrDefault(x => x.GetType() == typeof (UIOMaticFieldAttribute)); var key = prop.Name; //if (attris.Any(x=> x.GetType() == typeof(ColumnAttribute))) // key = ((ColumnAttribute) // attris.SingleOrDefault(x => x.GetType() == typeof(ColumnAttribute))).Name; string view = attri.GetView(); if (prop.PropertyType == typeof(bool) && attri.View == "textfield") view = "~/App_Plugins/UIOMatic/Backoffice/Views/checkbox.html"; if (prop.PropertyType == typeof(DateTime) && attri.View == "textfield") view = "~/App_Plugins/UIOMatic/Backoffice/Views/datetime.html"; if ((prop.PropertyType == typeof(int) | prop.PropertyType == typeof(long)) && attri.View == "textfield") view = "~/App_Plugins/UIOMatic/Backoffice/Views/number.html"; var pi = new UIOMaticPropertyInfo { Key = key, Name = attri.Name, Description = attri.Description, View = IOHelper.ResolveUrl(view), Type = prop.PropertyType.ToString() }; yield return pi; } else { var key = prop.Name; //if (attris.Any(x => x.GetType() == typeof(ColumnAttribute))) // key = ((ColumnAttribute) // attris.SingleOrDefault(x => x.GetType() == typeof(ColumnAttribute))).Name; string view = "~/App_Plugins/UIOMatic/Backoffice/Views/textfield.html"; if(prop.PropertyType == typeof(bool)) view = "~/App_Plugins/UIOMatic/Backoffice/Views/checkbox.html"; if (prop.PropertyType == typeof(DateTime)) view = "~/App_Plugins/UIOMatic/Backoffice/Views/datetime.html"; if (prop.PropertyType == typeof(int) | prop.PropertyType == typeof(long)) view = "~/App_Plugins/UIOMatic/Backoffice/Views/number.html"; var pi = new UIOMaticPropertyInfo { Key = key, Name = prop.Name, Description = string.Empty, View = IOHelper.ResolveUrl(view), Type = prop.PropertyType.ToString() }; yield return pi; } } } } }