Exemple #1
0
        public GrpcClientMetadata RegClient(GrpcClientOptions options)
        {
            var metadata = new GrpcClientMetadata(options);

            ClientMetadatas.Add(metadata);
            return(metadata);
        }
Exemple #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);
            }
        }