1 /* ****************************************************************************
3 * Copyright (c) Microsoft Corporation.
5 * This source code is subject to terms and conditions of the Microsoft Public License. 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 Microsoft Public License, 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 Microsoft Public License.
11 * You must not remove this notice, or any other, from this software.
14 * ***************************************************************************/
15 using System; using Microsoft;
18 using System.Reflection;
21 namespace System.Linq.Expressions {
23 namespace Microsoft.Linq.Expressions {
26 /// Describes the binding types that are used in MemberInitExpression objects.
28 public enum MemberBindingType {
30 /// A binding that represents initializing a member with the value of an expression.
34 /// A binding that represents recursively initializing members of a member.
38 /// 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.
44 /// Provides the base class from which the classes that represent bindings that are used to initialize members of a newly created object derive.
46 public abstract class MemberBinding {
47 MemberBindingType _type;
51 /// Initializes an instance of <see cref="MemberBinding"/> class.
53 /// <param name="type">The type of member binding.</param>
54 /// <param name="member">The field or property to be initialized.</param>
55 [Obsolete("Do not use this constructor. It will be removed in future releases.")]
56 protected MemberBinding(MemberBindingType type, MemberInfo member) {
62 /// Gets the type of binding that is represented.
64 public MemberBindingType BindingType {
69 /// Gets the field or property to be initialized.
71 public MemberInfo Member {
72 get { return _member; }
76 /// Returns a <see cref="String"/> that represents the current <see cref="Object"/>.
78 /// <returns>A <see cref="String"/> that represents the current <see cref="Object"/>. </returns>
79 public override string ToString() {
80 return ExpressionStringBuilder.MemberBindingToString(this);