CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ServiceProviderMethodInfo.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ServiceProviderMethodInfo.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Class that contains cached metadata about data portal</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Linq;
11using System.Reflection;
12using System.Text;
13using System.Threading.Tasks;
14using Csla.Server;
15
16namespace Csla.Reflection
17{
23 {
24 private bool _initialized;
25
29 public System.Reflection.MethodInfo MethodInfo { get; set; }
34 public DynamicMethodDelegate DynamicMethod { get; private set; }
38 public ParameterInfo[] Parameters { get; private set; }
43 public bool TakesParamArray { get; private set; }
48 public bool[] IsInjected { get; private set; }
53 public bool IsAsyncTask { get; private set; }
58 public bool IsAsyncTaskObject { get; set; }
62 internal DataPortalMethodInfo DataPortalMethodInfo { get; private set; }
63
68 public void PrepForInvocation()
69 {
70 if (!_initialized)
71 {
72 lock (MethodInfo)
73 {
74 if (!_initialized)
75 {
76 DynamicMethod = DynamicMethodHandlerFactory.CreateMethod(MethodInfo);
77 Parameters = MethodInfo.GetParameters();
78 TakesParamArray = (Parameters.Length == 1 && Parameters[0].ParameterType.Equals(typeof(object[])));
79 IsInjected = new bool[Parameters.Length];
80
81 int index = 0;
82 foreach (var item in Parameters)
83 {
84 if (item.GetCustomAttributes<InjectAttribute>().Any())
85 IsInjected[index] = true;
86 index++;
87 }
88 IsAsyncTask = (MethodInfo.ReturnType == typeof(Task));
89 IsAsyncTaskObject = (MethodInfo.ReturnType.IsGenericType && (MethodInfo.ReturnType.GetGenericTypeDefinition() == typeof(Task<>)));
90 DataPortalMethodInfo = new DataPortalMethodInfo(MethodInfo);
91
92 _initialized = true;
93 }
94 }
95 }
96 }
97 }
98}
Specifies a parameter that is provided via dependency injection.
Maintains metadata about a method.
Definition: MethodInfo.cs:19
Class that contains cached metadata about data portal method to be invoked
System.Reflection.MethodInfo MethodInfo
Gets or sets the MethodInfo object for the method
bool IsAsyncTaskObject
Gets a value indicating whether the method returns a Task of T
bool TakesParamArray
Gets a value indicating whether the method takes a param array as its parameter
void PrepForInvocation()
Initializes and caches the metastate values necessary to invoke the method
DynamicMethodDelegate DynamicMethod
Gets delegate representing an expression that can invoke the method
bool[] IsInjected
Gets an array of values indicating which parameters need to be injected
ParameterInfo[] Parameters
Gets the parameters for the method
bool IsAsyncTask
Gets a value indicating whether the method returns type Task
delegate object DynamicMethodDelegate(object target, object[] args)
Delegate for a dynamic method.