Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CallStartupHook()

static void System.StartupHookProvider.CallStartupHook ( StartupHookNameOrPath startupHook)
inlinestaticprivate

Definition at line 94 of file StartupHookProvider.cs.

95 {
96 Assembly assembly;
97 try
98 {
99 if (startupHook.Path != null)
100 {
101 assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(startupHook.Path);
102 }
103 else
104 {
105 if (startupHook.AssemblyName == null)
106 {
107 return;
108 }
109 assembly = AssemblyLoadContext.Default.LoadFromAssemblyName(startupHook.AssemblyName);
110 }
111 }
112 catch (Exception innerException)
113 {
114 throw new ArgumentException(SR.Format(SR.Argument_StartupHookAssemblyLoadFailed, startupHook.Path ?? startupHook.AssemblyName.ToString()), innerException);
115 }
116 Type type = assembly.GetType("StartupHook", throwOnError: true);
117 MethodInfo method = type.GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
118 bool flag = false;
119 if (method == null)
120 {
121 try
122 {
123 method = type.GetMethod("Initialize", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
124 }
126 {
127 }
128 if (!(method != null))
129 {
130 throw new MissingMethodException("StartupHook", "Initialize");
131 }
132 flag = true;
133 }
134 else if (method.ReturnType != typeof(void))
135 {
136 flag = true;
137 }
138 if (flag)
139 {
140 throw new ArgumentException(SR.Format(SR.Argument_InvalidStartupHookSignature, "StartupHook" + Type.Delimiter + "Initialize", startupHook.Path ?? startupHook.AssemblyName.ToString()));
141 }
142 method.Invoke(null, null);
143 }
virtual ? Type GetType(string name)
Definition Assembly.cs:305
object? Invoke(object? obj, object?[]? parameters)

References System.SR.Argument_InvalidStartupHookSignature, System.SR.Argument_StartupHookAssemblyLoadFailed, System.StartupHookProvider.StartupHookNameOrPath.AssemblyName, System.Runtime.Loader.AssemblyLoadContext.Default, System.Type.Delimiter, System.Type.EmptyTypes, System.SR.Format(), System.Reflection.Assembly.GetType(), System.Reflection.MethodBase.Invoke(), System.StartupHookProvider.StartupHookNameOrPath.Path, System.Reflection.MethodInfo.ReturnType, System.Reflection.AssemblyName.ToString(), and System.type.

Referenced by System.StartupHookProvider.ProcessStartupHooks().