Пример #1
0
        public IRegistration Load(string key, Type service, Arguments 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));
        }
Пример #2
0
        private static void ObtainServiceContract(ComponentModel model, IWcfClientModel clientModel)
        {
            var serviceContract = clientModel.Contract ??
                                  model.Services.Where(service => WcfUtils.IsServiceContract(service)).Single();

            model.ExtendedProperties[WcfConstants.ServiceContractKey] = serviceContract;
        }