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

  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 sealed class VBArrayConstructor : ScriptFunction
  21.     {
  22.         static internal readonly VBArrayConstructor ob = new VBArrayConstructor();
  23.        
  24.         private VBArrayPrototype originalPrototype;
  25.        
  26.         internal VBArrayConstructor() : base(FunctionPrototype.ob, "VBArray", 1)
  27.         {
  28.             this.originalPrototype = VBArrayPrototype.ob;
  29.             VBArrayPrototype._constructor = this;
  30.             this.proto = VBArrayPrototype.ob;
  31.         }
  32.        
  33.         internal VBArrayConstructor(LenientFunctionPrototype parent, LenientVBArrayPrototype prototypeProp) : base(parent, "VBArray", 1)
  34.         {
  35.             this.originalPrototype = prototypeProp;
  36.             prototypeProp.constructor = this;
  37.             this.proto = prototypeProp;
  38.             this.noExpando = false;
  39.         }
  40.        
  41.         internal override object Call(object[] args, object thisob)
  42.         {
  43.             return null;
  44.         }
  45.        
  46.         internal override object Construct(object[] args)
  47.         {
  48.             return this.CreateInstance(args);
  49.         }
  50.        
  51.         //Only to be used for type inference
  52.         internal VBArrayObject Construct()
  53.         {
  54.             return new VBArrayObject(this.originalPrototype, null);
  55.         }
  56.        
  57.         [JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
  58.         public new object CreateInstance(params object[] args)
  59.         {
  60.             if (args.Length < 1 || !typeof(Array).IsAssignableFrom(args[0].GetType()))
  61.                 throw new JScriptException(JSError.VBArrayExpected);
  62.             return new VBArrayObject(this.originalPrototype, (Array)args[0]);
  63.         }
  64.     }
  65. }

Developer Fusion