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.
DataPortalMethodCache.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DataPortalMethodCache.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6//-----------------------------------------------------------------------
7using System;
8using System.Collections.Generic;
9using Csla.Reflection;
10
11namespace Csla.Server
12{
13 internal static class DataPortalMethodCache
14 {
15 private static Dictionary<MethodCacheKey, DataPortalMethodInfo> _cache =
16 new Dictionary<MethodCacheKey, DataPortalMethodInfo>();
17
18 public static DataPortalMethodInfo GetMethodInfo(Type objectType, string methodName, params object[] parameters)
19 {
20 var key = new MethodCacheKey(objectType.FullName, methodName, MethodCaller.GetParameterTypes(parameters));
21 DataPortalMethodInfo result = null;
22 var found = false;
23 try
24 {
25 found = _cache.TryGetValue(key, out result);
26 }
27 catch
28 { /* failure will drop into !found block */ }
29 if (!found)
30 {
31 lock (_cache)
32 {
33 if (!_cache.TryGetValue(key, out result))
34 {
35 result = new DataPortalMethodInfo(MethodCaller.GetMethod(objectType, methodName, parameters));
36 _cache.Add(key, result);
37 }
38 }
39 }
40 return result;
41 }
42 }
43}