private static void Patch(TypedDelta delta, object model) { var type = typeof(Delta <>).MakeGenericType(delta.EntityType); var method = type.GetMethod("Patch"); method.Invoke(delta, new object[] { model }); }
/// <summary> /// Returns the URI for NextPageLink /// </summary> /// <param name="baseUri">BaseUri for nextlink. It should be request URI for top level resource and navigation link for nested resource.</param> /// <param name="pageSize">Maximum number of records in the set of partial results for a resource.</param> /// <param name="instance">Instance based on which SkipToken value will be generated.</param> /// <param name="context">Serializer context</param> /// <returns>Returns the URI for NextPageLink. If a null object is passed for the instance, resorts to the default paging mechanism of using $skip and $top.</returns> public override Uri GenerateNextPageLink(Uri baseUri, int pageSize, Object instance, ODataSerializerContext context) { if (context == null) { return(null); } if (pageSize <= 0) { return(null); } Func <object, string> skipTokenGenerator = null; IList <OrderByNode> orderByNodes = null; ExpandedReferenceSelectItem expandedItem = context.CurrentExpandedSelectItem; IEdmModel model = context.Model; DefaultQuerySettings settings = context.QueryContext.DefaultQuerySettings; if (settings.EnableSkipToken) { if (expandedItem != null) { // Handle Delta resource; currently not value based. if (TypedDelta.IsDeltaOfT(context.ExpandedResource.GetType())) { return(GetNextPageHelper.GetNextPageLink(baseUri, pageSize)); } if (expandedItem.OrderByOption != null) { orderByNodes = OrderByNode.CreateCollection(expandedItem.OrderByOption); } skipTokenGenerator = (obj) => { return(GenerateSkipTokenValue(obj, model, orderByNodes)); }; return(GetNextPageHelper.GetNextPageLink(baseUri, pageSize, instance, skipTokenGenerator)); } if (context.QueryOptions != null && context.QueryOptions.OrderBy != null) { orderByNodes = context.QueryOptions.OrderBy.OrderByNodes; } skipTokenGenerator = (obj) => { return(GenerateSkipTokenValue(obj, model, orderByNodes)); }; } return(GetNextPageHelper.GetNextPageLink(baseUri, pageSize, instance, skipTokenGenerator)); }
public TypedGraphDelta(Type type, JObject json) { if (type == null) { throw new ArgumentNullException("type"); } if (json == null) { throw new ArgumentNullException("json"); } _root = TypedGraphDelta.ReadRoot(type, json); _children = TypedGraphDelta.ReadChildren(type, json); }