PageRenderTime 162ms CodeModel.GetById 120ms app.highlight 3ms RepoModel.GetById 38ms app.codeStats 0ms

/Microsoft.Scripting.Core/Ast/MemberBinding.cs

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