Exemple #1
0
        public void BeforeAllTests()
        {
            var description = new ContractDescription(typeof(ISomeContract));

            var moduleBuilder = ProxyAssembly.CreateModule(nameof(EmitClientBuilderBuilderTest));

            _sut         = new EmitClientBuilderBuilder(description, typeof(ContractMock), typeof(ClientMock));
            _builderType = _sut.Build(moduleBuilder);
        }
Exemple #2
0
        public IClientBuilder <TContract> GenerateClientBuilder <TContract>()
        {
            var serviceType = typeof(TContract);

            Type clientBuilderType;

            lock (ProxyAssembly.SyncRoot)
            {
                clientBuilderType = ProxyAssembly.DefaultModule.GetType(ContractDescription.GetClientBuilderClassName(serviceType), false, false) !;
                if (clientBuilderType == null)
                {
                    var(description, contractType) = GenerateContract(serviceType);
                    var clientType = new EmitClientBuilder(description, contractType).Build(ProxyAssembly.DefaultModule);
                    clientBuilderType = new EmitClientBuilderBuilder(description, contractType, clientType).Build(ProxyAssembly.DefaultModule);
                }
            }

            return((IClientBuilder <TContract>)Activator.CreateInstance(clientBuilderType));
        }