Esempio n. 1
0
        public GrpcClient(
            GrpcOptions options,
            GrpcServiceCallBuilder serviceCallBuilder,
            IBinarySerializer binarySerializer)
        {
            _options = options;

            ID             = Guid.NewGuid();
            GrpcServiceDic = new Dictionary <Type, Type>();
            var namespaces = $"Kadder.Client.Services";

            _codeBuilder = new CodeBuilder(namespaces, namespaces);
            var grpcServiceDic = serviceCallBuilder
                                 .GenerateHandler(_options, this, ref _codeBuilder);

            _codeAssembly     = _codeBuilder.BuildAsync().Result;
            _binarySerializer = binarySerializer;

            GrpcClientExtension.ClientDic.Add(ID.ToString(), this);
            foreach (var item in grpcServiceDic)
            {
                var type = _codeAssembly.Assembly.GetType(item.Value);
                GrpcServiceDic.Add(item.Key, type);
            }
        }
Esempio n. 2
0
        public GrpcClient(GrpcClientMetadata metadata, GrpcClientBuilder builder, GrpcServiceCallBuilder serviceCallBuilder)
        {
            _clientBuilder     = builder;
            _metadata          = metadata;
            _options           = metadata.Options;
            ID                 = Guid.NewGuid();
            _lastConnectedTime = DateTime.Now;
            GrpcServiceDic     = new Dictionary <Type, Type>();
            _oldMethodDic      = new Dictionary <string, string>();
            var namespaces = $"Kadder.Client.Services";

            _codeBuilder = new CodeBuilder(namespaces, namespaces);

            var grpcServiceDic = serviceCallBuilder.GenerateHandler(_options, this, ref _codeBuilder);

            _codeAssembly = _codeBuilder.BuildAsync().Result;
            GrpcClientExtension.ClientDic.Add(ID.ToString(), this);
            foreach (var keyValuePair in grpcServiceDic)
            {
                var type = _codeAssembly.Assembly.GetType(keyValuePair.Value);
                GrpcServiceDic.Add(keyValuePair.Key, type);
            }
        }