private ActionInfo ConvertActionToDto <T>(IAction <T> action, string actionName, IEnumerable <Guid> ids)
        {
            string group = null;

            foreach (var attr in action.GetType().GetCustomAttributes(typeof(ActionGroupAttribute), false))
            {
                group = (attr as ActionGroupAttribute)?.Group;
            }

            int orderNumber = 0;

            foreach (var attr in action.GetType().GetCustomAttributes(typeof(OrderNumberAttribute), false))
            {
                orderNumber = (attr as OrderNumberAttribute)?.Value ?? orderNumber;
            }

            ActionAccess access = ActionAccess.Everywhere;

            foreach (var attr in action.GetType().GetCustomAttributes(typeof(ActionAccessAttribute), false))
            {
                access = (attr as ActionAccessAttribute)?.Access ?? access;
            }

            var dto = new ActionDto
            {
                Color           = action.Color.ToString().ToLowerFirstLetter(),
                Name            = actionName,
                Description     = action.Description,
                Group           = group,
                AllowedFromGrid = access != ActionAccess.FormOnly,
                AllowedFromForm = access != ActionAccess.GridOnly,
                Ids             = ids.Select(x => x.ToString())
            };

            return(new ActionInfo
            {
                Dto = dto,
                OrderNumber = orderNumber
            });
        }
Пример #2
0
 public ActionService(ActionAccess actionAccess)
 {
     _actionAccess = actionAccess;
 }
 public ActionAccessAttribute(ActionAccess access)
 {
     Access = access;
 }