示例#1
0
        public JsonResult GetProperties(string entityName)
        {
            JSONData res = new JSONData();

            res.success = false;
            List <JPropertyInfo> list       = new List <JPropertyInfo>();
            List <string>        entityList = GetEntityList(Config.EntityProject);

            try
            {
                Assembly assembly = Assembly.Load(Config.EntityModule);
                Type     xtype    = assembly.GetType(Config.EntityModule + ".Entities." + entityName);
                System.Reflection.PropertyInfo[] propertyList = xtype.GetProperties();

                foreach (System.Reflection.PropertyInfo item in propertyList)
                {
                    JPropertyInfo prop = new JPropertyInfo();
                    string        type = item.PropertyType.ToString();
                    if (type.Contains("Collection"))
                    {
                        continue;
                    }
                    prop.PropertyName = item.Name;
                    prop.Xtype        = type;
                    prop.HasDetail    = !string.IsNullOrEmpty(entityList.FirstOrDefault(x => type.Contains(x)));
                    if (prop.HasDetail)
                    {
                        prop.Details = GetSubProperties(item.Name, assembly, type);
                    }

                    list.Add(prop);
                }
                res.success = true;

                res.data = SyncWithSavedWidget(list, entityName);
            }
            catch (Exception ex)
            {
                res.message = ex.Message;
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        private List <JPropertyInfo> GetSubProperties(string entityName, Assembly assembly, string type)
        {
            List <JPropertyInfo> list = new List <JPropertyInfo>();

            Type xtype = assembly.GetType(Config.EntityModule + ".Entities." + entityName);

            if (xtype == null)
            {
                type  = type.Substring(type.LastIndexOf(".") + 1);
                xtype = assembly.GetType(Config.EntityModule + ".Entities." + type);
            }
            System.Reflection.PropertyInfo[] propertyList = xtype.GetProperties();

            foreach (System.Reflection.PropertyInfo item in propertyList)
            {
                JPropertyInfo temp = new JPropertyInfo();
                temp.PropertyName = item.Name;
                list.Add(temp);
            }
            return(list);
        }
示例#3
0
        private List <JPropertyInfo> SyncWithSavedWidget(List <JPropertyInfo> list, string widgetName)
        {
            WidgetManager widgetManager = new WidgetManager();

            widgetManager.RootPath = Config.Root;
            JwtWidget temp = widgetManager.GetWidgetByName(widgetName);

            if (temp == null)
            {
                return(list);
            }
            foreach (var item in temp.PropertyList)
            {
                JPropertyInfo prop = list.Find(p => p.PropertyName == item.PropertyName);
                if (prop != null)
                {
                    list.Remove(prop);
                    list.Add(item);
                }
            }

            return(list);
        }