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