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

  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. //Nothing more than a box for a value. Used to store the values of expando properties.
  16. //Kept lightweight because there are many of them and they are not used at compile time.
  17. namespace Microsoft.JScript
  18. {
  19.    
  20.     using System;
  21.     using System.Globalization;
  22.     using System.Reflection;
  23.    
  24.     internal sealed class JSExpandoField : JSField
  25.     {
  26.         private object value;
  27.         private string name;
  28.        
  29.         internal JSExpandoField(string name) : this(name, null)
  30.         {
  31.         }
  32.        
  33.         internal JSExpandoField(string name, object value)
  34.         {
  35.             this.value = value;
  36.             this.name = name;
  37.         }
  38.        
  39.         public override FieldAttributes Attributes {
  40.             get { return FieldAttributes.Public | FieldAttributes.Static; }
  41.         }
  42.        
  43.         public override object GetValue(object obj)
  44.         {
  45.             return this.value;
  46.         }
  47.        
  48.         public override string Name {
  49.             get { return this.name; }
  50.         }
  51.        
  52.         public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo locale)
  53.         {
  54.             this.value = value;
  55.         }
  56.     }
  57. }

Developer Fusion