Beispiel #1
0
        internal bool IsEquivalent(AddressHeaderCollection col)
        {
            if (this.InternalCount != col.InternalCount)
            {
                return(false);
            }
            StringBuilder            builder = new StringBuilder();
            Dictionary <string, int> headers = new Dictionary <string, int>();

            this.PopulateHeaderDictionary(builder, headers);
            Dictionary <string, int> dictionary2 = new Dictionary <string, int>();

            col.PopulateHeaderDictionary(builder, dictionary2);
            if (headers.Count != dictionary2.Count)
            {
                return(false);
            }
            foreach (KeyValuePair <string, int> pair in headers)
            {
                int num;
                if (dictionary2.TryGetValue(pair.Key, out num))
                {
                    if (num != pair.Value)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        private static T GetServiceByFactory <T>(String service, SecurityMode SM)
        {
            String         URL = String.Format(HttpService, service);
            IClientChannel cc  = CheckService(URL);

            if (cc != null)
            {
                return((T)cc);
            }
            ChannelFactory <T> factory = CheckFactory(URL) as ChannelFactory <T>;

            if (factory == null)
            {
                System.ServiceModel.Channels.AddressHeaderCollection ahc = new System.ServiceModel.Channels.AddressHeaderCollection();
                EndpointAddress EPD = new EndpointAddress(new Uri(URL), EndpointIdentity.CreateDnsIdentity(dnsName), ahc);
                WSHttpBinding   wh  = new WSHttpBinding(SM);
                wh.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
                wh.MaxBufferPoolSize                   = 2147483647;
                wh.MaxReceivedMessageSize              = 2147483647;
                wh.ReaderQuotas.MaxArrayLength         = 2147483647;
                wh.ReaderQuotas.MaxBytesPerRead        = 2147483647;
                wh.ReaderQuotas.MaxDepth               = 2147483647;
                wh.ReaderQuotas.MaxNameTableCharCount  = 2147483647;
                wh.ReaderQuotas.MaxStringContentLength = 2147483647;
                wh.ReceiveTimeout = new TimeSpan(0, 2, 0);
                wh.ReliableSession.InactivityTimeout = new TimeSpan(0, 1, 0);
                wh.ReliableSession.Enabled           = true;
                factory = new ChannelFactory <T>(wh, EPD);
                if (SM == SecurityMode.Message)
                {
                    SetCredentials(factory.Credentials);
                }
            }
            else
            {
                factory = (ChannelFactory <T>)dicFactory[URL];
            }
            T t = factory.CreateChannel();

            dicChannel.Remove(URL);
            dicChannel.Add(URL, (IClientChannel)t);
            return(t);
        }
Beispiel #3
0
        internal bool IsEquivalent(AddressHeaderCollection col)
        {
            if (InternalCount != col.InternalCount)
            {
                return(false);
            }

            StringBuilder            builder   = new StringBuilder();
            Dictionary <string, int> myHeaders = new Dictionary <string, int>();

            PopulateHeaderDictionary(builder, myHeaders);

            Dictionary <string, int> otherHeaders = new Dictionary <string, int>();

            col.PopulateHeaderDictionary(builder, otherHeaders);

            if (myHeaders.Count != otherHeaders.Count)
            {
                return(false);
            }

            foreach (KeyValuePair <string, int> pair in myHeaders)
            {
                int count;
                if (otherHeaders.TryGetValue(pair.Key, out count))
                {
                    if (count != pair.Value)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }