本文整理汇总了C#中Microsoft.OData.Core.UriParser.Parsers.BindingState类的典型用法代码示例。如果您正苦于以下问题:C# BindingState类的具体用法?C# BindingState怎么用?C# BindingState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BindingState类属于Microsoft.OData.Core.UriParser.Parsers命名空间,在下文中一共展示了BindingState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BindLambdaToken
/// <summary>
/// Binds a LambdaToken to metadata.
/// </summary>
/// <param name="lambdaToken">Token to bind.</param>
/// <param name="state">Object to hold the state of binding.</param>
/// <returns>A metadata bound any or all node.</returns>
internal LambdaNode BindLambdaToken(LambdaToken lambdaToken, BindingState state)
{
ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");
ExceptionUtils.CheckArgumentNotNull(state, "state");
// Start by binding the parent token
CollectionNode parent = this.BindParentToken(lambdaToken.Parent);
RangeVariable rangeVariable = null;
// Add the lambda variable to the stack
if (lambdaToken.Parameter != null)
{
rangeVariable = NodeFactory.CreateParameterNode(lambdaToken.Parameter, parent);
state.RangeVariables.Push(rangeVariable);
}
// Bind the expression
SingleValueNode expression = this.BindExpressionToken(lambdaToken.Expression);
// Create the node
LambdaNode lambdaNode = NodeFactory.CreateLambdaNode(state, parent, expression, rangeVariable, lambdaToken.Kind);
// Remove the lambda variable as it is now out of scope
if (rangeVariable != null)
{
state.RangeVariables.Pop();
}
return lambdaNode;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:36,代码来源:LambdaBinder.cs
示例2: BinderBase
/// <summary>
/// Constructor for binderbase.
/// </summary>
/// <param name="bindMethod">Method to use for binding the parent token, if needed.</param>
/// <param name="state">State of the metadata binding.</param>
protected BinderBase(MetadataBinder.QueryTokenVisitor bindMethod, BindingState state)
{
ExceptionUtils.CheckArgumentNotNull(bindMethod, "bindMethod");
ExceptionUtils.CheckArgumentNotNull(state, "state");
this.bindMethod = bindMethod;
this.state = state;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:BinderBase.cs
示例3: BindParameterAlias
/// <summary>
/// Bind a parameter alias which is inside another alias value.
/// </summary>
/// <param name="bindingState">The alias name which is inside another alias value.</param>
/// <param name="aliasToken">The cache of alias value nodes</param>
/// <returns>The semantics node tree for alias (the @p1 in "@p1=...", not alias value expression)</returns>
internal ParameterAliasNode BindParameterAlias(BindingState bindingState, FunctionParameterAliasToken aliasToken)
{
ExceptionUtils.CheckArgumentNotNull(bindingState, "bindingState");
ExceptionUtils.CheckArgumentNotNull(aliasToken, "aliasToken");
string alias = aliasToken.Alias;
ParameterAliasValueAccessor aliasValueAccessor = bindingState.Configuration.ParameterAliasValueAccessor;
if (aliasValueAccessor == null)
{
return new ParameterAliasNode(alias, null);
}
// in cache?
SingleValueNode aliasValueNode = null;
if (!aliasValueAccessor.ParameterAliasValueNodesCached.TryGetValue(alias, out aliasValueNode))
{
// has value expression?
string aliasValueExpression = aliasValueAccessor.GetAliasValueExpression(alias);
if (aliasValueExpression == null)
{
aliasValueAccessor.ParameterAliasValueNodesCached[alias] = null;
}
else
{
aliasValueNode = this.ParseAndBindParameterAliasValueExpression(bindingState, aliasValueExpression, aliasToken.ExpectedParameterType);
aliasValueAccessor.ParameterAliasValueNodesCached[alias] = aliasValueNode;
}
}
return new ParameterAliasNode(alias, aliasValueNode.GetEdmTypeReference());
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:37,代码来源:ParameterAliasBinder.cs
示例4: MetadataBinder
/// <summary>
/// Constructs a MetadataBinder with the given <paramref name="initialState"/>.
/// This constructor gets used if you are not calling the top level entry point ParseQuery.
/// This is an at-your-own-risk constructor, since you must provide valid initial state.
/// </summary>
/// <param name="initialState">The initialState to use for binding.</param>
internal MetadataBinder(BindingState initialState)
{
ExceptionUtils.CheckArgumentNotNull(initialState, "initialState");
ExceptionUtils.CheckArgumentNotNull(initialState.Model, "initialState.Model");
this.BindingState = initialState;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:MetadataBinder.cs
示例5: Init
public void Init()
{
this.orderbyBinder = new OrderByBinder(FakeBindMethods.BindMethodReturningASinglePrimitive);
var implicitRangeVariable = new EntityRangeVariable(ExpressionConstants.It, HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
this.bindingState = new BindingState(configuration) { ImplicitRangeVariable = implicitRangeVariable };
this.bindingState.RangeVariables.Push(new BindingState(configuration) { ImplicitRangeVariable = implicitRangeVariable }.ImplicitRangeVariable);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:OrderByBinderTests.cs
示例6: ApplyBinderTests
public ApplyBinderTests()
{
var implicitRangeVariable = new EntityRangeVariable(ExpressionConstants.It,
HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
this._bindingState = new BindingState(_configuration) { ImplicitRangeVariable = implicitRangeVariable };
this._bindingState.RangeVariables.Push(
new BindingState(_configuration) { ImplicitRangeVariable = implicitRangeVariable }.ImplicitRangeVariable);
}
开发者ID:TomDu,项目名称:odata.net,代码行数:8,代码来源:ApplyBinderTests.cs
示例7: PrimitiveCollectionPropertyShouldCreateMatchingNode
public void PrimitiveCollectionPropertyShouldCreateMatchingNode()
{
var state = new BindingState(configuration);
var binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASingleDog, state);
var token = new InnerPathToken("Nicknames", new DummyToken(), null /*namedValues*/);
var result = binder.BindInnerPathSegment(token);
result.ShouldBeCollectionPropertyAccessQueryNode(HardCodedTestModel.GetDogNicknamesProperty());
}
开发者ID:modulexcite,项目名称:odata.net,代码行数:9,代码来源:NonrootSegmentBinderTests.cs
示例8: DeclaredPropertyOnOpenTypeShouldCreateMatchingNode
public void DeclaredPropertyOnOpenTypeShouldCreateMatchingNode()
{
var state = new BindingState(configuration);
var binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASinglePainting, state);
var token = new InnerPathToken("Colors", new DummyToken(), null /*namedValues*/);
var result = binder.BindInnerPathSegment(token);
result.ShouldBeCollectionPropertyAccessQueryNode(HardCodedTestModel.GetPaintingColorsProperty());
}
开发者ID:modulexcite,项目名称:odata.net,代码行数:9,代码来源:NonrootSegmentBinderTests.cs
示例9: OpenPropertyShouldCreateMatchingNode
public void OpenPropertyShouldCreateMatchingNode()
{
const string OpenPropertyName = "Emotions";
var state = new BindingState(configuration);
var binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASinglePainting, state);
var token = new InnerPathToken(OpenPropertyName, new DummyToken(), null /*namedValues*/);
var result = binder.BindInnerPathSegment(token);
result.ShouldBeSingleValueOpenPropertyAccessQueryNode(OpenPropertyName);
}
开发者ID:modulexcite,项目名称:odata.net,代码行数:10,代码来源:NonrootSegmentBinderTests.cs
示例10: CollectionNavigationPropertyShouldCreateMatchingNode
public void CollectionNavigationPropertyShouldCreateMatchingNode()
{
var state = new BindingState(configuration);
var binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASingleDog, state);
var token = new InnerPathToken("MyPeople", new DummyToken(), null /*namedValues*/);
var result = binder.BindInnerPathSegment(token);
result.ShouldBeCollectionNavigationNode(HardCodedTestModel.GetDogMyPeopleNavProp()).
And.NavigationSource.Should().BeSameAs(HardCodedTestModel.GetDogsSet().FindNavigationTarget(HardCodedTestModel.GetDogMyPeopleNavProp()));
}
开发者ID:modulexcite,项目名称:odata.net,代码行数:10,代码来源:NonrootSegmentBinderTests.cs
示例11: CreateLambdaNodeForAnyTokenShouldCreateAnyNode
public void CreateLambdaNodeForAnyTokenShouldCreateAnyNode()
{
BindingState bindingState = new BindingState(configuration);
EntityCollectionNode parent = new EntitySetNode(HardCodedTestModel.GetPeopleSet());
SingleValueNode expression = new ConstantNode(true);
RangeVariable rangeVariable = new EntityRangeVariable("bob", HardCodedTestModel.GetPersonTypeReference(), parent);
var resultNode = NodeFactory.CreateLambdaNode(bindingState, parent, expression, rangeVariable, QueryTokenKind.Any);
var node = resultNode.ShouldBeAnyQueryNode().And;
node.Body.Should().BeSameAs(expression);
node.Source.Should().BeSameAs(parent);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:11,代码来源:NodeFactoryTests.cs
示例12: CreateParentFromImplicitRangeVariable
/// <summary>
/// Constructs parent node from binding state
/// </summary>
/// <param name="state">Current binding state</param>
/// <returns>The parent node.</returns>
internal static SingleValueNode CreateParentFromImplicitRangeVariable(BindingState state)
{
ExceptionUtils.CheckArgumentNotNull(state, "state");
// If the Parent is null, then it must be referring to the implicit $it parameter
if (state.ImplicitRangeVariable == null)
{
throw new ODataException(ODataErrorStrings.MetadataBinder_PropertyAccessWithoutParentParameter);
}
return NodeFactory.CreateRangeVariableReferenceNode(state.ImplicitRangeVariable);
}
开发者ID:TomDu,项目名称:odata.net,代码行数:17,代码来源:EndPathBinder.cs
示例13: MissingPropertyShouldThrow
public void MissingPropertyShouldThrow()
{
const string MissingPropertyName = "ThisPropertyDoesNotExist";
var state = new BindingState(configuration);
var binder = new InnerPathTokenBinder(FakeBindMethods.BindMethodReturningASingleDog, state);
var token = new InnerPathToken(MissingPropertyName, new DummyToken(), null /*namedValues*/);
Action bind = () => binder.BindInnerPathSegment(token);
string expectedMessage =
ODataErrorStrings.MetadataBinder_PropertyNotDeclared(HardCodedTestModel.GetDogType().FullTypeName(), MissingPropertyName);
bind.ShouldThrow<ODataException>(expectedMessage);
}
开发者ID:modulexcite,项目名称:odata.net,代码行数:13,代码来源:NonrootSegmentBinderTests.cs
示例14: BindRangeVariableToken
/// <summary>
/// Binds a parameter token.
/// </summary>
/// <param name="rangeVariableToken">The parameter token to bind.</param>
/// <param name="state">The state of metadata binding.</param>
/// <returns>The bound query node.</returns>
internal static SingleValueNode BindRangeVariableToken(RangeVariableToken rangeVariableToken, BindingState state)
{
ExceptionUtils.CheckArgumentNotNull(rangeVariableToken, "rangeVariableToken");
RangeVariable rangeVariable = state.RangeVariables.SingleOrDefault(p => p.Name == rangeVariableToken.Name);
if (rangeVariable == null)
{
throw new ODataException(ODataErrorStrings.MetadataBinder_ParameterNotInScope(rangeVariableToken.Name));
}
return NodeFactory.CreateRangeVariableReferenceNode(rangeVariable);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:19,代码来源:RangeVariableBinder.cs
示例15: BindOrderBy
/// <summary>
/// Processes the order-by tokens of a entityCollection (if any).
/// </summary>
/// <param name="state">State to use for binding.</param>
/// <param name="orderByTokens">The order-by tokens to bind.</param>
/// <returns>An OrderByClause representing the orderby statements expressed in the tokens.</returns>
internal OrderByClause BindOrderBy(BindingState state, IEnumerable<OrderByToken> orderByTokens)
{
ExceptionUtils.CheckArgumentNotNull(state, "state");
ExceptionUtils.CheckArgumentNotNull(orderByTokens, "orderByTokens");
OrderByClause orderByClause = null;
// Go through the orderby tokens starting from the last one
foreach (OrderByToken orderByToken in orderByTokens.Reverse())
{
orderByClause = this.ProcessSingleOrderBy(state, orderByClause, orderByToken);
}
return orderByClause;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:21,代码来源:OrderByBinder.cs
示例16: ParseAndBindParameterAliasValueExpression
/// <summary>
/// Parse expression into syntaxs token tree, and bind it into semantics node tree.
/// </summary>
/// <param name="bindingState">The BindingState.</param>
/// <param name="aliasValueExpression">The alias value's expression text.</param>
/// <param name="parameterType">The edm type of the parameter.</param>
/// <returns>The semantcs node of the expression text.</returns>
private SingleValueNode ParseAndBindParameterAliasValueExpression(BindingState bindingState, string aliasValueExpression, IEdmTypeReference parameterType)
{
// Get the syntactic representation of the filter expression
// TODO: change Settings.FilterLimit to ParameterAliasValueLimit
UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(bindingState.Configuration.Settings.FilterLimit);
QueryToken aliasValueToken = expressionParser.ParseExpressionText(aliasValueExpression);
// Special logic to handle parameter alias token.
aliasValueToken = ParseComplexOrCollectionAlias(aliasValueToken, parameterType, bindingState.Model);
// Get the semantic node, and check for SingleValueNode
QueryNode aliasValueNode = this.bindMethod(aliasValueToken);
SingleValueNode result = aliasValueNode as SingleValueNode;
if (result == null)
{
// TODO: add string resource
throw new ODataException("ODataErrorStrings.MetadataBinder_ParameterAliasValueExpressionNotSingleValue");
}
return result;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:28,代码来源:ParameterAliasBinder.cs
示例17: ProcessSingleOrderBy
/// <summary>
/// Processes the specified order-by token.
/// </summary>
/// <param name="state">State to use for binding.</param>
/// <param name="thenBy"> The next OrderBy node, or null if there is no orderby after this.</param>
/// <param name="orderByToken">The order-by token to bind.</param>
/// <returns>Returns the combined entityCollection including the ordering.</returns>
private OrderByClause ProcessSingleOrderBy(BindingState state, OrderByClause thenBy, OrderByToken orderByToken)
{
ExceptionUtils.CheckArgumentNotNull(state, "state");
ExceptionUtils.CheckArgumentNotNull(orderByToken, "orderByToken");
QueryNode expressionNode = this.bindMethod(orderByToken.Expression);
// The order-by expressions need to be primitive / enumeration types
SingleValueNode expressionResultNode = expressionNode as SingleValueNode;
if (expressionResultNode == null ||
(expressionResultNode.TypeReference != null && !expressionResultNode.TypeReference.IsODataPrimitiveTypeKind() && !expressionResultNode.TypeReference.IsODataEnumTypeKind() && !expressionResultNode.TypeReference.IsODataTypeDefinitionTypeKind()))
{
throw new ODataException(ODataErrorStrings.MetadataBinder_OrderByExpressionNotSingleValue);
}
OrderByClause orderByNode = new OrderByClause(
thenBy,
expressionResultNode,
orderByToken.Direction,
state.ImplicitRangeVariable);
return orderByNode;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:OrderByBinder.cs
示例18: ParseOrderByImplementation
/// <summary>
/// Parses an <paramref name="orderBy "/> clause on the given <paramref name="elementType"/>, binding
/// the text into semantic nodes using the provided model.
/// </summary>
/// <param name="orderBy">String representation of the orderby expression.</param>
/// <param name="configuration">The configuration used for binding.</param>
/// <param name="elementType">Type that the orderby clause refers to.</param>
/// <param name="navigationSource">NavigationSource that the elements are from.</param>
/// <returns>An <see cref="OrderByClause"/> representing the metadata bound orderby expression.</returns>
private OrderByClause ParseOrderByImplementation(string orderBy, ODataUriParserConfiguration configuration, IEdmType elementType, IEdmNavigationSource navigationSource)
{
ExceptionUtils.CheckArgumentNotNull(configuration, "configuration");
ExceptionUtils.CheckArgumentNotNull(configuration.Model, "model");
ExceptionUtils.CheckArgumentNotNull(elementType, "elementType");
ExceptionUtils.CheckArgumentNotNull(orderBy, "orderBy");
// Get the syntactic representation of the orderby expression
UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.OrderByLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier);
var orderByQueryTokens = expressionParser.ParseOrderBy(orderBy);
// Bind it to metadata
BindingState state = new BindingState(configuration);
state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(elementType.ToTypeReference(), navigationSource);
state.RangeVariables.Push(state.ImplicitRangeVariable);
if (applyClause != null)
{
state.AggregatedPropertyNames = applyClause.GetLastAggregatedPropertyNames();
}
MetadataBinder binder = new MetadataBinder(state);
OrderByBinder orderByBinder = new OrderByBinder(binder.Bind);
OrderByClause orderByClause = orderByBinder.BindOrderBy(state, orderByQueryTokens);
return orderByClause;
}
开发者ID:TomDu,项目名称:odata.net,代码行数:35,代码来源:ODataQueryOptionParser.cs
示例19: ParseApplyImplementation
/// <summary>
/// Parses an <paramref name="apply"/> clause on the given <paramref name="elementType"/>, binding
/// the text into a metadata-bound or dynamic properties to be applied using the provided model.
/// </summary>
/// <param name="apply">String representation of the apply expression.</param>
/// <param name="configuration">The configuration used for binding.</param>
/// <param name="elementType">Type that the apply clause refers to.</param>
/// <param name="navigationSource">Navigation source that the elements being filtered are from.</param>
/// <returns>A <see cref="ApplyClause"/> representing the metadata bound apply expression.</returns>
private static ApplyClause ParseApplyImplementation(string apply, ODataUriParserConfiguration configuration, IEdmType elementType, IEdmNavigationSource navigationSource)
{
ExceptionUtils.CheckArgumentNotNull(configuration, "configuration");
ExceptionUtils.CheckArgumentNotNull(elementType, "elementType");
ExceptionUtils.CheckArgumentNotNull(apply, "apply");
// Get the syntactic representation of the apply expression
UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier);
var applyTokens = expressionParser.ParseApply(apply);
// Bind it to metadata
BindingState state = new BindingState(configuration);
state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(elementType.ToTypeReference(), navigationSource);
state.RangeVariables.Push(state.ImplicitRangeVariable);
MetadataBinder binder = new MetadataBinder(state);
ApplyBinder applyBinder = new ApplyBinder(binder.Bind, state);
ApplyClause boundNode = applyBinder.BindApply(applyTokens);
return boundNode;
}
开发者ID:TomDu,项目名称:odata.net,代码行数:29,代码来源:ODataQueryOptionParser.cs
示例20: ParseFilterImplementation
/// <summary>
/// Parses a <paramref name="filter"/> clause on the given <paramref name="elementType"/>, binding
/// the text into semantic nodes using the provided model.
/// </summary>
/// <param name="filter">String representation of the filter expression.</param>
/// <param name="configuration">The configuration used for binding.</param>
/// <param name="elementType">Type that the filter clause refers to.</param>
/// <param name="navigationSource">Navigation source that the elements being filtered are from.</param>
/// <returns>A <see cref="FilterClause"/> representing the metadata bound filter expression.</returns>
private FilterClause ParseFilterImplementation(string filter, ODataUriParserConfiguration configuration, IEdmType elementType, IEdmNavigationSource navigationSource)
{
ExceptionUtils.CheckArgumentNotNull(configuration, "configuration");
ExceptionUtils.CheckArgumentNotNull(elementType, "elementType");
ExceptionUtils.CheckArgumentNotNull(filter, "filter");
// Get the syntactic representation of the filter expression
UriQueryExpressionParser expressionParser = new UriQueryExpressionParser(configuration.Settings.FilterLimit, configuration.EnableCaseInsensitiveUriFunctionIdentifier);
QueryToken filterToken = expressionParser.ParseFilter(filter);
// Bind it to metadata
BindingState state = new BindingState(configuration);
state.ImplicitRangeVariable = NodeFactory.CreateImplicitRangeVariable(elementType.ToTypeReference(), navigationSource);
state.RangeVariables.Push(state.ImplicitRangeVariable);
if (applyClause != null)
{
state.AggregatedPropertyNames = applyClause.GetLastAggregatedPropertyNames();
}
MetadataBinder binder = new MetadataBinder(state);
FilterBinder filterBinder = new FilterBinder(binder.Bind, state);
FilterClause boundNode = filterBinder.BindFilter(filterToken);
return boundNode;
}
开发者ID:TomDu,项目名称:odata.net,代码行数:34,代码来源:ODataQueryOptionParser.cs
注:本文中的Microsoft.OData.Core.UriParser.Parsers.BindingState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论