Merge pull request #572 from jack-pappas/sockets-ipproto
[mono.git] / mcs / class / dlr / Runtime / Microsoft.Scripting.Core / Actions / DeleteMemberBinder.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.Dynamic.Utils;
17
18 namespace System.Dynamic {
19
20     /// <summary>
21     /// Represents the dynamic delete member operation at the call site, providing the binding semantic and the details about the operation.
22     /// </summary>
23     public abstract class DeleteMemberBinder : DynamicMetaObjectBinder {
24         private readonly string _name;
25         private readonly bool _ignoreCase;
26
27         /// <summary>
28         /// Initializes a new instance of the <see cref="DeleteIndexBinder" />.
29         /// </summary>
30         /// <param name="name">The name of the member to delete.</param>
31         /// <param name="ignoreCase">true if the name should be matched ignoring case; false otherwise.</param>
32         protected DeleteMemberBinder(string name, bool ignoreCase) {
33             ContractUtils.RequiresNotNull(name, "name");
34
35             _name = name;
36             _ignoreCase = ignoreCase;
37         }
38
39         /// <summary>
40         /// Gets the name of the member to delete.
41         /// </summary>
42         public string Name {
43             get {
44                 return _name;
45             }
46         }
47
48         /// <summary>
49         /// Gets the value indicating if the string comparison should ignore the case of the member name.
50         /// </summary>
51         public bool IgnoreCase {
52             get {
53                 return _ignoreCase;
54             }
55         }
56
57         /// <summary>
58         /// The result type of the operation.
59         /// </summary>
60         public override sealed Type ReturnType {
61             get { return typeof(void); }
62         }
63
64         /// <summary>
65         /// Performs the binding of the dynamic delete member operation if the target dynamic object cannot bind.
66         /// </summary>
67         /// <param name="target">The target of the dynamic delete member operation.</param>
68         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
69         public DynamicMetaObject FallbackDeleteMember(DynamicMetaObject target) {
70             return FallbackDeleteMember(target, null);
71         }
72
73         /// <summary>
74         /// When overridden in the derived class, performs the binding of the dynamic delete member operation if the target dynamic object cannot bind.
75         /// </summary>
76         /// <param name="target">The target of the dynamic delete member operation.</param>
77         /// <param name="errorSuggestion">The binding result to use if binding fails, or null.</param>
78         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
79         public abstract DynamicMetaObject FallbackDeleteMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion);
80
81         /// <summary>
82         /// Performs the binding of the dynamic delete member operation.
83         /// </summary>
84         /// <param name="target">The target of the dynamic delete member operation.</param>
85         /// <param name="args">An array of arguments of the dynamic delete member operation.</param>
86         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
87         public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
88             ContractUtils.RequiresNotNull(target, "target");
89             ContractUtils.Requires(args == null || args.Length == 0);
90
91             return target.BindDeleteMember(this);
92         }
93
94
95         // this is a standard DynamicMetaObjectBinder
96         internal override sealed bool IsStandardBinder {
97             get {
98                 return true;
99             }
100         }
101     }
102 }