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

  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. // Makes a PropertyInfo look like a FieldInfo for use in compiled with statements
  16. namespace Microsoft.JScript
  17. {
  18.    
  19.     using System;
  20.     using System.Globalization;
  21.     using System.Reflection;
  22.    
  23.     internal sealed class JSPropertyField : JSField
  24.     {
  25.         internal PropertyInfo wrappedProperty;
  26.         internal object wrappedObject;
  27.        
  28.         internal JSPropertyField(PropertyInfo field, object obj)
  29.         {
  30.             this.wrappedProperty = field;
  31.             this.wrappedObject = obj;
  32.         }
  33.        
  34.         public override string Name {
  35.             get { return this.wrappedProperty.Name; }
  36.         }
  37.        
  38.         public override FieldAttributes Attributes {
  39.             get { return FieldAttributes.Public; }
  40.         }
  41.        
  42.         public override Type DeclaringType {
  43.             get { return this.wrappedProperty.DeclaringType; }
  44.         }
  45.        
  46.         public override Type FieldType {
  47.             get { return this.wrappedProperty.PropertyType; }
  48.         }
  49.        
  50.         public override object GetValue(object obj)
  51.         {
  52.             return this.wrappedProperty.GetValue(this.wrappedObject, new object[0]);
  53.         }
  54.        
  55.         public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo locale)
  56.         {
  57.             this.wrappedProperty.SetValue(this.wrappedObject, value, invokeAttr, binder, new object[0], locale);
  58.         }
  59.     }
  60. }

Developer Fusion