|
static T | Create< T > (string id, string assembly="Assembly-CSharp") |
|
|
Dictionary< string, Func< T > > | dict = new Dictionary<string, Func<T>>() |
|
Definition at line 6 of file ClassCache.cs.
◆ Create< T >()
static T ClassCache< T >.Create< T > |
( |
string |
id, |
|
|
string |
assembly = "Assembly-CSharp" |
|
) |
| |
|
inlinestatic |
◆ 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 {
37 {
38 type = Type.GetType(id + ", " + assembly2);
39 if (type != null)
40 {
41 break;
42 }
43 }
44 }
46 }
static HashSet< string > assemblies
T Create< T2 >(Type type)
References ClassCache< T >.assemblies, and ClassCache< T >.Create< T2 >().
◆ Create< T2 >() [2/2]
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
References ClassCache< T >.dict.
Referenced by ClassCache< T >.Create< T2 >().
◆ assemblies
HashSet<string> ClassCache< T >.assemblies = new HashSet<string>() |
|
static |
◆ caches
◆ dict
Dictionary<string, Func<T> > ClassCache< T >.dict = new Dictionary<string, Func<T>>() |
The documentation for this class was generated from the following file: