static void LoadDeclaredReaders(AssemblyDefinition currentAssembly, TypeDefinition klass) { // register all the reader in this class. Skip the ones with wrong signature foreach (MethodDefinition method in klass.Methods) { if (method.Parameters.Count != 1) { continue; } if (!method.Parameters[0].ParameterType.Is <NetworkReader>()) { continue; } if (method.ReturnType.Is(typeof(void))) { continue; } if (!method.HasCustomAttribute <System.Runtime.CompilerServices.ExtensionAttribute>()) { continue; } if (method.HasGenericParameters) { continue; } Readers.Register(method.ReturnType, currentAssembly.MainModule.ImportReference(method)); } }
static void LoadReaders(AssemblyDefinition currentAssembly, TypeDefinition klass) { // register all the reader in this class. Skip the ones with wrong signature foreach (MethodDefinition method in klass.Methods) { if (method.Parameters.Count != 1) { continue; } if (method.Parameters[0].ParameterType.FullName != "Mirror.NetworkReader") { continue; } if (method.ReturnType.FullName == "System.Void") { continue; } if (method.GetCustomAttribute("System.Runtime.CompilerServices.ExtensionAttribute") == null) { continue; } Readers.Register(method.ReturnType, currentAssembly.MainModule.ImportReference(method)); } }
private void RegisterReader(MethodInfo method) { if (method.GetParameters().Length != 1) { return; } if (method.GetParameters()[0].ParameterType.FullName != typeof(NetworkReader).FullName) { return; } if (method.ReturnType == typeof(void)) { return; } readers.Register(module.ImportReference(method.ReturnType), module.ImportReference(method)); }