The Labs \ Source Viewer \ SSCLI \ System \ DBNull

  1. // ==++==
  2. //
  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. //
  14. // ==--==
  15. ////////////////////////////////////////////////////////////////////////////////
  16. // Void
  17. // This class represents a Missing Variant
  18. ////////////////////////////////////////////////////////////////////////////////
  19. namespace System
  20. {
  21.    
  22.     using System;
  23.     using System.Runtime.Remoting;
  24.     using System.Runtime.Serialization;
  25.     [System.Runtime.InteropServices.ComVisible(true)]
  26.     [Serializable()]
  27.     public sealed class DBNull : ISerializable, IConvertible
  28.     {
  29.        
  30.         //Package private constructor
  31.         private DBNull()
  32.         {
  33.         }
  34.        
  35.         private DBNull(SerializationInfo info, StreamingContext context)
  36.         {
  37.             throw new NotSupportedException(Environment.GetResourceString("NotSupported_DBNullSerial"));
  38.         }
  39.        
  40.         public static readonly DBNull Value = new DBNull();
  41.        
  42.         public void GetObjectData(SerializationInfo info, StreamingContext context)
  43.         {
  44.             UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.NullUnity, null, null);
  45.         }
  46.        
  47.         public override string ToString()
  48.         {
  49.             return String.Empty;
  50.         }
  51.        
  52.         public string ToString(IFormatProvider provider)
  53.         {
  54.             return String.Empty;
  55.         }
  56.        
  57.         public TypeCode GetTypeCode()
  58.         {
  59.             return TypeCode.DBNull;
  60.         }
  61.        
  62.         /// <internalonly/>
  63.         bool IConvertible.ToBoolean(IFormatProvider provider)
  64.         {
  65.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  66.         }
  67.        
  68.         /// <internalonly/>
  69.         char IConvertible.ToChar(IFormatProvider provider)
  70.         {
  71.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  72.         }
  73.        
  74.         /// <internalonly/>
  75.         sbyte IConvertible.ToSByte(IFormatProvider provider)
  76.         {
  77.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  78.         }
  79.        
  80.         /// <internalonly/>
  81.         byte IConvertible.ToByte(IFormatProvider provider)
  82.         {
  83.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  84.         }
  85.        
  86.         /// <internalonly/>
  87.         short IConvertible.ToInt16(IFormatProvider provider)
  88.         {
  89.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  90.         }
  91.        
  92.         /// <internalonly/>
  93.         ushort IConvertible.ToUInt16(IFormatProvider provider)
  94.         {
  95.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  96.         }
  97.        
  98.         /// <internalonly/>
  99.         int IConvertible.ToInt32(IFormatProvider provider)
  100.         {
  101.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  102.         }
  103.        
  104.         /// <internalonly/>
  105.         uint IConvertible.ToUInt32(IFormatProvider provider)
  106.         {
  107.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  108.         }
  109.        
  110.         /// <internalonly/>
  111.         long IConvertible.ToInt64(IFormatProvider provider)
  112.         {
  113.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  114.         }
  115.        
  116.         /// <internalonly/>
  117.         ulong IConvertible.ToUInt64(IFormatProvider provider)
  118.         {
  119.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  120.         }
  121.        
  122.         /// <internalonly/>
  123.         float IConvertible.ToSingle(IFormatProvider provider)
  124.         {
  125.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  126.         }
  127.        
  128.         /// <internalonly/>
  129.         double IConvertible.ToDouble(IFormatProvider provider)
  130.         {
  131.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  132.         }
  133.        
  134.         /// <internalonly/>
  135.         decimal IConvertible.ToDecimal(IFormatProvider provider)
  136.         {
  137.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  138.         }
  139.        
  140.         /// <internalonly/>
  141.         DateTime IConvertible.ToDateTime(IFormatProvider provider)
  142.         {
  143.             throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull"));
  144.         }
  145.        
  146.         /// <internalonly/>
  147.         object IConvertible.ToType(Type type, IFormatProvider provider)
  148.         {
  149.             return Convert.DefaultToType((IConvertible)this, type, provider);
  150.         }
  151.     }
  152. }

Developer Fusion