本文整理汇总了C#中QueryNode类的典型用法代码示例。如果您正苦于以下问题:C# QueryNode类的具体用法?C# QueryNode怎么用?C# QueryNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryNode类属于命名空间,在下文中一共展示了QueryNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAndVerifyStatusCode
public static void GetAndVerifyStatusCode(Workspace w, QueryNode query, HttpStatusCode expectedStatusCode)
{
AstoriaRequest request = w.CreateRequest(query);
request.ExpectedStatusCode = expectedStatusCode;
AstoriaResponse response = request.GetResponse();
ResponseVerification.VerifyStatusCode(response);
}
示例2: GetHighlightResultsNode
public GetHighlightResultsNode(QueryNode sourceNode, string preTag, string postTag, bool mergeHighlights)
{
this.SourceNode = sourceNode;
this.PreTag = preTag;
this.PostTag = postTag;
this.MergeHighlights = mergeHighlights;
}
示例3: Bind
protected string Bind(QueryNode node)
{
CollectionNode collectionNode = node as CollectionNode;
SingleValueNode singleValueNode = node as SingleValueNode;
if (collectionNode != null)
{
switch (node.Kind)
{
case QueryNodeKind.CollectionNavigationNode:
CollectionNavigationNode navigationNode = node as CollectionNavigationNode;
return BindNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty);
case QueryNodeKind.CollectionPropertyAccess:
return BindCollectionPropertyAccessNode(node as CollectionPropertyAccessNode);
}
}
else if (singleValueNode != null)
{
switch (node.Kind)
{
case QueryNodeKind.BinaryOperator:
return BindBinaryOperatorNode(node as BinaryOperatorNode);
case QueryNodeKind.Constant:
return BindConstantNode(node as ConstantNode);
case QueryNodeKind.Convert:
return BindConvertNode(node as ConvertNode);
case QueryNodeKind.EntityRangeVariableReference:
return BindRangeVariable((node as EntityRangeVariableReferenceNode).RangeVariable);
case QueryNodeKind.NonentityRangeVariableReference:
return BindRangeVariable((node as NonentityRangeVariableReferenceNode).RangeVariable);
case QueryNodeKind.SingleValuePropertyAccess:
return BindPropertyAccessQueryNode(node as SingleValuePropertyAccessNode);
case QueryNodeKind.UnaryOperator:
return BindUnaryOperatorNode(node as UnaryOperatorNode);
case QueryNodeKind.SingleValueFunctionCall:
return BindSingleValueFunctionCallNode(node as SingleValueFunctionCallNode);
case QueryNodeKind.SingleNavigationNode:
SingleNavigationNode navigationNode = node as SingleNavigationNode;
return BindNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty);
case QueryNodeKind.Any:
return BindAnyNode(node as AnyNode);
case QueryNodeKind.All:
return BindAllNode(node as AllNode);
}
}
throw new NotSupportedException(String.Format("Nodes of type {0} are not supported", node.Kind));
}
示例4: WithinRadiusNode
public WithinRadiusNode(QueryNode sourceNode, string field, double lat, double lon, int radius)
{
this.SourceNode = sourceNode;
this.Field = field;
this.Lat = lat;
this.Lon = lon;
this.Radius = radius;
}
示例5: TopNode
/// <summary>
/// Creates a <see cref="TopNode"/>.
/// </summary>
/// <param name="amount">The number of entities to include in the result.</param>
/// <param name="collection">The collection to take items from.</param>
public TopNode(QueryNode amount, CollectionNode collection)
{
ExceptionUtils.CheckArgumentNotNull(amount, "amount");
ExceptionUtils.CheckArgumentNotNull(collection, "collection");
this.amount = amount;
this.collection = collection;
}
示例6: AddNode
protected void AddNode (QueryNode node)
{
if (node is QueryTermNode) {
QueryTermBox box = first_add_node ? FirstRow : CreateRow (true);
box.QueryNode = node as QueryTermNode;
first_add_node = false;
} else {
throw new ArgumentException ("Query is too complex for GUI query editor", "node");
}
}
示例7: ReplaceChild
public void ReplaceChild(QueryNode old_child, QueryNode new_child)
{
int index = children.IndexOf(old_child);
if(index < 0) {
throw new ApplicationException("old_child does not exist");
}
children.RemoveAt(index);
children.Insert(index, new_child);
}
示例8: TryBindIdentifier
internal static bool TryBindIdentifier(string identifier, IEdmEnumTypeReference typeReference, IEdmModel modelWhenNoTypeReference, out QueryNode boundEnum)
{
boundEnum = null;
string text = identifier;
// parse the string, e.g., NS.Color'Green'
// get type information, and also convert Green into an ODataEnumValue
// find the first ', before that, it is namespace.type
int indexOfSingleQuote = text.IndexOf('\'');
if (indexOfSingleQuote < 0)
{
return false;
}
string namespaceAndType = text.Substring(0, indexOfSingleQuote);
Debug.Assert((typeReference == null) || (modelWhenNoTypeReference == null), "((typeReference == null) || (modelWhenNoTypeReference == null)");
// validate typeReference but allow type name not found in model for delayed throwing.
if ((typeReference != null) && !string.Equals(namespaceAndType, typeReference.ODataFullName()))
{
return false;
}
// get the type
IEdmEnumType enumType = typeReference != null
?
(IEdmEnumType)typeReference.Definition
:
UriEdmHelpers.FindEnumTypeFromModel(modelWhenNoTypeReference, namespaceAndType);
if (enumType == null)
{
return false;
}
// now, find out the value
UriPrimitiveTypeParser.TryRemovePrefix(namespaceAndType, ref text);
UriPrimitiveTypeParser.TryRemoveQuotes(ref text);
// parse string or int value to edm enum value
string enumValueString = text;
ODataEnumValue enumValue;
if (!TryParseEnum(enumType, enumValueString, out enumValue))
{
return false;
}
// create an enum node, enclosing an odata enum value
IEdmEnumTypeReference enumTypeReference = typeReference ?? new EdmEnumTypeReference(enumType, false);
boundEnum = new ConstantNode(enumValue, identifier, enumTypeReference);
return true;
}
示例9: Find
public void Find(QueryNode node)
{
switch (node.Kind)
{
case QueryNodeKind.All:
case QueryNodeKind.Any:
var l = (LambdaNode)node;
Find(l.Source);
Find(l.Body);
break;
case QueryNodeKind.BinaryOperator:
var bo = (BinaryOperatorNode)node;
Find(bo.Left);
addPath();
Find(bo.Right);
break;
case QueryNodeKind.Convert:
Find(((ConvertNode)node).Source);
break;
case QueryNodeKind.NonentityRangeVariableReference:
case QueryNodeKind.UnaryOperator:
var uo = (UnaryOperatorNode)node;
Find(uo.Operand);
break;
case QueryNodeKind.SingleValuePropertyAccess:
var sv = (SingleValuePropertyAccessNode)node;
Find(sv.Source);
break;
/*
case QueryNodeKind.CollectionPropertyAccess:
var cpa = (CollectionPropertyAccessNode)node;
Paths[Paths.Count-1] += '.' + cpa.Property.Name;
break;
*/
case QueryNodeKind.CollectionNavigationNode:
var cnn = (CollectionNavigationNode)node;
Find(cnn.Source);
AddNav(cnn.NavigationProperty.Name);
break;
case QueryNodeKind.SingleNavigationNode:
var snn = (SingleNavigationNode)node;
AddNav(snn.NavigationProperty.Name);
break;
//case QueryNodeKind.SingleValueOpenPropertyAccess:
//case QueryNodeKind.SingleEntityCast:
//case QueryNodeKind.EntityCollectionCast:
case QueryNodeKind.NamedFunctionParameter:
Console.WriteLine(node.GetType());
break;
}
}
示例10: ToString
public static string ToString(QueryNode node)
{
if (node == null) return String.Empty;
switch (node.Kind)
{
case QueryNodeKind.Any:
return ToString((AnyNode)node);
case QueryNodeKind.All:
return ToString((AllNode)node);
case QueryNodeKind.NonentityRangeVariableReference:
return ToString((NonentityRangeVariableReferenceNode)node);
case QueryNodeKind.Convert:
return ToString((ConvertNode)node);
case QueryNodeKind.BinaryOperator:
return ToString((BinaryOperatorNode)node);
case QueryNodeKind.UnaryOperator:
return ToString((UnaryOperatorNode)node);
case QueryNodeKind.SingleValueFunctionCall:
return ToString((SingleValueFunctionCallNode)node);
case QueryNodeKind.SingleValuePropertyAccess:
return ToString((SingleValuePropertyAccessNode)node);
case QueryNodeKind.CollectionPropertyAccess:
return ToString((CollectionPropertyAccessNode)node);
case QueryNodeKind.CollectionOpenPropertyAccess:
return ToString((CollectionOpenPropertyAccessNode)node);
case QueryNodeKind.SingleEntityCast:
return ToString((SingleEntityCastNode)node);
case QueryNodeKind.EntityCollectionCast:
return ToString((EntityCollectionCastNode)node);
case QueryNodeKind.EntityRangeVariableReference:
return ToString((EntityRangeVariableReferenceNode)node);
case QueryNodeKind.Constant:
return ToString((ConstantNode)node);
case QueryNodeKind.CollectionNavigationNode:
return ToString((CollectionNavigationNode)node);
case QueryNodeKind.SingleNavigationNode:
return ToString((SingleNavigationNode)node);
case QueryNodeKind.SingleEntityFunctionCall:
return ToString((SingleEntityFunctionCallNode)node);
case QueryNodeKind.NamedFunctionParameter:
return ToString((NamedFunctionParameterNode)node);
case QueryNodeKind.ParameterAlias:
return ToString((ParameterAliasNode)node);
case QueryNodeKind.SearchTerm:
return ToString((SearchTermNode)node);
case QueryNodeKind.CollectionPropertyCast:
return ToString((CollectionPropertyCastNode)node);
case QueryNodeKind.SingleValueCast:
return ToString((SingleValueCastNode)node);
default:
throw new NotSupportedException(String.Format("Node kind not yet supported: {0}", node.Kind.ToString()));
}
}
示例11: Visit
protected override AbstractSolrQuery Visit(QueryNode node, SolrQueryMapperState state)
{
if (node.NodeType == QueryNodeType.Custom)
{
if (node is WithinRadiusNode)
{
return VisitWithinRadius((WithinRadiusNode)node, state);
}
}
return base.Visit(node, state);
}
示例12: AllTokenWithNonEntityCollectionParentNonConstantExpression
public void AllTokenWithNonEntityCollectionParentNonConstantExpression()
{
this.parentQueryNode = new CollectionPropertyAccessNode(new ConstantNode(null), HardCodedTestModel.GetDogNicknamesProperty());
this.expressionQueryNode = new BinaryOperatorNode(BinaryOperatorKind.LessThanOrEqual, new ConstantNode(1), new ConstantNode(5));
var binder = new LambdaBinder(this.FakeBindMethod);
var state = this.GetBindingStateForTest(HardCodedTestModel.GetPersonTypeReference(), HardCodedTestModel.GetPeopleSet());
var allToken = this.CreateTestAllQueryToken();
var result = binder.BindLambdaToken(allToken, state);
result.ShouldBeAllQueryNode().And.Source.ShouldBeCollectionPropertyAccessQueryNode(HardCodedTestModel.GetDogNicknamesProperty());
result.Body.ShouldBeBinaryOperatorNode(BinaryOperatorKind.LessThanOrEqual);
}
示例13: Visit
protected override QueryNode Visit(QueryNode node, SolrQueryOptimizerState state)
{
if (node.NodeType == QueryNodeType.Custom)
{
if (node is WithinRadiusNode)
{
return VisitWithinRadius((WithinRadiusNode)node, state);
}
}
return base.Visit(node, state);
}
示例14: VerifyQueryNodesAreEqual
public static void VerifyQueryNodesAreEqual(QueryNode expected, QueryNode actual, AssertionHandler assert)
{
try
{
if (expected == null)
{
assert.IsNull(actual, "The node should be null.");
return;
}
else
{
assert.IsNotNull(actual, "The node should not be null.");
}
assert.AreEqual(expected.InternalKind, actual.InternalKind, "The node kind differs from expected one.");
switch (expected.InternalKind)
{
case InternalQueryNodeKind.Constant:
VerifyConstantQueryNodesAreEqual((ConstantNode)expected, (ConstantNode)actual, assert);
break;
case InternalQueryNodeKind.Convert:
VerifyConvertQueryNodesAreEqual((ConvertNode)expected, (ConvertNode)actual, assert);
break;
case InternalQueryNodeKind.NonentityRangeVariableReference:
VerifyNonentityRangeVariableReferenceNodesAreEqual((NonentityRangeVariableReferenceNode) expected, (NonentityRangeVariableReferenceNode) actual,assert);
break;
case InternalQueryNodeKind.EntityRangeVariableReference:
VerifyEntityRangeVariableReferenceNodesAreEqual((EntityRangeVariableReferenceNode)expected, (EntityRangeVariableReferenceNode)actual, assert);
break;
case InternalQueryNodeKind.BinaryOperator:
VerifyBinaryOperatorQueryNodesAreEqual((BinaryOperatorNode)expected, (BinaryOperatorNode)actual, assert);
break;
case InternalQueryNodeKind.UnaryOperator:
VerifyUnaryOperatorQueryNodesAreEqual((UnaryOperatorNode)expected, (UnaryOperatorNode)actual, assert);
break;
case InternalQueryNodeKind.SingleValuePropertyAccess:
VerifyPropertyAccessQueryNodesAreEqual((SingleValuePropertyAccessNode)expected, (SingleValuePropertyAccessNode)actual, assert);
break;
case InternalQueryNodeKind.SingleValueFunctionCall:
VerifySingleValueFunctionCallQueryNodesAreEqual((SingleValueFunctionCallNode)expected, (SingleValueFunctionCallNode)actual, assert);
break;
default:
throw new Exception("Query node of kind '" + expected.InternalKind.ToString() + "' not yet supported by VerifyQueryNodesAreEqual.");
}
}
catch (Exception)
{
assert.Warn("Expected query node: " + expected.ToDebugString());
assert.Warn("Actual query node: " + actual.ToDebugString());
throw;
}
}
示例15: ArgumentsAreSetCorrectly
public void ArgumentsAreSetCorrectly()
{
QueryNode[] args = new QueryNode[]
{
new ConstantNode(1),
new ConstantNode(2),
new ConstantNode(3),
new ConstantNode(4),
new ConstantNode(5)
};
SingleValueFunctionCallNode singleValueFunction = new SingleValueFunctionCallNode("stuff", args, EdmCoreModel.Instance.GetInt32(true));
singleValueFunction.Parameters.Should().BeEquivalentTo(args);
}