/// <summary> /// Initializes a new instance of the <see cref="ODataSerializerContext"/> class. /// </summary> /// <param name="entity">The entity whose navigation property is being expanded.</param> /// <param name="selectExpandClause">The <see cref="SelectExpandClause"/> for the navigation property being expanded.</param> /// <param name="navigationProperty">The navigation property being expanded.</param> /// <remarks>This constructor is used to construct the serializer context for writing expanded properties.</remarks> public ODataSerializerContext(EntityInstanceContext entity, SelectExpandClause selectExpandClause, IEdmNavigationProperty navigationProperty) { if (entity == null) { throw Error.ArgumentNull("entity"); } if (navigationProperty == null) { throw Error.ArgumentNull("navigationProperty"); } ODataSerializerContext context = entity.SerializerContext; Request = context.Request; RequestContext = context.RequestContext; Url = context.Url; NavigationSource = context.NavigationSource; Model = context.Model; Path = context.Path; RootElementName = context.RootElementName; SkipExpensiveAvailabilityChecks = context.SkipExpensiveAvailabilityChecks; MetadataLevel = context.MetadataLevel; Items = context.Items; ExpandedEntity = entity; SelectExpandClause = selectExpandClause; NavigationProperty = navigationProperty; NavigationSource = context.NavigationSource.FindNavigationTarget(navigationProperty); }
/// <summary> /// Initializes a new instance of the <see cref="ODataSerializerContext"/> class. /// </summary> /// <param name="entity">The entity whose navigation property is being expanded.</param> /// <param name="selectExpandClause">The <see cref="SelectExpandClause"/> for the navigation property being expanded.</param> /// <param name="navigationProperty">The navigation property being expanded.</param> /// <remarks>This constructor is used to construct the serializer context for writing expanded properties.</remarks> public ODataSerializerContext(EntityInstanceContext entity, SelectExpandClause selectExpandClause, IEdmNavigationProperty navigationProperty) { if (entity == null) { throw Error.ArgumentNull("entity"); } if (navigationProperty == null) { throw Error.ArgumentNull("navigationProperty"); } ODataSerializerContext context = entity.SerializerContext; Request = context.Request; RequestContext = context.RequestContext; Url = context.Url; EntitySet = context.EntitySet; Model = context.Model; Path = context.Path; RootElementName = context.RootElementName; SkipExpensiveAvailabilityChecks = context.SkipExpensiveAvailabilityChecks; MetadataLevel = context.MetadataLevel; Items = context.Items; ExpandedEntity = entity; SelectExpandClause = selectExpandClause; NavigationProperty = navigationProperty; // Cast will fail in singleton / containment cases. EntitySet = context.EntitySet.FindNavigationTarget(navigationProperty) as IEdmEntitySet; }