示例#1
0
        public ProxyBase(ProxyBase proxy)
        {
            if (proxy == null)
            {
                throw new ArgumentNullException(nameof(proxy));
            }

            State     = ProxyState.Ready;
            _contract = proxy.Contract;
            _pipeline = proxy.Pipeline;
        }
示例#2
0
        protected ProxyBase(ProxyBase proxy)
        {
            if (proxy == null)
            {
                throw new ArgumentNullException(nameof(proxy));
            }

            Contract = proxy.Contract;
            _pipeline = proxy.Pipeline;
            State = proxy.State;
        }
示例#3
0
        public T CreateProxy <T>(IClientPipeline pipeline) where T : class
        {
            ContractMetadata contract = BoltFramework.GetContract(typeof(T));
            var interceptor           = new ChannelInterceptor();
            var options = new ProxyGenerationOptions
            {
                BaseTypeForInterfaceProxy = _baseProxy
            };

            ProxyMetadata metadata = _metadatas.GetOrAdd(typeof(T), v => new ProxyMetadata(_baseProxy));
            var           proxy    = _generator.CreateInterfaceProxyWithoutTarget <T>(
                options,
                interceptor);

            ProxyBase proxyBase = (ProxyBase)(object)proxy;

            proxyBase.Contract = contract;
            proxyBase.Pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline));

            interceptor.Proxy    = proxyBase;
            interceptor.Metadata = metadata;
            return(proxy);
        }