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

Public Member Functions

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

Static Public Member Functions

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

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>()
 
static List< Func< string, Type > > typeLoaders = new List<Func<string, Type>> { LoadTypeFromGlobalNamespace }
 
static HashSet< Type > modTypes = new HashSet<Type>()
 

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 60 of file ClassCache.cs.

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

References ClassCache< T >.caches.

◆ Create< T2 >()

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

Definition at line 25 of file ClassCache.cs.

26 {
27 id = id.Trim();
28 Func<T> func = dict.TryGetValue(id);
29 if (func != null)
30 {
31 return func();
32 }
33 Type type = Type.GetType(id + ", " + assembly);
34 if (type == null)
35 {
36 for (int num = ClassCache.typeLoaders.Count - 1; num >= 0; num--)
37 {
38 type = ClassCache.typeLoaders[num](id);
39 if (type != null)
40 {
41 break;
42 }
43 }
44 }
45 func = CreateDelegate(type);
46 dict[id] = func;
47 return func();
48 }
Func< T > CreateDelegate(Type type)
Definition: ClassCache.cs:10
static List< Func< string, Type > > typeLoaders
Definition: ClassCache.cs:56
Dictionary< string, Func< T > > dict
Definition: ClassCache.cs:8

References ClassCache< T >.CreateDelegate(), ClassCache< T >.dict, and ClassCache< T >.typeLoaders.

◆ CreateDelegate()

Func< T > ClassCache< T >.CreateDelegate ( Type  type)
inline

Definition at line 10 of file ClassCache.cs.

11 {
12 Func<T> result = () => default(T);
13 if (type == null)
14 {
15 return result;
16 }
17 ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
18 if (constructor != null)
19 {
20 result = Expression.Lambda<Func<T>>(Expression.New(constructor), Array.Empty<ParameterExpression>()).Compile();
21 }
22 return result;
23 }

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

◆ LoadTypeFromGlobalNamespace()

static Type ClassCache< T >.LoadTypeFromGlobalNamespace ( string  id)
inlinestatic

Definition at line 65 of file ClassCache.cs.

66 {
67 foreach (string assembly in assemblies)
68 {
69 Type type = Type.GetType(id + ", " + assembly);
70 if (type != null)
71 {
72 return type;
73 }
74 }
75 return null;
76 }
static HashSet< string > assemblies
Definition: ClassCache.cs:54

References ClassCache< T >.assemblies.

Member Data Documentation

◆ assemblies

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

Definition at line 54 of file ClassCache.cs.

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

◆ caches

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

Definition at line 52 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 >().

◆ modTypes

HashSet<Type> ClassCache< T >.modTypes = new HashSet<Type>()
static

Definition at line 58 of file ClassCache.cs.

◆ typeLoaders

List<Func<string, Type> > ClassCache< T >.typeLoaders = new List<Func<string, Type>> { LoadTypeFromGlobalNamespace }
static

Definition at line 56 of file ClassCache.cs.

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


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