Fix bugs in sizing TableLayoutPanel (Xamarin bug 18638)
[mono.git] / mcs / class / System.ComponentModel.Composition / src / ComponentModel / System / ComponentModel / Composition / ReflectionModel / ReflectionMethod.cs
1 // -----------------------------------------------------------------------\r
2 // Copyright (c) Microsoft Corporation.  All rights reserved.\r
3 // -----------------------------------------------------------------------\r
4 using System;\r
5 using System.ComponentModel.Composition.Hosting;\r
6 using System.Reflection;\r
7 using Microsoft.Internal;\r
8 using System.Threading;\r
9 using System.ComponentModel.Composition.Primitives;\r
10 \r
11 namespace System.ComponentModel.Composition.ReflectionModel\r
12 {\r
13     internal partial class ReflectionMethod : ReflectionMember\r
14     {\r
15         private readonly MethodInfo _method;\r
16 \r
17         public ReflectionMethod(MethodInfo method)\r
18         {\r
19             Assumes.NotNull(method);\r
20 \r
21             this._method = method;\r
22         }\r
23 \r
24         public MethodInfo UnderlyingMethod\r
25         {\r
26             get { return this._method; }\r
27         }\r
28 \r
29         public override MemberInfo UnderlyingMember\r
30         {\r
31             get { return this.UnderlyingMethod; }\r
32         }\r
33 \r
34         public override bool CanRead\r
35         {\r
36             get { return true; }\r
37         }\r
38 \r
39         public override bool RequiresInstance\r
40         {\r
41             get { return !this.UnderlyingMethod.IsStatic; }\r
42         }\r
43 \r
44         public override Type ReturnType\r
45         {\r
46             get { return this.UnderlyingMethod.ReturnType; }\r
47         }\r
48 \r
49         public override ReflectionItemType ItemType\r
50         {\r
51             get { return ReflectionItemType.Method; }\r
52         }\r
53 \r
54         public override object GetValue(object instance)\r
55         {\r
56             return SafeCreateExportedDelegate(instance, _method);\r
57         }\r
58 #if !SILVERLIGHT\r
59         [System.Security.SecuritySafeCritical]\r
60 #endif\r
61         private static ExportedDelegate SafeCreateExportedDelegate(object instance, MethodInfo method)\r
62         {\r
63             // We demand member access in place of the [SecurityCritical] \r
64             // attribute on ExportDelegate constructor\r
65             ReflectionInvoke.DemandMemberAccessIfNeeded(method);\r
66 \r
67             return new ExportedDelegate(instance, method);\r
68         }\r
69     }\r
70 }\r