CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
DynamicMethodHandle.cs
Go to the documentation of this file.
1#if !IOS
2//-----------------------------------------------------------------------
3// <copyright file="DynamicMethodHandle.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>no summary</summary>
8//-----------------------------------------------------------------------
9using System;
10using System.Linq;
11using System.Reflection;
12
13namespace Csla.Reflection
14{
15 internal class DynamicMethodHandle
16 {
17 public string MethodName { get; private set; }
18 public DynamicMethodDelegate DynamicMethod { get; private set; }
19 public bool HasFinalArrayParam { get; private set; }
20 public int MethodParamsLength { get; private set; }
21 public Type FinalArrayElementType { get; private set; }
22 public bool IsAsyncTask { get; private set; }
23 public bool IsAsyncTaskObject { get; private set; }
24
25 public DynamicMethodHandle(System.Reflection.MethodInfo info, params object[] parameters)
26 {
27 if (info == null)
28 {
29 this.DynamicMethod = null;
30 }
31 else
32 {
33 this.MethodName = info.Name;
34 var infoParams = info.GetParameters();
35 object[] inParams = null;
36 if (parameters == null)
37 {
38 inParams = new object[] { null };
39
40 }
41 else
42 {
43 inParams = parameters;
44 }
45 var pCount = infoParams.Length;
46#if NETFX_CORE
47 var isgeneric = info.ReturnType.IsGenericType();
48 if (pCount > 0 &&
49 ((pCount == 1 && infoParams[0].ParameterType.IsArray) ||
50 (infoParams[pCount - 1].GetCustomAttributes(typeof(ParamArrayAttribute), true).Count() > 0)))
51#else
52 var isgeneric = info.ReturnType.IsGenericType;
53 if (pCount > 0 &&
54 ((pCount == 1 && infoParams[0].ParameterType.IsArray) ||
55 (infoParams[pCount - 1].GetCustomAttributes(typeof(ParamArrayAttribute), true).Length > 0)))
56#endif
57 {
58 this.HasFinalArrayParam = true;
59 this.MethodParamsLength = pCount;
60 this.FinalArrayElementType = infoParams[pCount - 1].ParameterType;
61 }
62 IsAsyncTask = (info.ReturnType == typeof(System.Threading.Tasks.Task));
63 IsAsyncTaskObject = (isgeneric && (info.ReturnType.GetGenericTypeDefinition() == typeof(System.Threading.Tasks.Task<>)));
64 this.DynamicMethod = DynamicMethodHandlerFactory.CreateMethod(info);
65 }
66 }
67 }
68}
69#endif
delegate object DynamicMethodDelegate(object target, object[] args)
Delegate for a dynamic method.