コード例 #1
0
        public static InlineActionRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, ActionContextFacade actionContext, RestControlFlags flags)
        {
            IConsentFacade consent = actionContext.Action.IsUsable(actionContext.Target);

            var actionRepresentationStrategy = new ActionRepresentationStrategy(oidStrategy, req, actionContext, flags);

            if (consent.IsVetoed)
            {
                var optionals = new List <OptionalProperty> {
                    new OptionalProperty(JsonPropertyNames.DisabledReason, consent.Reason)
                };
                return(CreateWithOptionals <InlineActionRepresentation>(new object[] { oidStrategy, actionRepresentationStrategy }, optionals));
            }

            return(new InlineActionRepresentation(oidStrategy, actionRepresentationStrategy));
        }
コード例 #2
0
        public static InlineMemberAbstractRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, RestControlFlags flags, bool asTableColumn)
        {
            IConsentFacade consent   = propertyContext.Property.IsUsable(propertyContext.Target);
            var            optionals = new List <OptionalProperty>();

            if (consent.IsVetoed)
            {
                optionals.Add(new OptionalProperty(JsonPropertyNames.DisabledReason, consent.Reason));
            }

            if (propertyContext.Property.IsCollection)
            {
                return(InlineCollectionRepresentation.Create(oidStrategy, req, propertyContext, optionals, flags, asTableColumn));
            }

            return(InlinePropertyRepresentation.Create(oidStrategy, req, propertyContext, optionals, flags));
        }
        public static InlineActionRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, ActionContextFacade actionContext, RestControlFlags flags)
        {
            IConsentFacade consent = actionContext.Action.IsUsable(actionContext.Target);

            var strategy  = AbstractActionRepresentationStrategy.GetStrategy(true, oidStrategy, req, actionContext, flags);
            var optionals = new List <OptionalProperty>();

            if (consent.IsVetoed)
            {
                optionals.Add(new OptionalProperty(JsonPropertyNames.DisabledReason, consent.Reason));
            }

            if (strategy.ShowParameters())
            {
                optionals.Add(new OptionalProperty(JsonPropertyNames.Parameters, strategy.GetParameters()));
            }

            if (optionals.Any())
            {
                return(CreateWithOptionals <InlineActionRepresentation>(new object[] { oidStrategy, strategy }, optionals));
            }

            return(new InlineActionRepresentation(oidStrategy, strategy));
        }
コード例 #4
0
 internal static string GetVetoedAction(this HtmlHelper html, ActionContext actionContext, IConsentFacade consent, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class = actionContext.GetActionClass(),
         title = consent.Reason
     });
     return "div";
 }