The Labs \ Source Viewer \ SSCLI \ Microsoft.JScript \ BooleanPrototype

  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. namespace Microsoft.JScript
  16. {
  17.    
  18.     using System;
  19.    
  20.     public class BooleanPrototype : BooleanObject
  21.     {
  22.         static internal readonly BooleanPrototype ob = new BooleanPrototype(ObjectPrototype.ob, typeof(BooleanPrototype));
  23.         static internal BooleanConstructor _constructor;
  24.        
  25.         protected BooleanPrototype(ObjectPrototype parent, Type baseType) : base(parent, baseType)
  26.         {
  27.             this.noExpando = true;
  28.         }
  29.        
  30.         public static BooleanConstructor constructor {
  31.             get { return BooleanPrototype._constructor; }
  32.         }
  33.        
  34.         [JSFunctionAttribute(JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_toString)]
  35.         public static string toString(object thisob)
  36.         {
  37.             if (thisob is BooleanObject)
  38.                 return Convert.ToString(((BooleanObject)thisob).value);
  39.             else if (Convert.GetTypeCode(thisob) == TypeCode.Boolean)
  40.                 return Convert.ToString(thisob);
  41.             throw new JScriptException(JSError.BooleanExpected);
  42.         }
  43.        
  44.         [JSFunctionAttribute(JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_valueOf)]
  45.         public static object valueOf(object thisob)
  46.         {
  47.             if (thisob is BooleanObject)
  48.                 return ((BooleanObject)thisob).value;
  49.             else if (Convert.GetTypeCode(thisob) == TypeCode.Boolean)
  50.                 return thisob;
  51.             throw new JScriptException(JSError.BooleanExpected);
  52.         }
  53.        
  54.     }
  55. }

Developer Fusion