Elin Decompiled Documentation EA 23.286 Nightly Patch 1
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 59 of file ClassCache.cs.

60 {
61 return (T)caches.Create<T>(id, assembly);
62 }
static ClassCache< object > caches
Definition: ClassCache.cs:55

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 Func<T> func = dict.TryGetValue(id);
34 if (func != null)
35 {
36 return func();
37 }
38 Type type = Type.GetType(id + ", " + assembly);
39 if (type == null)
40 {
41 foreach (string assembly2 in ClassCache.assemblies)
42 {
43 type = Type.GetType(id + ", " + assembly2);
44 if (type != null)
45 {
46 break;
47 }
48 }
49 }
50 return Create<T2>(type);
51 }
static HashSet< string > assemblies
Definition: ClassCache.cs:57
T Create< T2 >(Type type)
Definition: ClassCache.cs:10
Dictionary< string, Func< T > > dict
Definition: ClassCache.cs:8

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

◆ 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 }

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 57 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 55 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: