/// <summary> /// 返回创建的接口的代理代理类型 /// </summary> /// <param name="interfaceType">接口类型</param> /// <param name="apiMethods">接口方法集合</param> /// <returns></returns> private static Type BuildProxyType(Type interfaceType, MethodInfo[] apiMethods) { var moduleName = interfaceType.GetTypeInfo().Module.Name; var assemblyName = new AssemblyName(Guid16.NewGuid16().ToString()); var module = AssemblyBuilder .DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run) .DefineDynamicModule(moduleName); var builder = module.DefineType(interfaceType.FullName, TypeAttributes.Class, typeof(HttpApi)); builder.AddInterfaceImplementation(interfaceType); var fieldInterceptor = BuildField(builder, "interceptor", typeof(IApiInterceptor)); var fieldApiMethods = BuildField(builder, "apiMethods", typeof(MethodInfo[])); BuildCtor(builder, fieldInterceptor, fieldApiMethods); BuildMethods(builder, apiMethods, fieldInterceptor, fieldApiMethods); return(builder.CreateTypeInfo().AsType()); }
/// <summary> /// form-data表单 /// </summary> public MultipartFormContent() : this(Guid16.NewGuid16().ToString()) { }