#if NET20 || NET30 || !NET_4_6 // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Diagnostics; namespace System.Linq.Expressions.Reimplement { /// /// Represents the default value of a type or an empty expression. /// [DebuggerTypeProxy(typeof(DefaultExpressionProxy))] public sealed class DefaultExpression : Expression { private readonly Type _type; internal DefaultExpression(Type type) { _type = type; } /// /// Gets the static type of the expression that this represents. /// /// The that represents the static type of the expression. public override Type Type { get { return _type; } } /// /// Returns the node type of this Expression. Extension nodes should return /// ExpressionType.Extension when overriding this method. /// /// The of the expression. public override ExpressionType NodeType { get { return ExpressionType.Default; } } protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitDefault(this); } } public partial class Expression { /// /// Creates an empty expression that has type. /// /// /// A that has the property equal to /// and the property set to . /// public static DefaultExpression Empty() { return new DefaultExpression(typeof(void)); } /// /// Creates a that has the property set to the specified type. /// /// A to set the property equal to. /// /// A that has the property equal to /// and the property set to the specified type. /// public static DefaultExpression Default(Type type) { if (type == typeof(void)) { return Empty(); } return new DefaultExpression(type); } } } #endif