private AtomicResultObject SerializeOperation(OperationContainer operation)
        {
            ResourceObject resourceObject = null;

            if (operation != null)
            {
                _request.CopyFrom(operation.Request);
                _fieldsToSerialize.ResetCache();
                _evaluatedIncludeCache.Set(null);

                _resourceDefinitionAccessor.OnSerialize(operation.Resource);

                Type resourceType = operation.Resource.GetType();
                IReadOnlyCollection <AttrAttribute>         attributes    = _fieldsToSerialize.GetAttributes(resourceType);
                IReadOnlyCollection <RelationshipAttribute> relationships = _fieldsToSerialize.GetRelationships(resourceType);

                resourceObject = ResourceObjectBuilder.Build(operation.Resource, attributes, relationships);
            }

            if (resourceObject != null)
            {
                resourceObject.Links = _linkBuilder.GetResourceLinks(resourceObject.Type, resourceObject.Id);
            }

            return(new AtomicResultObject
            {
                Data = resourceObject
            });
        }
Beispiel #2
0
        /// <inheritdoc />
        public QueryLayer ComposeFromConstraints(ResourceContext requestResource)
        {
            ArgumentGuard.NotNull(requestResource, nameof(requestResource));

            ExpressionInScope[] constraints = _constraintProviders.SelectMany(provider => provider.GetConstraints()).ToArray();

            QueryLayer topLayer = ComposeTopLayer(constraints, requestResource);

            topLayer.Include = ComposeChildren(topLayer, constraints);

            _evaluatedIncludeCache.Set(topLayer.Include);

            return(topLayer);
        }