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