public static ConditionalMemberCSharpExpression ConditionalProperty(Expression expression, PropertyInfo property) { RequiresCanRead(expression, nameof(expression)); ContractUtils.RequiresNotNull(property, nameof(property)); if (!property.CanRead) { throw Error.ConditionalAccessRequiresReadableProperty(); } if (property.GetIndexParameters().Length != 0) { throw Error.ConditionalAccessRequiresReadableProperty(); } if (property.GetGetMethod(true).IsStatic) { throw Error.ConditionalAccessRequiresNonStaticMember(); } var type = expression.Type.GetNonNullReceiverType(); if (!TypeUtils.IsValidInstanceType(property, type)) { throw LinqError.PropertyNotDefinedForType(property, type); } return(ConditionalMemberCSharpExpression.Make(expression, property)); }
public static ConditionalMemberCSharpExpression ConditionalField(Expression expression, FieldInfo field) { RequiresCanRead(expression, nameof(expression)); ContractUtils.RequiresNotNull(field, nameof(field)); if (field.IsStatic) { throw Error.ConditionalAccessRequiresNonStaticMember(); } var type = expression.Type.GetNonNullReceiverType(); if (!TypeUtils1.AreReferenceAssignable(field.DeclaringType, type)) { throw LinqError.FieldInfoNotDefinedForType(field.DeclaringType, field.Name, type); } return(ConditionalMemberCSharpExpression.Make(expression, field)); }
protected internal virtual Expression VisitConditionalMember(ConditionalMemberCSharpExpression node) { return(node.Update(Visit(node.Expression))); }
protected internal override Expression VisitConditionalMember(ConditionalMemberCSharpExpression node) { var expr = Visit(node.Expression); return(Push("CSharpConditionalMemberAccess", node, new XAttribute(nameof(node.Member), node.Member), new XElement(nameof(node.Expression), expr))); }
public ConditionalMemberCSharpExpressionProxy(ConditionalMemberCSharpExpression node) { _node = node; }