The Labs \ Source Viewer \ SSCLI \ System.Reflection \ IReflect

  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. ////////////////////////////////////////////////////////////////////////////////
  17. //
  18. // IReflect is an interface that defines a subset of the Type reflection methods.
  19. // This interface is used to access and invoke members of a Type. It can be either
  20. // type based (like Type) or instance based (like Expando). This interface is used in
  21. // combination with IExpando to model the IDispatchEx expando capibilities in
  22. // the interop layer.
  23. //
  24. // Date: Sep 98
  25. //
  26. namespace System.Reflection
  27. {
  28.     using System;
  29.     using System.Runtime.InteropServices;
  30.     using CultureInfo = System.Globalization.CultureInfo;
  31.    
  32.     // Interface does not need to be marked with the serializable attribute
  33.     [Guid("AFBF15E5-C37C-11d2-B88E-00A0C9B471B8")]
  34.     [System.Runtime.InteropServices.ComVisible(true)]
  35.     public interface IReflect
  36.     {
  37.         // Return the requested method if it is implemented by the Reflection object. The
  38.         // match is based upon the name and DescriptorInfo which describes the signature
  39.         // of the method.
  40.         MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers);
  41.        
  42.         // Return the requested method if it is implemented by the Reflection object. The
  43.         // match is based upon the name of the method. If the object implementes multiple methods
  44.         // with the same name an AmbiguousMatchException is thrown.
  45.         MethodInfo GetMethod(string name, BindingFlags bindingAttr);
  46.        
  47.         MethodInfo[] GetMethods(BindingFlags bindingAttr);
  48.        
  49.         // Return the requestion field if it is implemented by the Reflection object. The
  50.         // match is based upon a name. There cannot be more than a single field with
  51.         // a name.
  52.         FieldInfo GetField(string name, BindingFlags bindingAttr);
  53.        
  54.         FieldInfo[] GetFields(BindingFlags bindingAttr);
  55.        
  56.         // Return the property based upon name. If more than one property has the given
  57.         // name an AmbiguousMatchException will be thrown. Returns null if no property
  58.         // is found.
  59.         PropertyInfo GetProperty(string name, BindingFlags bindingAttr);
  60.        
  61.         // Return the property based upon the name and Descriptor info describing the property
  62.         // indexing. Return null if no property is found.
  63.         PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers);
  64.        
  65.         // Returns an array of PropertyInfos for all the properties defined on
  66.         // the Reflection object.
  67.         PropertyInfo[] GetProperties(BindingFlags bindingAttr);
  68.        
  69.         // Return an array of members which match the passed in name.
  70.         MemberInfo[] GetMember(string name, BindingFlags bindingAttr);
  71.        
  72.         // Return an array of all of the members defined for this object.
  73.         MemberInfo[] GetMembers(BindingFlags bindingAttr);
  74.        
  75.         // Description of the Binding Process.
  76.         // We must invoke a method that is accessable and for which the provided
  77.         // parameters have the most specific match. A method may be called if
  78.         // 1. The number of parameters in the method declaration equals the number of
  79.         // arguments provided to the invocation
  80.         // 2. The type of each argument can be converted by the binder to the
  81.         // type of the type of the parameter.
  82.         //
  83.         // The binder will find all of the matching methods. These method are found based
  84.         // upon the type of binding requested (MethodInvoke, Get/Set Properties). The set
  85.         // of methods is filtered by the name, number of arguments and a set of search modifiers
  86.         // defined in the Binder.
  87.         //
  88.         // After the method is selected, it will be invoked. Accessability is checked
  89.         // at that point. The search may be control which set of methods are searched based
  90.         // upon the accessibility attribute associated with the method.
  91.         //
  92.         // The BindToMethod method is responsible for selecting the method to be invoked.
  93.         // For the default binder, the most specific method will be selected.
  94.         //
  95.         // This will invoke a specific member...
  96.         object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters);
  97.        
  98.         // Return the underlying Type that represents the IReflect Object. For expando object,
  99.         // this is the (Object) IReflectInstance.GetType(). For Type object it is this.
  100.         Type UnderlyingSystemType {
  101.             get;
  102.         }
  103.     }
  104. }

Developer Fusion