2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / dlr / Runtime / Microsoft.Scripting.Core / Actions / DeleteIndexBinder.cs
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  * ***************************************************************************/
15 using System; using Microsoft;
16
17
18 #if CODEPLEX_40
19 using System.Dynamic.Utils;
20 #else
21 using Microsoft.Scripting.Utils;
22 #endif
23
24 #if CODEPLEX_40
25 namespace System.Dynamic {
26 #else
27 namespace Microsoft.Scripting {
28 #endif
29     /// <summary>
30     /// Represents the dynamic delete index operation at the call site, providing the binding semantic and the details about the operation.
31     /// </summary>
32     public abstract class DeleteIndexBinder : DynamicMetaObjectBinder {
33         private readonly CallInfo _callInfo;
34
35         /// <summary>
36         /// Initializes a new instance of the <see cref="DeleteIndexBinder" />.
37         /// </summary>
38         /// <param name="callInfo">The signature of the arguments at the call site.</param>
39         protected DeleteIndexBinder(CallInfo callInfo) {
40             ContractUtils.RequiresNotNull(callInfo, "callInfo");
41             _callInfo = callInfo;
42         }
43
44         /// <summary>
45         /// The result type of the operation.
46         /// </summary>
47         public override sealed Type ReturnType {
48             get { return typeof(void); }
49         }
50
51         /// <summary>
52         /// Gets the signature of the arguments at the call site.
53         /// </summary>
54         public CallInfo CallInfo {
55             get { return _callInfo; }
56         }
57
58         /// <summary>
59         /// Performs the binding of the dynamic delete index operation.
60         /// </summary>
61         /// <param name="target">The target of the dynamic delete index operation.</param>
62         /// <param name="args">An array of arguments of the dynamic delete index operation.</param>
63         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
64         public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
65             ContractUtils.RequiresNotNull(target, "target");
66             ContractUtils.RequiresNotNullItems(args, "args");
67
68             return target.BindDeleteIndex(this, args);
69         }
70
71         // this is a standard DynamicMetaObjectBinder
72         internal override sealed bool IsStandardBinder {
73             get {
74                 return true;
75             }
76         }
77
78         /// <summary>
79         /// Performs the binding of the dynamic delete index operation if the target dynamic object cannot bind.
80         /// </summary>
81         /// <param name="target">The target of the dynamic delete index operation.</param>
82         /// <param name="indexes">The arguments of the dynamic delete index operation.</param>
83         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
84         public DynamicMetaObject FallbackDeleteIndex(DynamicMetaObject target, DynamicMetaObject[] indexes) {
85             return FallbackDeleteIndex(target, indexes, null);
86         }
87
88         /// <summary>
89         /// When overridden in the derived class, performs the binding of the dynamic delete index operation if the target dynamic object cannot bind.
90         /// </summary>
91         /// <param name="target">The target of the dynamic delete index operation.</param>
92         /// <param name="indexes">The arguments of the dynamic delete index operation.</param>
93         /// <param name="errorSuggestion">The binding result to use if binding fails, or null.</param>
94         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
95         public abstract DynamicMetaObject FallbackDeleteIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion);
96     }
97 }