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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DataObjectFieldAttribute.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.     /// Represents a field of a DataObject. Use this attribute on a field to indicate
  23.     /// properties such as primary key, identity, nullability, and length.
  24.     /// </devdoc>
  25.     [AttributeUsage(AttributeTargets.Property)]
  26.     public sealed class DataObjectFieldAttribute : Attribute
  27.     {
  28.         private bool _primaryKey;
  29.         private bool _isIdentity;
  30.         private bool _isNullable;
  31.         private int _length;
  32.        
  33.         public DataObjectFieldAttribute(bool primaryKey) : this(primaryKey, false, false, -1)
  34.         {
  35.         }
  36.        
  37.         public DataObjectFieldAttribute(bool primaryKey, bool isIdentity) : this(primaryKey, isIdentity, false, -1)
  38.         {
  39.         }
  40.        
  41.         public DataObjectFieldAttribute(bool primaryKey, bool isIdentity, bool isNullable) : this(primaryKey, isIdentity, isNullable, -1)
  42.         {
  43.         }
  44.        
  45.         public DataObjectFieldAttribute(bool primaryKey, bool isIdentity, bool isNullable, int length)
  46.         {
  47.             _primaryKey = primaryKey;
  48.             _isIdentity = isIdentity;
  49.             _isNullable = isNullable;
  50.             _length = length;
  51.         }
  52.        
  53.         public bool IsIdentity {
  54.             get { return _isIdentity; }
  55.         }
  56.        
  57.         public bool IsNullable {
  58.             get { return _isNullable; }
  59.         }
  60.        
  61.         public int Length {
  62.             get { return _length; }
  63.         }
  64.        
  65.         public bool PrimaryKey {
  66.             get { return _primaryKey; }
  67.         }
  68.        
  69.         public override bool Equals(object obj)
  70.         {
  71.             if (obj == this) {
  72.                 return true;
  73.             }
  74.            
  75.             DataObjectFieldAttribute other = obj as DataObjectFieldAttribute;
  76.             return (other != null) && (other.IsIdentity == IsIdentity) && (other.IsNullable == IsNullable) && (other.Length == Length) && (other.PrimaryKey == PrimaryKey);
  77.         }
  78.        
  79.         public override int GetHashCode()
  80.         {
  81.             return base.GetHashCode();
  82.         }
  83.     }
  84. }

Developer Fusion