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

  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.Class)]
  24.     public sealed class DataObjectAttribute : Attribute
  25.     {
  26.        
  27.         public static readonly DataObjectAttribute DataObject = new DataObjectAttribute(true);
  28.        
  29.         public static readonly DataObjectAttribute NonDataObject = new DataObjectAttribute(false);
  30.        
  31.         public static readonly DataObjectAttribute Default = NonDataObject;
  32.        
  33.         private bool _isDataObject;
  34.        
  35.         public DataObjectAttribute() : this(true)
  36.         {
  37.         }
  38.        
  39.         public DataObjectAttribute(bool isDataObject)
  40.         {
  41.             _isDataObject = isDataObject;
  42.         }
  43.        
  44.         public bool IsDataObject {
  45.             get { return _isDataObject; }
  46.         }
  47.        
  48.         /// <internalonly/>
  49.         public override bool Equals(object obj)
  50.         {
  51.             if (obj == this) {
  52.                 return true;
  53.             }
  54.            
  55.             DataObjectAttribute other = obj as DataObjectAttribute;
  56.             return (other != null) && (other.IsDataObject == IsDataObject);
  57.         }
  58.        
  59.         /// <internalonly/>
  60.         public override int GetHashCode()
  61.         {
  62.             return _isDataObject.GetHashCode();
  63.         }
  64.        
  65.         /// <internalonly/>
  66.         public override bool IsDefaultAttribute()
  67.         {
  68.             return (this.Equals(Default));
  69.         }
  70.     }
  71. }

Developer Fusion