PageRenderTime 959ms CodeModel.GetById 29ms RepoModel.GetById 2ms app.codeStats 0ms

/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DeleteMemberBinder.cs

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