/// <summary> /// Set the UrlConventions in DefaultODataPathHandler. /// </summary> /// <param name="configuration">The server configuration.</param> /// <param name="conventions">The <see cref="ODataUrlConventions"/></param> public static void SetUrlConventions(this HttpConfiguration configuration, ODataUrlConventions conventions) { if (configuration == null) { throw Error.ArgumentNull("configuration"); } ODataUriResolverSetttings settings = configuration.GetResolverSettings(); settings.UrlConventions = conventions; }
public static Uri UriBuilder(Uri queryUri, ODataUrlConventions urlConventions, ODataUriParserSettings settings) { ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, queryUri); odataUriParser.UrlConventions = urlConventions; ODataUri odataUri = odataUriParser.ParseUri(); ODataUriBuilder odataUriBuilder = new ODataUriBuilder(urlConventions, odataUri); return(odataUriBuilder.BuildUri()); }
/// <summary> /// Get the string representation of <see cref="ODataPath"/>. /// mainly translate Query Url path. /// </summary> /// <param name="path">Path to perform the computation on.</param> /// <param name="urlConventions">Mark whether key is segment</param> /// <returns>The string representation of the Query Url path.</returns> public static string ToResourcePathString(this ODataPath path, ODataUrlConventions urlConventions) { return(string.Concat(path.WalkWith(new PathSegmentToResourcePathTranslator(urlConventions.UrlConvention)).ToArray()).TrimStart('/')); }
/// <summary> /// Constructor of the ODataUriBuilder /// </summary> /// <param name="urlConventions">ODataUriBuilder constructor</param> /// <param name="odataUri">semantic tree of the uri</param> public ODataUriBuilder(ODataUrlConventions urlConventions, ODataUri odataUri) { this.urlConventions = urlConventions; this.odataUri = odataUri; }
/// <summary> /// Get the string representation of <see cref="ODataPath"/>. /// mainly translate Query Url path. /// </summary> /// <param name="path">Path to perform the computation on.</param> /// <param name="urlConventions">Mark whether key is segment</param> /// <returns>The string representation of the Query Url path.</returns> public static string ToResourcePathString(this ODataPath path, ODataUrlConventions urlConventions) { return string.Concat(path.WalkWith(new PathSegmentToResourcePathTranslator(urlConventions.UrlConvention)).ToArray()).TrimStart('/'); }