/// <summary> /// Compares convert query nodes. /// </summary> /// <param name="left">Left side of comparison</param> /// <param name="right">Right side of comparison</param> /// <returns>True if equal, otherwise false</returns> private bool Compare(ConvertNode left, ConvertNode right) { if (left.TypeReference != right.TypeReference) return false; if (!this.Compare(left.Source, right.Source)) return false; return true; }
public void SourceIsSetCorrectly() { ConstantNode source = new ConstantNode(1); ConvertNode convertNode = new ConvertNode(source, source.TypeReference); convertNode.Source.As <ConstantNode>().Value.As <int>().Should().Be(1); }
internal static object TranslateNode(object value) { if (value == null) { return(null); } ConstantNode node = value as ConstantNode; if (node != null) { return(node.Value); } ConvertNode convertNode = value as ConvertNode; if (convertNode != null) { object source = TranslateNode(convertNode.Source); return(source); } ParameterAliasNode parameterAliasNode = value as ParameterAliasNode; if (parameterAliasNode != null) { return(parameterAliasNode.Alias); } throw Error.NotSupported(SRResources.CannotRecognizeNodeType, typeof(ODataParameterHelper), value.GetType().FullName); }
public override FilterValue Visit(ConvertNode nodeIn) { if (nodeIn.TypeReference.Definition == BooleanType) { var value = ConstantVisitor.Visit(nodeIn.Source); return(new FilterValue(bool.Parse(value.ToString()))); } if (nodeIn.TypeReference.Definition == GuidType) { var value = ConstantVisitor.Visit(nodeIn.Source); return(new FilterValue(Guid.Parse(value.ToString()))); } if (nodeIn.TypeReference.Definition == DateTimeType) { var value = ConstantVisitor.Visit(nodeIn.Source); return(new FilterValue(ParseInstant(value))); } if (ConstantVisitor.Visit(nodeIn.Source) == null) { return(FilterValue.Null); } throw new NotSupportedException(); }
public override QueryNode Visit(BinaryOperatorNode nodeIn) { this.sql.Append("("); QueryNode left = nodeIn.LeftOperand; QueryNode right = nodeIn.RightOperand; if (left != null) { // modulo requires the dividend to be an integer, monetary or numeric // rewrite the expression to convert to numeric, allowing the DB to apply // rounding if needed. our default data type for number is float which // is incompatible with modulo. if (nodeIn.OperatorKind == BinaryOperatorKind.Modulo) { left = new ConvertNode(left, typeof(int)); } left = left.Accept(this); } if (right is ConstantNode rightConstant && rightConstant.Value == null) { // inequality expressions against a null literal have a special // translation in SQL if (nodeIn.OperatorKind == BinaryOperatorKind.Equal) { this.sql.Append(" IS NULL"); } else if (nodeIn.OperatorKind == BinaryOperatorKind.NotEqual) { this.sql.Append(" IS NOT NULL"); } }
internal Expression CreateConvertExpression(ConvertNode convertNode, Expression source) { Type conversionType = EdmLibHelpers.GetClrType(convertNode.TypeReference, Model, InternalAssembliesResolver); if (conversionType == typeof(bool?) && source.Type == typeof(bool)) { // we handle null propagation ourselves. So, if converting from bool to Nullable<bool> ignore. return(source); } else if (conversionType == typeof(Date?) && (source.Type == typeof(DateTimeOffset?) || source.Type == typeof(DateTime?))) { return(source); } if ((conversionType == typeof(TimeOfDay?) && source.Type == typeof(TimeOfDay)) || ((conversionType == typeof(Date?) && source.Type == typeof(Date)))) { return(source); } else if (conversionType == typeof(TimeOfDay?) && (source.Type == typeof(DateTimeOffset?) || source.Type == typeof(DateTime?) || source.Type == typeof(TimeSpan?))) { return(source); } else if (IsDateAndTimeRelated(conversionType) && IsDateAndTimeRelated(source.Type)) { return(source); } else if (source == NullConstant) { return(source); } else { if (TypeHelper.IsEnum(source.Type)) { // we handle enum conversions ourselves return(source); } else { // if a cast is from Nullable<T> to Non-Nullable<T> we need to check if source is null if (QuerySettings.HandleNullPropagation == HandleNullPropagationOption.True && IsNullable(source.Type) && !IsNullable(conversionType)) { // source == null ? null : source.Value return (Expression.Condition( test: CheckForNull(source), ifTrue: Expression.Constant(null, ToNullable(conversionType)), ifFalse: Expression.Convert(ExtractValueFromNullableExpression(source), ToNullable(conversionType)))); } else { return(Expression.Convert(source, conversionType)); } } } }
/// <summary> /// We return the <see cref="ResourceRangeVariableReferenceNode"/> within a <see cref="QueryNode"/> /// </summary> /// <param name="node">The node to extract the ResourceRangeVariableReferenceNode.</param> /// <returns>The extracted ResourceRangeVariableReferenceNode.</returns> private ResourceRangeVariableReferenceNode GetResourceRangeVariableReferenceNode(QueryNode node) { if (node == null) { return(null); } switch (node.Kind) { case QueryNodeKind.SingleValuePropertyAccess: SingleValuePropertyAccessNode singleValuePropertyAccessNode = node as SingleValuePropertyAccessNode; return(GetResourceRangeVariableReferenceNode(singleValuePropertyAccessNode.Source)); case QueryNodeKind.Convert: ConvertNode convertNode = node as ConvertNode; return(GetResourceRangeVariableReferenceNode(convertNode.Source)); case QueryNodeKind.Any: AnyNode anyNode = node as AnyNode; return(GetResourceRangeVariableReferenceNode(anyNode.Source)); case QueryNodeKind.SingleValueFunctionCall: SingleValueFunctionCallNode singleValueFunctionCallNode = node as SingleValueFunctionCallNode; return(GetResourceRangeVariableReferenceNode(singleValueFunctionCallNode.Parameters.First())); case QueryNodeKind.ResourceRangeVariableReference: return(node as ResourceRangeVariableReferenceNode); case QueryNodeKind.SingleValueOpenPropertyAccess: SingleValueOpenPropertyAccessNode singleValueOpenPropertyAccessNode = node as SingleValueOpenPropertyAccessNode; return(GetResourceRangeVariableReferenceNode(singleValueOpenPropertyAccessNode.Source)); case QueryNodeKind.SingleComplexNode: SingleComplexNode singleComplexNode = node as SingleComplexNode; return(GetResourceRangeVariableReferenceNode(singleComplexNode.Source)); case QueryNodeKind.CollectionComplexNode: CollectionComplexNode collectionComplexNode = node as CollectionComplexNode; return(GetResourceRangeVariableReferenceNode(collectionComplexNode.Source)); case QueryNodeKind.CollectionNavigationNode: CollectionNavigationNode collectionNavigationNode = node as CollectionNavigationNode; return(GetResourceRangeVariableReferenceNode(collectionNavigationNode.Source)); case QueryNodeKind.SingleNavigationNode: SingleNavigationNode singleNavigationNode = node as SingleNavigationNode; return(GetResourceRangeVariableReferenceNode(singleNavigationNode.Source)); case QueryNodeKind.CollectionResourceFunctionCall: CollectionResourceFunctionCallNode collectionResourceFunctionCallNode = node as CollectionResourceFunctionCallNode; return(GetResourceRangeVariableReferenceNode(collectionResourceFunctionCallNode.Source)); case QueryNodeKind.SingleResourceFunctionCall: SingleResourceFunctionCallNode singleResourceFunctionCallNode = node as SingleResourceFunctionCallNode; return(GetResourceRangeVariableReferenceNode(singleResourceFunctionCallNode.Source)); } return(null); }
protected virtual bool Visit <TInput, TOutput>(ConvertNode <TInput, TOutput> node) where TInput : TOutput { IncreaseDepth(); Visit(node.Output); DecreaseDepth(); return(true); }
protected override bool Visit <TInput, TOutput>(ConvertNode <TInput, TOutput> node) { _current = GetVertex(node.GetHashCode(), () => "\u21A7", typeof(ConvertNode <,>), typeof(TOutput)); LinkFromParent(); return(WithVertex(() => base.Visit(node))); }
/// <summary> /// Writes convert query node to string. /// </summary> /// <param name="node">Node to write to string</param> /// <returns>String representation of node.</returns> private static string ToString(ConvertNode node) { return(tabHelper.Prefix + "ConvertNode" + tabHelper.Indent(() => tabHelper.Prefix + "TypeReference = " + node.TypeReference + tabHelper.Prefix + "Source = " + ToString(node.Source) )); }
public void ConvertNode_SetChildren_Works() { ConvertNode instance = new ConvertNode(null, typeof(string)); List <QueryNode> children = new QueryNode[] { new ConstantNode("abc123") }.ToList(); instance.SetChildren(children); Assert.Same(children[0], instance.Source); Assert.Equal(typeof(string), instance.TargetType); }
/// <summary> /// Binds a <see cref="ConvertNode"/> to create a LINQ <see cref="Expression"/> that /// represents the semantics of the <see cref="ConvertNode"/>. /// </summary> /// <param name="convertNode">The node to bind.</param> /// <returns>The LINQ <see cref="Expression"/> created.</returns> public virtual Expression BindConvertNode(ConvertNode convertNode) { Contract.Assert(convertNode != null); Contract.Assert(convertNode.TypeReference != null); Expression source = Bind(convertNode.Source); return(CreateConvertExpression(convertNode, source)); }
/// <summary> /// Translate a ConvertNode. /// </summary> /// <param name="nodeIn">The node to be translated.</param> /// <returns>The translated node.</returns> public override QueryNode Visit(ConvertNode nodeIn) { if (nodeIn == null) { throw Error.ArgumentNull(nameof(nodeIn)); } return(new ConvertNode((SingleValueNode)nodeIn.Source.Accept(this), nodeIn.TypeReference)); }
public void SourceIsSetCorrectly() { ConstantNode source = new ConstantNode(1); ConvertNode convertNode = new ConvertNode(source, source.TypeReference); ConstantNode conNode = Assert.IsType <ConstantNode>(convertNode.Source); Assert.Equal(1, Assert.IsType <int>(conNode.Value)); }
public void ConvertExpressionHasExpectedOperand() { IExpressionNode actual = TestObject.Build(TestConvertExpression); ConvertNode actualNode = actual.VerifyIsActually <ConvertNode>(); ConstantNode operandNode = actualNode.Operand.VerifyIsActually <ConstantNode>(); Assert.AreSame(TestConstantOne, operandNode.SourceExpression); }
public override Expression Visit(ConvertNode nodeIn) { Expression e = TranslateNode(nodeIn.Source); if (e is ConstantExpression constantExpression && constantExpression.Value == null && constantExpression.Type == typeof(Object)) { return(OeConstantToVariableVisitor.NullConstantExpression); } return(e); }
public override QueryNode Visit(ConvertNode nodeIn) { SingleValueNode?source = nodeIn.Source == null ? null : (SingleValueNode)Visit(nodeIn.Source); if (nodeIn.Source != source) { nodeIn = new ConvertNode(source, nodeIn.TypeReference); } return(nodeIn); }
/// <summary> /// Visit a ConvertNode /// </summary> /// <param name="nodeIn">the node to visit</param> /// <returns>true, indicating that the node has been visited.</returns> public override bool Visit(ConvertNode nodeIn) { validate(nodeIn); validate(nodeIn.TypeReference.Definition); if (nodeIn.TypeReference.IsCollection()) { validate(nodeIn.TypeReference.Definition.AsElementType()); } return(true); }
public void ConvertExpressionIsExpected() { Expression testExpression = TestConvertExpression; IExpressionNode actual = TestObject.Build(testExpression); ConvertNode actualNode = actual.VerifyIsActually <ConvertNode>(); Assert.AreSame(testExpression, actualNode.SourceExpression); }
public void Init() { _testExpression = Expression.Convert(TestOperandExpression, typeof(int)); MockNodeFactory .Setup(factory => factory.Build(TestOperandExpression)) .Returns(MockOperandExpression.Object); TestObject = new ConvertNode( MockNodeFactory.Object, TestExpression); }
/// <summary> /// Compares convert query nodes. /// </summary> /// <param name="left">Left side of comparison</param> /// <param name="right">Right side of comparison</param> /// <returns>True if equal, otherwise false</returns> private bool Compare(ConvertNode left, ConvertNode right) { if (left.TypeReference != right.TypeReference) { return(false); } if (!this.Compare(left.Source, right.Source)) { return(false); } return(true); }
private static string TranslateNode(object node, string functionName, string parameterName) { // If the function parameter is null, for example myFunction(param=null), // the input node here is not null, it is a contant node with a value as "null". // However, if a function call (or key) using parameter alias but without providing the parameter alias value, // the input node here is a null. if (node == null) { // We can't throw ODataException here because ODataException will be caught and return 404 response with empty message. throw new InvalidOperationException(Error.Format(SRResources.MissingConvertNode, parameterName, functionName)); } ConstantNode constantNode = node as ConstantNode; if (constantNode != null) { UriTemplateExpression uriTemplateExpression = constantNode.Value as UriTemplateExpression; if (uriTemplateExpression != null) { return(uriTemplateExpression.LiteralText); } // Make the enum prefix free to work. ODataEnumValue enumValue = constantNode.Value as ODataEnumValue; if (enumValue != null) { return(ODataUriUtils.ConvertToUriLiteral(enumValue, ODataVersion.V4)); } return(constantNode.LiteralText); } ConvertNode convertNode = node as ConvertNode; if (convertNode != null) { return(TranslateNode(convertNode.Source, functionName, parameterName)); } ParameterAliasNode parameterAliasNode = node as ParameterAliasNode; if (parameterAliasNode != null) { return(parameterAliasNode.Alias); } //return node.ToString(); throw Error.NotSupported(SRResources.CannotRecognizeNodeType, typeof(ODataPathSegmentHandler), node.GetType().FullName); }
// Translate the node in ODL path to string literal. private string TranslateNode(object node) { if (node == null) { throw Error.ArgumentNull("node"); } ConstantNode constantNode = node as ConstantNode; if (constantNode != null) { if (_enableUriTemplateParsing) { UriTemplateExpression uriTemplateExpression = constantNode.Value as UriTemplateExpression; if (uriTemplateExpression != null) { return(uriTemplateExpression.LiteralText); } } // Make the enum prefix free to work. ODataEnumValue enumValue = constantNode.Value as ODataEnumValue; if (enumValue != null) { return(ODataUriUtils.ConvertToUriLiteral(enumValue, ODataVersion.V4)); } return(constantNode.LiteralText); } ConvertNode convertNode = node as ConvertNode; if (convertNode != null) { return(TranslateNode(convertNode.Source)); } ParameterAliasNode parameterAliasNode = node as ParameterAliasNode; if (parameterAliasNode != null) { return(TranslateParameterAlias(parameterAliasNode.Alias)); } throw Error.NotSupported( SRResources.CannotRecognizeNodeType, typeof(ODataPathSegmentTranslator), node.GetType().FullName); }
/// <summary> /// Override this method to restrict the 'cast' inside the filter query. /// </summary> /// <remarks> /// This method is intended to be called from method overrides in subclasses. This method also supports unit-testing scenarios and is not intended to be called from user code. /// Call the Validate method to validate a <see cref="FilterQueryOption"/> instance. /// </remarks> /// <param name="convertNode"></param> /// <param name="settings"></param> public virtual void ValidateConvertNode(ConvertNode convertNode, ODataValidationSettings settings) { if (convertNode == null) { throw Error.ArgumentNull(nameof(convertNode)); } if (settings == null) { throw Error.ArgumentNull(nameof(settings)); } // Validate child nodes but not the ConvertNode itself. ValidateQueryNode(convertNode.Source, settings); }
/// <summary> /// Override this method to restrict the 'cast' inside the filter query. /// </summary> /// <remarks> /// This method is intended to be called from method overrides in subclasses. This method also supports unit-testing scenarios and is not intended to be called from user code. /// Call the Validate method to validate a <see cref="FilterQueryOption"/> instance. /// </remarks> /// <param name="convertNode"></param> /// <param name="settings"></param> public virtual void ValidateConvertNode(ConvertNode convertNode, ODataValidationSettings settings) { if (convertNode == null) { throw Error.ArgumentNull("convertNode"); } if (settings == null) { throw Error.ArgumentNull("settings"); } // no default validation logic here ValidateQueryNode(convertNode.Source, settings); }
public override IProjection Visit(ConvertNode nodeIn) { var sourceNode = nodeIn.Source; if (!(sourceNode is ConstantNode)) { return(null); } var constantNode = (ConstantNode)sourceNode; var convertedValue = this.ConvertValueFromLiteralValue(nodeIn.TypeReference, constantNode.Value); var convertNode = new ConstantNode(convertedValue); return(convertNode.Accept <IProjection>(this)); }
/// <summary> /// Visit a ConvertNode /// </summary> /// <param name="nodeIn">The node to visit</param> /// <returns>The translated expression</returns> public override Expression Visit(ConvertNode nodeIn) { this.CheckArgumentNull(nodeIn, "ConvertNode"); var sourceExpression = this.TranslateNode(nodeIn.Source); var targetEdmType = nodeIn.TypeReference; if (null == targetEdmType) { //Open property's target type is null, so return the source expression directly, supposely the caller should be ready to handle data of Object type. return(sourceExpression); } var targetClrType = EdmClrTypeUtils.GetInstanceType(targetEdmType); return(Expression.Convert(sourceExpression, targetClrType)); }
public void CtorComputeQueryOption_GetQueryNodeParsesQuery() { // Arrange IEdmModel model = _model; ODataQueryContext context = new ODataQueryContext(model, typeof(ComputeCustomer)) { RequestContainer = new MockServiceProvider() }; // Act ComputeQueryOption compute = new ComputeQueryOption("Price mul Qty as Total,Price mul 2.0 as Tax", context); ComputeClause computeClause = compute.ComputeClause; // Assert Assert.Equal(2, computeClause.ComputedItems.Count()); Assert.Collection(computeClause.ComputedItems, e => { Assert.Equal("Total", e.Alias); Assert.Equal(QueryNodeKind.BinaryOperator, e.Expression.Kind); BinaryOperatorNode binaryNode = e.Expression as BinaryOperatorNode; Assert.Equal(BinaryOperatorKind.Multiply, binaryNode.OperatorKind); Assert.Equal(QueryNodeKind.Convert, binaryNode.Right.Kind); ConvertNode convertNode = (ConvertNode)binaryNode.Right; Assert.Equal("Qty", ((SingleValuePropertyAccessNode)convertNode.Source).Property.Name); Assert.Equal(QueryNodeKind.SingleValuePropertyAccess, binaryNode.Left.Kind); var propertyAccessNode = binaryNode.Left as SingleValuePropertyAccessNode; Assert.Equal("Price", propertyAccessNode.Property.Name); }, e => { Assert.Equal("Tax", e.Alias); Assert.Equal(QueryNodeKind.BinaryOperator, e.Expression.Kind); BinaryOperatorNode binaryNode = e.Expression as BinaryOperatorNode; Assert.Equal(BinaryOperatorKind.Multiply, binaryNode.OperatorKind); Assert.Equal(QueryNodeKind.Constant, binaryNode.Right.Kind); Assert.Equal(2.0, ((ConstantNode)binaryNode.Right).Value); Assert.Equal(QueryNodeKind.SingleValuePropertyAccess, binaryNode.Left.Kind); var propertyAccessNode = binaryNode.Left as SingleValuePropertyAccessNode; Assert.Equal("Price", propertyAccessNode.Property.Name); }); }
/// <summary> /// Gets the constant node of a node, either directly or from a function modifier /// </summary> /// <param name="binaryNode">Node to be evaluated.</param> /// <returns>A ConstantNode or null if the node does not contain a node that can be resolved to a constant.</returns> private static ConstantNode GetConstantNode(BinaryOperatorNode binaryNode) { ConvertNode convertNode = null; ConstantNode constantNode = null; convertNode = binaryNode.Right as ConvertNode; if (convertNode != null) { constantNode = convertNode.Source as ConstantNode; } else { constantNode = binaryNode.Right as ConstantNode; } return(constantNode); }
public override Expression Visit(ConvertNode nodeIn) { Expression e = TranslateNode(nodeIn.Source); if (e.NodeType == ExpressionType.Constant) { var constantExpression = e as ConstantExpression; if (constantExpression.Value == null && constantExpression.Type == typeof(Object)) { Type clrType; EdmPrimitiveTypeKind primitiveTypeKind = nodeIn.TypeReference.PrimitiveKind(); if (primitiveTypeKind == EdmPrimitiveTypeKind.None) { if (nodeIn.TypeReference.IsEnum()) { var clrTypeAnnotation = _edmModel.GetAnnotationValue <ModelBuilder.OeClrTypeAnnotation>(nodeIn.TypeReference.Definition); if (clrTypeAnnotation == null) { throw new InvalidOperationException("Add OeClrTypeAnnotation for " + nodeIn.TypeReference.FullName()); } clrType = clrTypeAnnotation.ClrType; } else { throw new NotSupportedException(nodeIn.TypeReference.FullName()); } } else { clrType = ModelBuilder.PrimitiveTypeHelper.GetClrType(primitiveTypeKind); } if (nodeIn.TypeReference.IsNullable && clrType.GetTypeInfo().IsValueType) { clrType = typeof(Nullable <>).MakeGenericType(clrType); } ConstantExpression newConstantExpression = Expression.Constant(null, clrType); ReplaceConstant(constantExpression, newConstantExpression); e = newConstantExpression; } } return(e); }
public override object Visit(ConvertNode nodeIn) { if (nodeIn.TypeReference.Definition == BooleanType) { return(bool.Parse(Visit(nodeIn.Source).ToString())); } if (nodeIn.TypeReference.Definition == GuidType) { return(Guid.Parse(Visit(nodeIn.Source).ToString())); } if (nodeIn.TypeReference.Definition == DateTimeType) { var value = Visit(nodeIn.Source); if (value is DateTimeOffset dateTimeOffset) { return(Instant.FromDateTimeOffset(dateTimeOffset)); } if (value is DateTime dateTime) { return(Instant.FromDateTimeUtc(DateTime.SpecifyKind(dateTime, DateTimeKind.Utc))); } if (value is Date date) { return(Instant.FromUtc(date.Year, date.Month, date.Day, 0, 0)); } var parseResult = InstantPattern.General.Parse(Visit(nodeIn.Source).ToString()); if (!parseResult.Success) { throw new ODataException("Datetime is not in a valid format. Use ISO 8601"); } return(parseResult.Value); } return(base.Visit(nodeIn)); }
protected ConvertContext(ConvertEnvironment environment, XElement convertTree) { this.environment = environment; IEnumerable<XElement> trees = from tree in convertTree.Elements(@"ConvertConfigs") select tree; foreach (XElement singleTree in trees) { ConvertTree treeEntity; if (singleTree.Attribute(@"namespace") != null) { treeEntity = new ConvertTree(singleTree.Attribute(@"Name").Value, singleTree.Attribute(@"namespace").Value); } else { treeEntity = new ConvertTree(singleTree.Attribute(@"Name").Value); } convertTrees.Add(treeEntity); IEnumerable<XElement> nodes = from node in singleTree.Elements(@"ConvertNode") select node; foreach (XElement singleNode in nodes) { ConvertNode nodeEntity = new ConvertNode(singleNode.Attribute(@"Name").Value); treeEntity.Add(nodeEntity); IEnumerable<XElement> resNodes = from res in singleNode.Elements(@"ResourceConfig") select res; foreach (XElement resInfo in resNodes) { ResourceInformation resEntity = new ResourceInformation(resInfo, this.environment); nodeEntity.Add(resEntity); } } } }
private string BindConvertNode(ConvertNode convertNode) { return Bind(convertNode.Source); }
private static void VerifyConvertQueryNodesAreEqual(ConvertNode expected, ConvertNode actual, AssertionHandler assert) { assert.AreEqual(expected.TypeReference.TestFullName(), actual.TypeReference.TestFullName(), "The target type names differ."); VerifyQueryNodesAreEqual(expected.Source, actual.Source, assert); }
public void KindIsSetToConvertNode() { ConstantNode source = new ConstantNode(1); ConvertNode convertNode = new ConvertNode(source, EdmCoreModel.Instance.GetInt64(true)); convertNode.InternalKind.Should().Be(InternalQueryNodeKind.Convert); }
public void TypeReferenceIsSetCorrectly() { ConstantNode source = new ConstantNode(1); ConvertNode convertNode = new ConvertNode(source, EdmCoreModel.Instance.GetInt64(true)); convertNode.TypeReference.FullName().Should().Be("Edm.Int64"); }
public void SourceIsSetCorrectly() { ConstantNode source = new ConstantNode(1); ConvertNode convertNode = new ConvertNode(source, source.TypeReference); convertNode.Source.As<ConstantNode>().Value.As<int>().Should().Be(1); }
public override void ValidateConvertNode(ConvertNode convertQueryNode, ODataValidationSettings settings) { IncrementCount("ValidateConvertQueryNode"); base.ValidateConvertNode(convertQueryNode, settings); }
/// <summary> /// Writes convert query node to string. /// </summary> /// <param name="node">Node to write to string</param> /// <returns>String representation of node.</returns> private static string ToString(ConvertNode node) { return tabHelper.Prefix + "ConvertNode" + tabHelper.Indent(() => tabHelper.Prefix + "TypeReference = " + node.TypeReference + tabHelper.Prefix + "Source = " + ToString(node.Source) ); }
/// <summary> /// Override this method to restrict the 'cast' inside the filter query. /// </summary> /// <remarks> /// This method is intended to be called from method overrides in subclasses. This method also supports unit-testing scenarios and is not intended to be called from user code. /// Call the Validate method to validate a <see cref="FilterQueryOption"/> instance. /// </remarks> /// <param name="convertNode"></param> /// <param name="settings"></param> public virtual void ValidateConvertNode(ConvertNode convertNode, ODataValidationSettings settings) { if (convertNode == null) { throw Error.ArgumentNull("convertNode"); } if (settings == null) { throw Error.ArgumentNull("settings"); } // Validate child nodes but not the ConvertNode itself. ValidateQueryNode(convertNode.Source, settings); }