本文整理汇总了C#中Microsoft.OData.Core.UriParser.ODataUriParser类的典型用法代码示例。如果您正苦于以下问题:C# ODataUriParser类的具体用法?C# ODataUriParser怎么用?C# ODataUriParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataUriParser类属于Microsoft.OData.Core.UriParser命名空间,在下文中一共展示了ODataUriParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseOrderby
public void ParseOrderby()
{
ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://www.odata.com/OData"), new Uri("http://www.odata.com/OData/People?$orderby=Name asc"));
ODataUri parsedUri = parser.ParseUri();
parsedUri.OrderBy.Expression.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPersonNameProp());
parsedUri.OrderBy.Direction.Should().Be(OrderByDirection.Ascending);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:FullUriFunctionalTests.cs
示例2: RouteAsync
public async Task RouteAsync(RouteContext context)
{
var request = context.HttpContext.Request;
Uri uri;
PathString remaining;
if (!request.Path.StartsWithSegments(PathString.FromUriComponent("/" + _routePrefix), out remaining))
{
// Fallback to other routes.
return;
}
uri = new Uri(remaining.ToString(), UriKind.Relative);
context.HttpContext.ODataProperties().Model = _model;
var parser = new ODataUriParser(_model, uri);
var path = parser.ParsePath();
context.HttpContext.ODataProperties().NewPath = path;
context.HttpContext.ODataProperties().Path =
context.HttpContext.ODataPathHandler().Parse(_model, "http://service-root/", remaining.ToString());
context.HttpContext.ODataProperties().IsValidODataRequest = true;
await m.RouteAsync(context);
context.IsHandled = true;
}
开发者ID:emreolgun,项目名称:WebApi,代码行数:25,代码来源:ODataRoute.cs
示例3: BuildPath_AliasInFunctionImport
public void BuildPath_AliasInFunctionImport()
{
Uri fullUri = new Uri("http://gobbledygook/GetPet4([email protected])[email protected]=1.01M");
ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri);
SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings);
odataUriParser.UrlConventions = ODataUrlConventions.Default;
ODataUri odataUri = odataUriParser.ParseUri();
IDictionary<string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes;
odataUri.Path.LastSegment.ShouldBeOperationImportSegment(HardCodedTestModel.GetFunctionImportForGetPet4()).And.Parameters.First().ShouldHaveParameterAliasNode("id", "@p1", EdmCoreModel.Instance.GetDecimal(false));
aliasNodes["@p1"].ShouldBeConstantQueryNode(1.01M);
ODataUriBuilder odataUriBuilder = new ODataUriBuilder(ODataUrlConventions.Default, odataUri);
Uri actualUri = odataUriBuilder.BuildUri();
Assert.AreEqual(fullUri, actualUri);
ODataUriBuilder uriBuilderWithKeyAsSegment = new ODataUriBuilder(ODataUrlConventions.KeyAsSegment, odataUri);
actualUri = uriBuilderWithKeyAsSegment.BuildUri();
Assert.AreEqual(fullUri, actualUri);
ODataUriBuilder uriBuilderWithODataSimplified = new ODataUriBuilder(ODataUrlConventions.ODataSimplified, odataUri);
actualUri = uriBuilderWithODataSimplified.BuildUri();
Assert.AreEqual(fullUri, actualUri);
}
开发者ID:modulexcite,项目名称:odata.net,代码行数:25,代码来源:UrlBuilderWithParameterAliasTests.cs
示例4: PathNavigation
public void PathNavigation()
{
ODataUriParser parser = new ODataUriParser(model, new Uri("http://www.potato.com/"), new Uri("http://www.potato.com/Customers(5)/Orders"));
var result = parser.ParsePath();
ApprovalVerify(QueryNodeToStringVisitor.ToString(result));
this.TestExtensions("CustoMERS(5)/OrDErs");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:PathTests.cs
示例5: PathEntity
public void PathEntity()
{
ODataUriParser parser = new ODataUriParser(model, new Uri("http://www.potato.com/"), new Uri("http://www.potato.com/Orders(2)"));
var result = parser.ParsePath();
ApprovalVerify(QueryNodeToStringVisitor.ToString(result));
this.TestExtensions("OrDERS(2)");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:PathTests.cs
示例6: GetContextUrlPathString
private string GetContextUrlPathString(Uri queryUri)
{
ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, queryUri);
odataUriParser.UrlConventions = ODataUrlConventions.Default;
ODataUri odataUri = odataUriParser.ParseUri();
ODataPath odataPath = odataUri.Path;
return odataPath.ToContextUrlPathString();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:ContextUrlPathStringTests.cs
示例7: ParseFilter
public void ParseFilter()
{
ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://www.odata.com/OData"), new Uri("http://www.odata.com/OData/People?$filter=Name eq 'Bob'"));
ODataUri parsedUri = parser.ParseUri();
var equalOperator = parsedUri.Filter.Expression.ShouldBeBinaryOperatorNode(BinaryOperatorKind.Equal).And;
equalOperator.Left.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPersonNameProp());
equalOperator.Right.ShouldBeConstantQueryNode("Bob");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:FullUriFunctionalTests.cs
示例8: PathComplex
public void PathComplex()
{
ODataUriParser parser = new ODataUriParser(model, new Uri("http://www.potato.com/"), new Uri("http://www.potato.com/Customers(-32)/HomeAddress"));
var result = parser.ParsePath();
ApprovalVerify(QueryNodeToStringVisitor.ToString(result));
this.TestExtensions("CustomErs(-32)/HOMEAddress");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:PathTests.cs
示例9: PathBatch
public void PathBatch()
{
ODataUriParser parser = new ODataUriParser(model, new Uri("http://www.potato.com/"), new Uri("http://www.potato.com/$batch"));
var result = parser.ParsePath();
ApprovalVerify(QueryNodeToStringVisitor.ToString(result));
this.TestExtensions("$BATch");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:PathTests.cs
示例10: ODataUriBuilderWithEntitySet
public void ODataUriBuilderWithEntitySet()
{
Uri fullUri = new Uri("http://www.example.com/People?$filter=MyDog%2FColor%20eq%20%27Brown%27&$select=ID&$expand=MyDog&$orderby=ID&$top=1&$skip=2&$count=true&$search=FA");
ODataUriParser odataUriParser = new ODataUriParser(this.GetModel(), serviceRoot, fullUri);
odataUriParser.UrlConventions = ODataUrlConventions.Default;
SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings);
ODataUri odataUri = odataUriParser.ParseUri();
//verify path
EntitySetSegment entitySet = (EntitySetSegment)odataUri.Path.FirstSegment;
Assert.AreEqual(entitySet.EntitySet.Name, "People");
Assert.AreEqual(odataUri.Path.Count, 1);
//verify $filter
BinaryOperatorNode binaryOperator = (BinaryOperatorNode)odataUri.Filter.Expression;
SingleValuePropertyAccessNode singleValueProperty = (SingleValuePropertyAccessNode)binaryOperator.Left;
SingleNavigationNode singleNavigation = (SingleNavigationNode)singleValueProperty.Source;
ConstantNode constantNode = (ConstantNode)binaryOperator.Right;
Assert.AreEqual(binaryOperator.OperatorKind, BinaryOperatorKind.Equal);
Assert.AreEqual(singleValueProperty.Property.Name, "Color");
Assert.AreEqual(singleNavigation.NavigationProperty.Name, "MyDog");
Assert.AreEqual(constantNode.LiteralText, "'Brown'");
//verify $select and $expand
IEnumerable<SelectItem> selectItems = odataUri.SelectAndExpand.SelectedItems;
foreach (ExpandedNavigationSelectItem selectItem in selectItems)
{
NavigationPropertySegment navigationProperty = (NavigationPropertySegment)selectItem.PathToNavigationProperty.FirstSegment;
Assert.AreEqual(navigationProperty.NavigationProperty.Name, "MyDog");
break;
}
//verify $orderby
SingleValuePropertyAccessNode orderby = (SingleValuePropertyAccessNode)odataUri.OrderBy.Expression;
Assert.AreEqual(orderby.Property.Name, "ID");
//verify $top
Assert.AreEqual(odataUri.Top, 1);
//verify $skip
Assert.AreEqual(odataUri.Skip, 2);
//verify $count
Assert.AreEqual(odataUri.QueryCount, true);
//verify $search
SearchTermNode searchTermNode = (SearchTermNode)odataUri.Search.Expression;
Assert.AreEqual(searchTermNode.Text, "FA");
ODataUriBuilder odataUriBuilder = new ODataUriBuilder(ODataUrlConventions.Default, odataUri);
Uri actualUri = odataUriBuilder.BuildUri();
Assert.AreEqual(new Uri("http://www.example.com/People?$filter=MyDog%2FColor%20eq%20%27Brown%27&$select=ID%2CMyDog&$expand=MyDog&$orderby=ID&$top=1&$skip=2&$count=true&$search=FA"), actualUri);
ODataUriBuilder uriBuilderWithKeyAsSegment = new ODataUriBuilder(ODataUrlConventions.KeyAsSegment, odataUri);
actualUri = uriBuilderWithKeyAsSegment.BuildUri();
Assert.AreEqual(new Uri("http://www.example.com/People?$filter=MyDog%2FColor%20eq%20%27Brown%27&$select=ID%2CMyDog&$expand=MyDog&$orderby=ID&$top=1&$skip=2&$count=true&$search=FA"), actualUri);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:58,代码来源:UriBuilderTests.cs
示例11: ParsePathWithValue
public void ParsePathWithValue()
{
ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://www.odata.com/OData"), new Uri("http://www.odata.com/OData/People(1)/$value"));
ODataUri parsedUri = parser.ParseUri();
List<ODataPathSegment> path = parsedUri.Path.ToList();
path[0].ShouldBeEntitySetSegment(HardCodedTestModel.GetPeopleSet());
path[1].ShouldBeKeySegment(new KeyValuePair<string, object>("ID", 1));
path[2].ShouldBeValueSegment();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:9,代码来源:FullUriFunctionalTests.cs
示例12: ParsePathWithLinks
public void ParsePathWithLinks()
{
ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://www.odata.com/OData"), new Uri("http://www.odata.com/OData/People(1)/MyDog/$ref"));
ODataUri parsedUri = parser.ParseUri();
List<ODataPathSegment> path = parsedUri.Path.ToList();
path[0].ShouldBeEntitySetSegment(HardCodedTestModel.GetPeopleSet());
path[1].ShouldBeKeySegment(new KeyValuePair<string, object>("ID", 1));
path[2].ShouldBeNavigationPropertyLinkSegment(HardCodedTestModel.GetPersonMyDogNavProp());
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:9,代码来源:FullUriFunctionalTests.cs
示例13: UriBuilder
public static Uri UriBuilder(Uri queryUri, ODataUrlConventions urlConventions, ODataUriParserSettings settings)
{
ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, queryUri);
SetODataUriParserSettingsTo(settings, odataUriParser.Settings);
odataUriParser.UrlConventions = urlConventions;
ODataUri odataUri = odataUriParser.ParseUri();
ODataUriBuilder odataUriBuilder = new ODataUriBuilder(urlConventions, odataUri);
return odataUriBuilder.BuildUri();
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:10,代码来源:UriBuilderTestBase.cs
示例14: KeyAfterFunction
private static void KeyAfterFunction()
{
Console.WriteLine("TestKeyAfterFunction");
var parser = new ODataUriParser(
extModel.Model,
ServiceRoot,
new Uri("http://demo/odata.svc/People(2)/TestNS.GetFriends(2)"));
var path=parser.ParsePath();
Console.WriteLine(path.ToLogString());
}
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:11,代码来源:Program.cs
示例15: KeyContainingSpecialChar
private static void KeyContainingSpecialChar()
{
Console.WriteLine("KeyContainingSpecialChar");
var parser = new ODataUriParser(
extModel.Model,
ServiceRoot,
new Uri("http://demo/odata.svc/Resources('w%23j')"));
var path = parser.ParsePath();
Console.WriteLine(path.ToLogString());
}
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:11,代码来源:Program.cs
示例16: FilterOnOpenProperty
private static void FilterOnOpenProperty()
{
Console.WriteLine("FilterOnOpenProperty");
var parser = new ODataUriParser(
extModel.Model,
ServiceRoot,
new Uri("http://demo/odata.svc/Resources?$filter=Name eq 'w'"));
var filter = parser.ParseFilter();
Console.WriteLine(filter.Expression.ToLogString());
}
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:11,代码来源:Program.cs
示例17: ParseSelectExpand
public void ParseSelectExpand()
{
ODataUriParser parser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://www.odata.com/OData"), new Uri("http://www.odata.com/OData/Dogs?$select=Color, MyPeople&$expand=MyPeople"));
ODataUri parsedUri = parser.ParseUri();
parsedUri.SelectAndExpand.SelectedItems.First().ShouldBePathSelectionItem(new ODataPath(new PropertySegment(HardCodedTestModel.GetDogColorProp())));
var myPeopleExpand = parsedUri.SelectAndExpand.SelectedItems.Last().ShouldBeSelectedItemOfType<ExpandedNavigationSelectItem>().And;
myPeopleExpand.PathToNavigationProperty.Single().ShouldBeNavigationPropertySegment(HardCodedTestModel.GetDogMyPeopleNavProp());
var myPeopleSelectExpand = myPeopleExpand.SelectAndExpand;
myPeopleSelectExpand.AllSelected.Should().BeTrue();
myPeopleSelectExpand.SelectedItems.Should().BeEmpty();
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:11,代码来源:FullUriFunctionalTests.cs
示例18: ParseUri
/// <summary>
/// Parses the specified URI and wraps the results in a QueryContext.
/// </summary>
/// <param name="requestUri">The URI to parse.</param>
/// <param name="model">The data store model.</param>
/// <returns>The parsed URI wrapped in a QueryContext.</returns>
public static QueryContext ParseUri(Uri requestUri, IEdmModel model)
{
var requestUriParts = requestUri.OriginalString.Split('?');
var queryPath = requestUriParts.First();
if (requestUriParts.Count() > 1)
{
throw new NotSupportedException("Query option is not supported by the service yet.");
}
ODataUriParser uriParser = new ODataUriParser(model, ServiceConstants.ServiceBaseUri, new Uri(queryPath, UriKind.Absolute));
return new QueryContext { QueryPath = uriParser.ParsePath() };
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:18,代码来源:QueryContext.cs
示例19: PathBaseSingletonWithKeyShouldFail
public void PathBaseSingletonWithKeyShouldFail()
{
ODataUriParser parser = new ODataUriParser(model, new Uri("http://www.potato.com/"), new Uri("http://www.potato.com/SpecialOrder(1)"));
try
{
parser.ParsePath();
}
catch (ODataException e)
{
var expected = ODataExpectedExceptions.ODataException("RequestUriProcessor_SyntaxError");
expected.ExpectedMessage.Verifier.VerifyMatch("RequestUriProcessor_SyntaxError", e.Message);
}
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:SingletonPathTest.cs
示例20: ParseKeyTemplateWithTemplateParserWithWithWhitespaceOutsideofTempateExpressionTest
public void ParseKeyTemplateWithTemplateParserWithWithWhitespaceOutsideofTempateExpressionTest()
{
var uriParser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("People( {1} )", UriKind.Relative))
{
EnableUriTemplateParsing = true
};
var path = uriParser.ParsePath();
var keySegment = path.LastSegment.As<KeySegment>();
KeyValuePair<string, object> keypair = keySegment.Keys.Single();
keypair.Key.Should().Be("ID");
keypair.Value.As<UriTemplateExpression>().ShouldBeEquivalentTo(new UriTemplateExpression { LiteralText = "{1}", ExpectedType = keySegment.EdmType.As<IEdmEntityType>().DeclaredKey.Single().Type });
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:UriTemplateParserTests.cs
注:本文中的Microsoft.OData.Core.UriParser.ODataUriParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论