System.Drawing: added email to icon and test file headers
[mono.git] / mcs / class / dlr / Runtime / Microsoft.Scripting.Core / Ast / MemberBinding.cs
1 /* ****************************************************************************
2  *
3  * Copyright (c) Microsoft Corporation. 
4  *
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.
10  *
11  * You must not remove this notice, or any other, from this software.
12  *
13  *
14  * ***************************************************************************/
15
16 using System;
17 using System.Reflection;
18
19 #if CLR2
20 namespace Microsoft.Scripting.Ast {
21 #else
22 namespace System.Linq.Expressions {
23 #endif
24     /// <summary>
25     /// Describes the binding types that are used in MemberInitExpression objects.
26     /// </summary>
27     public enum MemberBindingType {
28         /// <summary>
29         /// A binding that represents initializing a member with the value of an expression.
30         /// </summary>
31         Assignment,
32         /// <summary>
33         /// A binding that represents recursively initializing members of a member.
34         /// </summary>
35         MemberBinding,
36         /// <summary>
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.
38         /// </summary>
39         ListBinding
40     }
41
42     /// <summary>
43     /// Provides the base class from which the classes that represent bindings that are used to initialize members of a newly created object derive.
44     /// </summary>
45     public abstract class MemberBinding {
46         MemberBindingType _type;
47         MemberInfo _member;
48
49         /// <summary>
50         /// Initializes an instance of <see cref="MemberBinding"/> class.
51         /// </summary>
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) {
56             _type = type;
57             _member = member;
58         }
59
60         /// <summary>
61         /// Gets the type of binding that is represented.
62         /// </summary>
63         public MemberBindingType BindingType {
64             get { return _type; }
65         }
66
67         /// <summary>
68         /// Gets the field or property to be initialized.
69         /// </summary>
70         public MemberInfo Member {
71             get { return _member; }
72         }
73
74         /// <summary>
75         /// Returns a <see cref="String"/> that represents the current <see cref="Object"/>. 
76         /// </summary>
77         /// <returns>A <see cref="String"/> that represents the current <see cref="Object"/>. </returns>
78         public override string ToString() {
79             return ExpressionStringBuilder.MemberBindingToString(this);
80         }
81     }
82 }