示例#1
0
        /// <summary>
        ///     获取操作链接
        ///     图标        ///
        ///     http://ui.5ug.com/metronic_v5.5.5/theme/default/dist/default/components/icons/flaticon.html
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <TableAction> GetActions(Type type, ClassPropertyAttribute classProperty)
        {
            var instance = Activator.CreateInstance(type);
            var list     = new List <TableAction>();

            if (instance is IAutoTable set)
            {
                list = set.Actions();
            }
            else if (instance is IAutoConfig)
            {
                // 如果是自动配置,则只有编辑和删除

                list.Add(new TableAction("编辑", $"/Admin/AutoConfig/Edit?Type={type.Name}"));
                list.Add(new TableAction("删除", "/api/AutoConfig/Delete"));

                // 表格右上角显示快捷操作
                list.Add(new TableAction($"新增{classProperty.Name}", $"/Admin/AutoConfig/Edit?Type={type.Name}",
                                         TableActionType.QuickAction));
            }
            else if (instance is IEntity)
            {
                // 如果实体继承了Action,则Action 实体通用删除
                list.Add(new TableAction("编辑", $"/Admin/{type.Name}/Edit"));
                list.Add(new TableAction("删除", $"/Api/{type.Name}/QueryDelete"));

                if (classProperty.IsShowQuickAction)
                {
                    list.Add(new TableAction($"新增{classProperty.Name}", $"/Admin/{type.Name}/Edit",
                                             TableActionType.QuickAction));
                }
            }

            return(list);
        }
示例#2
0
文件: Border.cs 项目: adteven/alabo
 public Border(ClassPropertyAttribute classPropertyAttribute)
 {
     this.Title       = classPropertyAttribute.Name;
     this.Description = classPropertyAttribute.Description;
     if (this.Description.IsNullOrEmpty())
     {
         this.Description = this.Title;
     }
     this.Icon = new Icon(classPropertyAttribute.Icon);
     this.Icon = new Icon(classPropertyAttribute.Icon);
 }
示例#3
0
        /// <summary>
        ///     Creates the specified configuration 类型.
        /// </summary>
        /// <param name="configType">The configuration 类型.</param>
        public CacheClassDescription Create(Type configType)
        {
            var objectCache = Ioc.Resolve <IObjectCache>();
            var cacheKey    = $"classDescription_{configType.FullName.Replace(".", "_")}";

            if (!objectCache.TryGet(cacheKey, out CacheClassDescription cacheDescription))
            {
                var classType = configType ?? throw new ArgumentNullException(nameof(configType));

                var classPropertyAttribute =
                    classType.GetTypeInfo().GetAttributes <ClassPropertyAttribute>().FirstOrDefault();
                //如果类特性为空,配置特性
                if (classPropertyAttribute == null)
                {
                    var typeName = classType.Name;
                    classPropertyAttribute      = new ClassPropertyAttribute();
                    classPropertyAttribute.Name = typeName;
                }

                //字段特性
                var propertys = classType.GetProperties().Select(e => new PropertyDescription(e.DeclaringType, e))
                                .ToArray();
                propertys = propertys.OrderBy(r => r.FieldAttribute.SortOrder).ToArray();

                //快捷操作链接
                var links = new List <ViewLink>();

                var linkMethod = configType.GetMethod("ViewLinks");
                if (linkMethod != null)
                {
                    // 使用动态方法获取链接地址
                    var config = Activator.CreateInstance(configType);
                    var target = new Interpreter().SetVariable("baseViewModel", config);
                    links = (List <ViewLink>)target.Eval("baseViewModel.ViewLinks()");
                }

                cacheDescription = new CacheClassDescription {
                    ClassType = classType,
                    ClassPropertyAttribute = classPropertyAttribute,
                    Propertys = propertys,
                    ViewLinks = links
                };

                objectCache.Set(cacheKey, cacheDescription);
            }

            return(cacheDescription);
        }
示例#4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ClassDescription" /> class.
 /// </summary>
 public ClassDescription()
 {
     ClassPropertyAttribute = new ClassPropertyAttribute();
 }