Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ClassCache< T > Class Template Reference

Public Member Functions

Create< T2 > (Type type)
 
Create< T2 > (string id, string assembly)
 

Static Public Member Functions

static T Create< T > (string id, string assembly="Assembly-CSharp")
 

Public Attributes

Dictionary< string, Func< T > > dict = new Dictionary<string, Func<T>>()
 

Static Public Attributes

static ClassCache< object > caches = new ClassCache<object>()
 
static HashSet< string > assemblies = new HashSet<string>()
 

Detailed Description

Definition at line 6 of file ClassCache.cs.

Member Function Documentation

◆ Create< T >()

static T ClassCache< T >.Create< T > ( string  id,
string  assembly = "Assembly-CSharp" 
)
inlinestatic

Definition at line 54 of file ClassCache.cs.

55 {
56 return (T)caches.Create<T>(id, assembly);
57 }
static ClassCache< object > caches
Definition: ClassCache.cs:50

References ClassCache< T >.caches.

◆ Create< T2 >() [1/2]

T ClassCache< T >.Create< T2 > ( string  id,
string  assembly 
)
inline

Definition at line 31 of file ClassCache.cs.

32 {
33 Type type = Type.GetType(id + ", " + assembly);
34 if (type == null)
35 {
36 foreach (string assembly2 in ClassCache.assemblies)
37 {
38 type = Type.GetType(id + ", " + assembly2);
39 if (type != null)
40 {
41 break;
42 }
43 }
44 }
45 return Create<T2>(type);
46 }
static HashSet< string > assemblies
Definition: ClassCache.cs:52
T Create< T2 >(Type type)
Definition: ClassCache.cs:10

References ClassCache< T >.assemblies, and ClassCache< T >.Create< T2 >().

◆ Create< T2 >() [2/2]

T ClassCache< T >.Create< T2 > ( Type  type)
inline

Definition at line 10 of file ClassCache.cs.

11 {
12 if (type == null)
13 {
14 return default(T);
15 }
16 Func<T> func = dict.TryGetValue(type.Name);
17 if (func != null)
18 {
19 return func();
20 }
21 ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
22 if (constructor == null)
23 {
24 return default(T);
25 }
26 func = Expression.Lambda<Func<T>>(Expression.New(constructor), Array.Empty<ParameterExpression>()).Compile();
27 dict.Add(type.Name, func);
28 return func();
29 }
Dictionary< string, Func< T > > dict
Definition: ClassCache.cs:8

References ClassCache< T >.dict.

Referenced by ClassCache< T >.Create< T2 >().

Member Data Documentation

◆ assemblies

HashSet<string> ClassCache< T >.assemblies = new HashSet<string>()
static

Definition at line 52 of file ClassCache.cs.

Referenced by ClassCache< T >.Create< T2 >(), and Core.StartCase().

◆ caches

ClassCache<object> ClassCache< T >.caches = new ClassCache<object>()
static

Definition at line 50 of file ClassCache.cs.

Referenced by ClassCache< T >.Create< T >().

◆ dict

Dictionary<string, Func<T> > ClassCache< T >.dict = new Dictionary<string, Func<T>>()

Definition at line 8 of file ClassCache.cs.

Referenced by ClassCache< T >.Create< T2 >().


The documentation for this class was generated from the following file: