Пример #1
0
        public WcfChannelWrapper <T> CreateWcfChannel <T>()
            where T : class
        {
            ChannelFactory cf;

            if (!_cfCache.TryGetValue(typeof(T), out cf))
            {
                lock (_cfCacheLock)
                {
                    if (!_cfCache.TryGetValue(typeof(T), out cf))
                    {
                        if (typeof(T) == typeof(IWcfConfigurationService))
                        {
                            cf = new ChannelFactory <IWcfConfigurationService>(WCFCONFIGURATIONSERVICE_ENDPOINT_NAME);
                        }
                        else
                        {
                            var endpoint = WcfConfigurationServiceProxy.GetWcfClientEndpoint(typeof(T));
                            cf = WcfChannelFactoryFactory.CreateChannelFactory <T>(endpoint);
                        }
                        _cfCache[typeof(T)] = cf;
                    }
                }
            }

            return(new WcfChannelWrapper <T>((cf as ChannelFactory <T>).CreateChannel()));
        }
Пример #2
0
        public WcfChannelWrapper <T> CreateWcfChannel <T>()
            where T : class
        {
            ChannelFactory cf;

            if (!_cfCache.TryGetValue(typeof(T), out cf))
            {
                lock (_cfCacheLock)
                {
                    if (!_cfCache.TryGetValue(typeof(T), out cf))
                    {
                        var endpoint = _config.GetWcfClientEndpointConfiguration(typeof(T));
                        cf = WcfChannelFactoryFactory.CreateChannelFactory <T>(endpoint);
                        _cfCache[typeof(T)] = cf;
                    }
                }
            }

            return(new WcfChannelWrapper <T>((cf as ChannelFactory <T>).CreateChannel()));
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var fac = WcfChannelFactoryFactory.CreateChannelFactory <IActiveRecordConnection <Farm> >(new WcfClientEndpoint
            {
                Address             = "http://localhost:2166/FarmConnectionService.svc",
                BindingXml          = new BindingXml("basichttpbinding", null),
                ServiceContractType = typeof(IActiveRecordConnection <Farm>).FullName
            });

            using (var svc = new WcfChannelWrapper <IActiveRecordConnection <Farm> >(fac.CreateChannel()))
            {
                Farm farm = new Farm();
                farm.Attach(svc.Channel);

                farm.FarmID          = 999;
                farm.FarmAddress     = "999";
                farm.LoadBalancePath = "999";
                farm.Delete();
                farm.Save();
                var loadFarm = farm.FindOne(farm.GetObjectId());
                loadFarm.Delete();
            }
        }