public ProxyGeneratorBuildResult Build( Type proxyInterfaceType, IEnumerable <InterfaceDescription> interfaceDescriptions) { // create the context to build the proxy var context = new CodeBuilderContext( assemblyName: this.CodeBuilder.Names.GetProxyAssemblyName(proxyInterfaceType), assemblyNamespace: this.CodeBuilder.Names.GetProxyAssemblyNamespace(proxyInterfaceType), enableDebugging: CodeBuilderAttribute.IsDebuggingEnabled(proxyInterfaceType)); var result = new ProxyGeneratorBuildResult(context); // ensure that method data types are built for each of the remote interfaces var methodBodyTypesResultsMap = interfaceDescriptions.ToDictionary( d => d, d => this.CodeBuilder.GetOrBuildMethodBodyTypes(d.InterfaceType)); // build the proxy class that implements all of the interfaces explicitly result.ProxyType = this.BuildProxyType(context, proxyInterfaceType, methodBodyTypesResultsMap); // build the activator type to create instances of the proxy result.ProxyActivatorType = this.BuildProxyActivatorType(context, proxyInterfaceType, result.ProxyType); // build the proxy generator result.ProxyGenerator = this.CreateProxyGenerator(proxyInterfaceType, methodBodyTypesResultsMap, result.ProxyActivatorType); context.Complete(); return(result); }
protected bool TryGetProxyGenerator(Type interfaceType, out ProxyGeneratorBuildResult orBuildProxyGenerator) { ProxyGeneratorBuildResult result; if (this.proxyGeneratorBuildResultMap.TryGetValue(interfaceType, out result)) { { orBuildProxyGenerator = result; return(true); } } orBuildProxyGenerator = null; return(false); }
protected void UpdateProxyGeneratorMap(Type interfaceType, ProxyGeneratorBuildResult result) { this.proxyGeneratorBuildResultMap.Add(interfaceType, result); }