/// <summary> /// Creates a context URI parser and parses the context URI read from the payload. /// </summary> /// <param name="model">The model to use when resolving the target of the URI.</param> /// <param name="contextUriFromPayload">The string value of the odata.metadata annotation read from the payload.</param> /// <param name="payloadKind">The payload kind we expect the context URI to conform to.</param> /// <param name="readerBehavior">Reader behavior if the caller is a reader, null if no reader behavior is available.</param> /// <param name="needParseFragment">Whether the fragment after $metadata should be parsed, if set to false, only MetadataDocumentUri is parsed.</param> /// <returns>The result from parsing the context URI.</returns> internal static ODataJsonLightContextUriParseResult Parse( IEdmModel model, string contextUriFromPayload, ODataPayloadKind payloadKind, ODataReaderBehavior readerBehavior, bool needParseFragment) { if (contextUriFromPayload == null) { throw new ODataException(ODataErrorStrings.ODataJsonLightContextUriParser_NullMetadataDocumentUri); } // Create an absolute URI from the payload string // TODO: Support relative context uri and resolving other relative uris Uri contextUri; if (!Uri.TryCreate(contextUriFromPayload, UriKind.Absolute, out contextUri)) { throw new ODataException(ODataErrorStrings.ODataJsonLightContextUriParser_TopLevelContextUrlShouldBeAbsolute(contextUriFromPayload)); } ODataJsonLightContextUriParser parser = new ODataJsonLightContextUriParser(model, contextUri); parser.TokenizeContextUri(); if (needParseFragment) { parser.ParseContextUri(payloadKind, readerBehavior); } return(parser.parseResult); }
/// <summary> /// Creates a context URI parser and parses the context URI read from the payload. /// </summary> /// <param name="model">The model to use when resolving the target of the URI.</param> /// <param name="contextUriFromPayload">The string value of the odata.metadata annotation read from the payload.</param> /// <param name="payloadKind">The payload kind we expect the context URI to conform to.</param> /// <param name="version">The OData version to use for determining the set of built-in functions available.</param> /// <param name="readerBehavior">Reader behavior if the caller is a reader, null if no reader behavior is available.</param> /// <param name="needParseFragment">Whether the fragment after $metadata should be parsed, if set to false, only MetadataDocumentUri is parsed.</param> /// <returns>The result from parsing the context URI.</returns> internal static ODataJsonLightContextUriParseResult Parse( IEdmModel model, string contextUriFromPayload, ODataPayloadKind payloadKind, ODataVersion version, ODataReaderBehavior readerBehavior, bool needParseFragment) { if (contextUriFromPayload == null) { throw new ODataException(ODataErrorStrings.ODataJsonLightContextUriParser_NullMetadataDocumentUri); } // Create an absolute URI from the payload string Uri contextUri = new Uri(contextUriFromPayload, UriKind.Absolute); ODataJsonLightContextUriParser parser = new ODataJsonLightContextUriParser(model, contextUri); parser.TokenizeContextUri(); if (needParseFragment) { parser.ParseContextUri(payloadKind, readerBehavior, version); } return(parser.parseResult); }
/// <summary> /// Creates a context URI parser and parses the context URI read from the payload. /// </summary> /// <param name="model">The model to use when resolving the target of the URI.</param> /// <param name="contextUriFromPayload">The string value of the odata.metadata annotation read from the payload.</param> /// <param name="payloadKind">The payload kind we expect the context URI to conform to.</param> /// <param name="readerBehavior">Reader behavior if the caller is a reader, null if no reader behavior is available.</param> /// <param name="needParseFragment">Whether the fragment after $metadata should be parsed, if set to false, only MetadataDocumentUri is parsed.</param> /// <returns>The result from parsing the context URI.</returns> internal static ODataJsonLightContextUriParseResult Parse( IEdmModel model, string contextUriFromPayload, ODataPayloadKind payloadKind, ODataReaderBehavior readerBehavior, bool needParseFragment) { if (contextUriFromPayload == null) { throw new ODataException(ODataErrorStrings.ODataJsonLightContextUriParser_NullMetadataDocumentUri); } // Create an absolute URI from the payload string // TODO: Support relative context uri and resolving other relative uris Uri contextUri; if (!Uri.TryCreate(contextUriFromPayload, UriKind.Absolute, out contextUri)) { throw new ODataException(ODataErrorStrings.ODataJsonLightContextUriParser_TopLevelContextUrlShouldBeAbsolute(contextUriFromPayload)); } ODataJsonLightContextUriParser parser = new ODataJsonLightContextUriParser(model, contextUri); parser.TokenizeContextUri(); if (needParseFragment) { parser.ParseContextUri(payloadKind, readerBehavior); } return parser.parseResult; }