예제 #1
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;
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
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();
 }
예제 #5
0
 private void SetLinks(HttpRequestMessage req, ActionContextSurface actionContext) {
     SetLinks(req, actionContext.Specification.ElementType);
 }
예제 #6
0
 public static ActionRepresentation Create(HttpRequestMessage req, ActionContextSurface actionContext, RestControlFlags flags) {
     return new ActionRepresentation(new ActionRepresentationStrategy(req, actionContext, flags));
 }
예제 #7
0
 public RestSnapshot(ActionContextSurface actionContext, HttpRequestMessage req, RestControlFlags flags)
     : this(actionContext, req, true) {
     populator = () => {
         representation = ActionRepresentation.Create(req, actionContext, flags);
         SetHeaders();
     };
 }