public TContract CreateProxy <TContract>(Action <EndpointProxyBuilder> proxyConfigurator) where TContract : class { var proxyType = ProxyFactory.GetProxyType <EndpointProxy, TContract>(); var metadataProvider = _container.Required <RestMetadataProvider>(); var valuesProvider = new MetadataValueProvider(); var metadata = metadataProvider.GetEndpointMetadata(typeof(TContract), valuesProvider); var proxyBuilder = new RestContainerBuilder(_container); proxyBuilder.Register <DefaultRequestBinder>(); proxyBuilder.Register <DefaultResponseBinder>(); proxyBuilder.Register <DefaultRequestQueryValueFormatter>(); proxyBuilder.Register <DefaultRequestRouteValueFormatter>(); proxyBuilder.Register <RestModelMapper>(); proxyConfigurator?.Invoke(new EndpointProxyBuilder(proxyBuilder)); var proxyContainer = proxyBuilder.CreateContainer(); var proxy = Activator.CreateInstance(proxyType, new object[] { this, metadata, proxyContainer }); return((TContract)proxy); }
public RestClient CreateClient() { return(new RestClient(_container.CreateContainer())); }