Ejemplo n.º 1
0
 public ActionContextSurface ToActionContextSurface(INakedObjectsSurface surface) {
     var ac = new ActionContextSurface {
         Action = new NakedObjectActionWrapper(Action, surface, OverloadedUniqueId ?? ""),
         VisibleParameters = VisibleParameters.Select(p => p.ToParameterContextSurface(surface)).ToArray()
     };
     return ToContextSurface(ac, surface);
 }
Ejemplo n.º 2
0
 public ActionRepresentationStrategy(HttpRequestMessage req, ActionContextSurface actionContext, RestControlFlags flags) : base(flags)
 {
     this.req           = req;
     this.actionContext = actionContext;
     self          = new MemberRelType(RelValues.Self, new UriMtHelper(req, actionContext));
     parameterList = GetParameterList();
 }
Ejemplo n.º 3
0
 public RestSnapshot(ActionContextSurface actionContext, HttpRequestMessage req, RestControlFlags flags)
     : this(actionContext, req, true)
 {
     populator = () => {
         representation = ActionRepresentation.Create(req, actionContext, flags);
         SetHeaders();
     };
 }
Ejemplo n.º 4
0
 public UriMtHelper(HttpRequestMessage req, ActionContextSurface actionContext) : this(req) {
     action      = actionContext.Action;
     nakedObject = actionContext.Target;
     spec        = nakedObject.Specification;
     LinkObjectId oid = OidStrategyHolder.OidStrategy.GetOid(nakedObject);
     cachedId   = oid.InstanceId;
     cachedType = oid.DomainType;
 }
Ejemplo n.º 5
0
        public ActionContextSurface ToActionContextSurface(INakedObjectsSurface surface, INakedObjectsFramework framework)
        {
            var ac = new ActionContextSurface {
                Action            = new NakedObjectActionWrapper(Action, surface, framework, OverloadedUniqueId ?? ""),
                VisibleParameters = VisibleParameters.Select(p => p.ToParameterContextSurface(surface, framework)).ToArray()
            };

            return(ToContextSurface(ac, surface, framework));
        }
        public static InlineActionRepresentation Create(HttpRequestMessage req, ActionContextSurface actionContext, RestControlFlags flags)
        {
            IConsentSurface consent = actionContext.Action.IsUsable(actionContext.Target);

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

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

            return(new InlineActionRepresentation(actionRepresentationStrategy));
        }
Ejemplo n.º 7
0
 public static ActionRepresentation Create(HttpRequestMessage req, ActionContextSurface actionContext, RestControlFlags flags)
 {
     return(new ActionRepresentation(new ActionRepresentationStrategy(req, actionContext, flags)));
 }
 private void SetLinks(HttpRequestMessage req, ActionContextSurface actionContext)
 {
     SetLinks(req, actionContext.ElementSpecification);
 }
        protected ListRepresentation(ObjectContextSurface objectContext, HttpRequestMessage req, RestControlFlags flags, ActionContextSurface actionContext)
            : base(flags)
        {
            INakedObjectSurface list;

            if (flags.PageSize > 0 && objectContext.Target.Count() > flags.PageSize)
            {
                warnings.Add(string.Format("Result contains more than {0} objects only returning the first {0}", flags.PageSize));
                list = objectContext.Target.Page(1, flags.PageSize);
            }
            else
            {
                list = objectContext.Target;
            }

            Value = list.ToEnumerable().Select(no => CreateObjectLink(req, no)).ToArray();

            SetLinks(req, actionContext);
            SetExtensions();
            SetHeader(false);
        }