예제 #1
0
 private ActionContextFacade ActionContext(IMenuActionFacade actionFacade, IFrameworkFacade frameworkFacade, string menuPath) =>
 new ActionContextFacade
 {
     MenuPath          = menuPath,
     Target            = frameworkFacade.GetServices().List.Single(s => s.Specification.IsOfType(actionFacade.Action.OnType)),
     Action            = actionFacade.Action,
     VisibleParameters = actionFacade.Action.Parameters.Select(p => new ParameterContextFacade {
         Parameter = p, Action = actionFacade.Action
     }).ToArray()
 };
        private ActionContextFacade ActionContext(IMenuActionFacade actionFacade, string menuPath) {

            if (!string.IsNullOrEmpty(menuPath)) {
                actionFacade.Action.ExtensionData[IdConstants.MenuPath] = menuPath;
            }

            return new ActionContextFacade {
                Target = OidStrategy.FrameworkFacade.GetServices().List.Single(s => s.Specification.IsOfType(actionFacade.Action.OnType)),
                Action = actionFacade.Action,
                VisibleParameters = actionFacade.Action.Parameters.Select(p => new ParameterContextFacade {Parameter = p, Action = actionFacade.Action}).ToArray()
            };
        }
예제 #3
0
        private ActionContextFacade ActionContext(IMenuActionFacade actionFacade, string menuPath)
        {
            if (!string.IsNullOrEmpty(menuPath))
            {
                actionFacade.Action.ExtensionData[IdConstants.MenuPath] = menuPath;
            }

            return(new ActionContextFacade {
                Target = OidStrategy.FrameworkFacade.GetServices().List.Single(s => s.Specification.IsOfType(actionFacade.Action.OnType)),
                Action = actionFacade.Action,
                VisibleParameters = actionFacade.Action.Parameters.Select(p => new ParameterContextFacade {
                    Parameter = p, Action = actionFacade.Action
                }).ToArray()
            });
        }
        private static ElementDescriptor MenuActionAsElementDescriptor(this HtmlHelper html, IMenuActionFacade menuAction, IObjectFacade nakedObject, bool isEdit) {
            var actionIm = menuAction.Action;
            var actionSpec = actionIm.ReturnType;
            if (nakedObject == null) {
                var serviceIm = actionIm.OnType;

                if (serviceIm == null) {
                    throw new Exception("Action is not on a known service");
                }
                nakedObject = html.Facade().GetServices().List.SingleOrDefault(s => s.Specification.Equals(serviceIm));
            }

            if (nakedObject == null) {
                // service may not be visible 
                return null;
            }

            var actionContext = new ActionContext(html.IdHelper(), false, nakedObject, actionIm);

            RouteValueDictionary attributes;
            string tagType;
            string value;
            if (!actionContext.Action.IsVisible(actionContext.Target)) {
                return null;
            }
            var consent = actionContext.Action.IsUsable(actionContext.Target);
            if (consent.IsVetoed) {
                tagType = html.GetVetoedAction(actionContext, consent, out value, out attributes);
            }
            else if (isEdit) {
                tagType = html.GetActionAsButton(actionContext, out value, out attributes);
            }
            else {
                tagType = html.GetActionAsForm(actionContext, html.Facade().GetObjectTypeShortName(actionContext.Target.GetDomainObject()), new {id = html.Facade().OidTranslator.GetOidTranslation(actionContext.Target).Encode()}, out value, out attributes);
            }

            return new ElementDescriptor {
                TagType = tagType,
                Value = value,
                Attributes = attributes
            };
        }
예제 #5
0
        private static ElementDescriptor MenuActionAsElementDescriptor(this HtmlHelper html, IMenuActionFacade menuAction, IObjectFacade nakedObject, bool isEdit)
        {
            var actionIm   = menuAction.Action;
            var actionSpec = actionIm.ReturnType;

            if (nakedObject == null)
            {
                var serviceIm = actionIm.OnType;

                if (serviceIm == null)
                {
                    throw new Exception("Action is not on a known service");
                }
                nakedObject = html.Facade().GetServices().List.SingleOrDefault(s => s.Specification.Equals(serviceIm));
            }

            if (nakedObject == null)
            {
                // service may not be visible
                return(null);
            }

            var actionContext = new ActionContext(html.IdHelper(), false, nakedObject, actionIm);

            RouteValueDictionary attributes;
            string tagType;
            string value;

            if (!actionContext.Action.IsVisible(actionContext.Target))
            {
                return(null);
            }
            var consent = actionContext.Action.IsUsable(actionContext.Target);

            if (consent.IsVetoed)
            {
                tagType = html.GetVetoedAction(actionContext, consent, out value, out attributes);
            }
            else if (isEdit)
            {
                tagType = html.GetActionAsButton(actionContext, out value, out attributes);
            }
            else
            {
                tagType = html.GetActionAsForm(actionContext, html.Facade().GetObjectTypeShortName(actionContext.Target.GetDomainObject()), new { id = html.Facade().OidTranslator.GetOidTranslation(actionContext.Target).Encode() }, out value, out attributes);
            }

            return(new ElementDescriptor {
                TagType = tagType,
                Value = value,
                Attributes = attributes
            });
        }