static NetCore50Utils()
        {
            var assembly = ResourceAssemblyLoader.Load(Library);

            var handlerTunerType = assembly.GetType($"{Namespace}.SocketsHttpHandlerTuner");

            var handlerTunerMethod = handlerTunerType.GetMethod("Tune", BindingFlags.Public | BindingFlags.Static);

            var handlerParameter = Expression.Parameter(typeof(HttpMessageHandler));

            tuning = Expression.Lambda <Action <HttpMessageHandler> >(Expression.Call(handlerTunerMethod, handlerParameter), handlerParameter)
                     .Compile();
        }
        static NetCore21Utils()
        {
            var assembly = ResourceAssemblyLoader.Load(Library);

            var handlerFactoryType = assembly.GetType($"{Namespace}.SocketsHttpHandlerFactory");

            var handlerFactoryMethod = handlerFactoryType.GetMethod("Create", BindingFlags.Public | BindingFlags.Static);

            var proxyParameter                      = Expression.Parameter(typeof(IWebProxy));
            var redirectParameter                   = Expression.Parameter(typeof(bool));
            var timeoutParameter                    = Expression.Parameter(typeof(TimeSpan));
            var idleTimeoutParameter                = Expression.Parameter(typeof(TimeSpan));
            var lifetimeParameter                   = Expression.Parameter(typeof(TimeSpan));
            var maxConnectionsParameter             = Expression.Parameter(typeof(int));
            var certificatesParameter               = Expression.Parameter(typeof(X509Certificate2[]));
            var remoteCertificateValidationCallback = Expression.Parameter(typeof(RemoteCertificateValidationCallback));

            socketHandlerFactory = Expression.Lambda <HandlerFactoryFunc>(
                Expression.Call(
                    handlerFactoryMethod,
                    proxyParameter,
                    redirectParameter,
                    timeoutParameter,
                    idleTimeoutParameter,
                    lifetimeParameter,
                    maxConnectionsParameter,
                    certificatesParameter,
                    remoteCertificateValidationCallback),
                proxyParameter,
                redirectParameter,
                timeoutParameter,
                idleTimeoutParameter,
                lifetimeParameter,
                maxConnectionsParameter,
                certificatesParameter,
                remoteCertificateValidationCallback)
                                   .Compile();

            SocketHandlerType = (Type)handlerFactoryType.GetProperty("SocketHandlerType")?.GetValue(null);
        }
Ejemplo n.º 3
0
        static NetCore20Utils()
        {
            var assembly = ResourceAssemblyLoader.Load(Library);

            methodGeneratorType = assembly.GetType($"{Namespace}.MethodGenerator");
        }