Castle.Facilities.WcfIntegration.WcfClientComponentLoader.Load C# (CSharp) Method

Load() public method

public Load ( string key, Type service, IDictionary arguments ) : IRegistration
key string
service System.Type
arguments IDictionary
return IRegistration
		public IRegistration Load(string key, Type service, IDictionary arguments)
		{
			if (service == typeof(IWcfClientFactory))
			{
				throw new FacilityException(
					"The IWcfClientFactory is only available with the TypedFactoryFacility.  " +
					"Did you forget to register that facility? Also make sure that TypedFactoryFacility was registred before WcfFacility.");
			}

			if (service == null || WcfUtils.IsServiceContract(service) == false)
			{
				return null;
			}

			var clientModel = WcfUtils.FindDependencies<IWcfClientModel>(arguments)
				.FirstOrDefault() ?? new DefaultClientModel();

			var endpoint = WcfUtils.FindDependencies<IWcfEndpoint>(arguments).FirstOrDefault();

			if (endpoint != null)
			{
				clientModel = clientModel.ForEndpoint(endpoint);
			}
			else if (clientModel.Endpoint == null && string.IsNullOrEmpty(key) == false)
			{
				clientModel = clientModel.ForEndpoint(WcfEndpoint.FromConfiguration(key));
			}

			return Component.For(service).Named(key).LifeStyle.Transient.AsWcfClient(clientModel);
		}
	}
WcfClientComponentLoader