The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ DataObjectMethodAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DataObjectAttribute.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.ComponentModel
  16. {
  17.    
  18.     using System;
  19.     using System.Security.Permissions;
  20.    
  21.     /// <devdoc>
  22.     /// </devdoc>
  23.     [AttributeUsage(AttributeTargets.Method)]
  24.     public sealed class DataObjectMethodAttribute : Attribute
  25.     {
  26.        
  27.         private bool _isDefault;
  28.         private DataObjectMethodType _methodType;
  29.        
  30.         public DataObjectMethodAttribute(DataObjectMethodType methodType) : this(methodType, false)
  31.         {
  32.         }
  33.        
  34.         public DataObjectMethodAttribute(DataObjectMethodType methodType, bool isDefault)
  35.         {
  36.             _methodType = methodType;
  37.             _isDefault = isDefault;
  38.         }
  39.        
  40.         public bool IsDefault {
  41.             get { return _isDefault; }
  42.         }
  43.        
  44.         public DataObjectMethodType MethodType {
  45.             get { return _methodType; }
  46.         }
  47.        
  48.         /// <internalonly/>
  49.         public override bool Equals(object obj)
  50.         {
  51.             if (obj == this) {
  52.                 return true;
  53.             }
  54.            
  55.             DataObjectMethodAttribute other = obj as DataObjectMethodAttribute;
  56.             return (other != null) && (other.MethodType == MethodType) && (other.IsDefault == IsDefault);
  57.         }
  58.        
  59.         /// <internalonly/>
  60.         public override int GetHashCode()
  61.         {
  62.             return ((int)_methodType).GetHashCode() ^ _isDefault.GetHashCode();
  63.         }
  64.        
  65.         /// <internalonly/>
  66.         public override bool Match(object obj)
  67.         {
  68.             if (obj == this) {
  69.                 return true;
  70.             }
  71.            
  72.             DataObjectMethodAttribute other = obj as DataObjectMethodAttribute;
  73.             return (other != null) && (other.MethodType == MethodType);
  74.         }
  75.     }
  76. }

Developer Fusion