コード例 #1
0
        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);
        }
コード例 #2
0
 public RestClient CreateClient()
 {
     return(new RestClient(_container.CreateContainer()));
 }