1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6 * copy of the license can be found in the License.html file at the root of this distribution. If
7 * you cannot locate the Apache License, Version 2.0, please send an email to
8 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9 * by the terms of the Apache License, Version 2.0.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
17 using System.Reflection;
20 namespace Microsoft.Scripting.Ast {
22 namespace System.Linq.Expressions {
25 /// Describes the binding types that are used in MemberInitExpression objects.
27 public enum MemberBindingType {
29 /// A binding that represents initializing a member with the value of an expression.
33 /// A binding that represents recursively initializing members of a member.
37 /// A binding that represents initializing a member of type <see cref="System.Collections.IList"/> or <see cref="System.Collections.Generic.ICollection{T}"/> from a list of elements.
43 /// Provides the base class from which the classes that represent bindings that are used to initialize members of a newly created object derive.
45 public abstract class MemberBinding {
46 MemberBindingType _type;
50 /// Initializes an instance of <see cref="MemberBinding"/> class.
52 /// <param name="type">The type of member binding.</param>
53 /// <param name="member">The field or property to be initialized.</param>
54 [Obsolete("Do not use this constructor. It will be removed in future releases.")]
55 protected MemberBinding(MemberBindingType type, MemberInfo member) {
61 /// Gets the type of binding that is represented.
63 public MemberBindingType BindingType {
68 /// Gets the field or property to be initialized.
70 public MemberInfo Member {
71 get { return _member; }
75 /// Returns a <see cref="String"/> that represents the current <see cref="Object"/>.
77 /// <returns>A <see cref="String"/> that represents the current <see cref="Object"/>. </returns>
78 public override string ToString() {
79 return ExpressionStringBuilder.MemberBindingToString(this);