private static Type GenerateInterfaceImplementation(ModuleBuilder moduleBuilder) { TypeBuilder type = moduleBuilder.DefineType("Microsoft.AspNetCore.SignalR.TypedClientBuilder." + typeof(T).Name + "Impl", TypeAttributes.Public, typeof(object), new Type[1] { typeof(T) }); FieldBuilder fieldBuilder = type.DefineField("_proxy", typeof(IClientProxy), FieldAttributes.Private); TypedClientBuilder <T> .BuildConstructor(type, (FieldInfo)fieldBuilder); foreach (MethodInfo allInterfaceMethod in TypedClientBuilder <T> .GetAllInterfaceMethods(typeof(T))) { TypedClientBuilder <T> .BuildMethod(type, allInterfaceMethod, (FieldInfo)fieldBuilder); } return((Type)type.CreateTypeInfo()); }
private static IEnumerable <MethodInfo> GetAllInterfaceMethods( Type interfaceType) { Type[] typeArray = interfaceType.GetInterfaces(); int index; for (index = 0; index < typeArray.Length; ++index) { foreach (MethodInfo allInterfaceMethod in TypedClientBuilder <T> .GetAllInterfaceMethods(typeArray[index])) { yield return(allInterfaceMethod); } } typeArray = (Type[])null; MethodInfo[] methodInfoArray = interfaceType.GetMethods(); for (index = 0; index < methodInfoArray.Length; ++index) { yield return(methodInfoArray[index]); } methodInfoArray = (MethodInfo[])null; }