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

◆ ClassRegistrationScenarioForType()

static void Internal.Runtime.InteropServices.ComActivator.ClassRegistrationScenarioForType ( ComActivationContext cxt,
bool register )
inlinestatic

Definition at line 177 of file ComActivator.cs.

178 {
180 {
182 }
183 string text = (register ? "ComRegisterFunctionAttribute" : "ComUnregisterFunctionAttribute");
184 Type type = Type.GetType("System.Runtime.InteropServices." + text + ", System.Runtime.InteropServices", throwOnError: false);
185 if (type == null)
186 {
187 return;
188 }
189 if (!Path.IsPathRooted(cxt.AssemblyPath))
190 {
191 throw new ArgumentException(null, "cxt");
192 }
193 Type type2 = FindClassType(cxt.ClassId, cxt.AssemblyPath, cxt.AssemblyName, cxt.TypeName);
194 Type type3 = type2;
195 bool flag = false;
196 while (type3 != null && !flag)
197 {
198 MethodInfo[] methods = type3.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
200 foreach (MethodInfo methodInfo in array)
201 {
202 if (methodInfo.GetCustomAttributes(type, inherit: true).Length != 0)
203 {
204 if (!methodInfo.IsStatic)
205 {
206 string resourceFormat = (register ? SR.InvalidOperation_NonStaticComRegFunction : SR.InvalidOperation_NonStaticComUnRegFunction);
208 }
209 ParameterInfo[] parameters = methodInfo.GetParameters();
210 if (methodInfo.ReturnType != typeof(void) || parameters == null || parameters.Length != 1 || (parameters[0].ParameterType != typeof(string) && parameters[0].ParameterType != typeof(Type)))
211 {
212 string resourceFormat2 = (register ? SR.InvalidOperation_InvalidComRegFunctionSig : SR.InvalidOperation_InvalidComUnRegFunctionSig);
214 }
215 if (flag)
216 {
217 string resourceFormat3 = (register ? SR.InvalidOperation_MultipleComRegFunctions : SR.InvalidOperation_MultipleComUnRegFunctions);
219 }
220 object[] array2 = new object[1];
221 if (parameters[0].ParameterType == typeof(string))
222 {
223 array2[0] = $"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\{cxt.ClassId:B}";
224 }
225 else
226 {
227 array2[0] = type2;
228 }
229 methodInfo.Invoke(null, array2);
230 flag = true;
231 }
232 }
233 type3 = type3.BaseType;
234 }
235 }
static Type FindClassType(Guid clsid, string assemblyPath, string assemblyName, string typeName)
static bool IsPathRooted([NotNullWhen(true)] string? path)
Definition Path.cs:985
static string NotSupported_COM
Definition SR.cs:2190
static string InvalidOperation_MultipleComUnRegFunctions
Definition SR.cs:2128
static string InvalidOperation_NonStaticComUnRegFunction
Definition SR.cs:2120
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string InvalidOperation_InvalidComUnRegFunctionSig
Definition SR.cs:2124
Definition SR.cs:7
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408

References System.array, Internal.Runtime.InteropServices.ComActivator.FindClassType(), System.SR.Format(), System.Type.GetType(), System.SR.InvalidOperation_InvalidComUnRegFunctionSig, System.SR.InvalidOperation_MultipleComUnRegFunctions, System.SR.InvalidOperation_NonStaticComUnRegFunction, System.Runtime.InteropServices.Marshal.IsBuiltInComSupported, System.IO.Path.IsPathRooted(), System.SR.NotSupported_COM, System.Reflection.ParameterInfo.ParameterType, System.text, and System.type.

Referenced by Internal.Runtime.InteropServices.ComActivator.RegisterClassForTypeInternal(), and Internal.Runtime.InteropServices.ComActivator.UnregisterClassForTypeInternal().