public SsbChannelFactory(SsbBindingElement bindingElement, BindingContext context)
            : base(context.Binding)
        {
            this.connstr                    = bindingElement.SqlConnectionString;
            this.bufferManager              = BufferManager.CreateBufferManager(bindingElement.MaxBufferPoolSize, int.MaxValue);
            this.endConversationOnClose     = bindingElement.SenderEndsConversationOnClose;
            this.useEncryption              = bindingElement.UseEncryption;
            this.contract                   = bindingElement.Contract;
            this.useActionForSsbMessageType = bindingElement.UseActionForSsbMessageType;

            this.binding = context.Binding;

            Collection <MessageEncodingBindingElement> messageEncoderBindingElements = context.BindingParameters.FindAll <MessageEncodingBindingElement>();

            if (messageEncoderBindingElements.Count > 1)
            {
                throw new InvalidOperationException("More than one MessageEncodingBindingElement was found in the BindingParameters of the BindingContext");
            }
            else if (messageEncoderBindingElements.Count == 1)
            {
                this.messageEncoderFactory = messageEncoderBindingElements[0].CreateMessageEncoderFactory();
            }
            else
            {
                this.messageEncoderFactory = SsbConstants.DefaultMessageEncoderFactory;
            }
        }
        void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
        {
            Console.WriteLine("ImportPolicy");
            if (importer == null)
            {
                throw new ArgumentNullException("importer");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            SsbBindingElement         ssbBindingElement = null;
            PolicyAssertionCollection policyAssertions  = context.GetBindingAssertions();

            if (policyAssertions.Remove(SsbConstants.SsbTransportAssertion, SsbConstants.SsbNs) != null)
            {
                ssbBindingElement = new SsbBindingElement();
                ssbBindingElement.SqlConnectionString = "";
            }
            if (ssbBindingElement != null)
            {
                context.BindingElements.Add(ssbBindingElement);
            }
        }
Пример #3
0
 public SsbBindingElement(SsbBindingElement other)
     : base(other)
 {
     this.SqlConnectionString           = other.SqlConnectionString;
     this.SenderEndsConversationOnClose = other.SenderEndsConversationOnClose;
     this.contract      = other.contract;
     this.useEncryption = other.useEncryption;
     this.useActionForSsbMessageType = other.useActionForSsbMessageType;
     if (other.IsConversationGroupSpecified)
     {
         this.ConversationGroupId = other.ConversationGroupId;
     }
 }
        private ServiceHost CreateResponseHost2 <TContract>(ServiceHost host, Uri listenAddress)
        {
            //if turn this off, since it makes no sense
            //and if the conversation was started automatically, it will be on.
            endConversationOnClose = false;

            //Uri responseAddress = new SsbUri(listenAddress).Reverse();
            BindingElementCollection bindingElements   = factory.Binding.CreateBindingElements();
            SsbBindingElement        ssbBindingElement = bindingElements.Find <SsbBindingElement>();

            ssbBindingElement.ConversationGroupId = ConversationGroupID;
            Binding responseBinding = new CustomBinding(bindingElements);

            responseBinding.ReceiveTimeout = factory.Binding.ReceiveTimeout;
            responseBinding.OpenTimeout    = factory.Binding.OpenTimeout;
            responseBinding.CloseTimeout   = factory.Binding.CloseTimeout;
            host.AddServiceEndpoint(typeof(TContract), responseBinding, listenAddress);

            return(host);
        }
Пример #5
0
        public static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            binding = null;
            if (elements.Count > 4)
            {
                return(false);
            }

            TextMessageEncodingBindingElement textMessageEncodingBindingElement = null;
            SsbBindingElement ssbBindingElement = null;

            foreach (BindingElement element in elements)
            {
                if (element is TextMessageEncodingBindingElement)
                {
                    textMessageEncodingBindingElement = (TextMessageEncodingBindingElement)element;
                }
                else if (element is SsbBindingElement)
                {
                    ssbBindingElement = (SsbBindingElement)element;
                }
                else
                {
                    return(false);
                }
            }

            if (ssbBindingElement == null || textMessageEncodingBindingElement == null)
            {
                return(false);
            }

            SsbBinding ssbbinding = new SsbBinding();

            ssbbinding.InitializeFrom(ssbBindingElement, textMessageEncodingBindingElement);
            binding = ssbbinding;
            return(true);
        }
        public SsbChannelListener(SsbBindingElement bindingElement, BindingContext context)
            : base(context.Binding)
        {
            this.bindingElement    = bindingElement;
            originalBindingContext = context.Clone();
            //Address stuff
            if (context.ListenUriMode == ListenUriMode.Unique)
            {
                throw new ProtocolException("ListenUriMode.Unique is not supported. You must provide an explicit address");
            }
            Uri baseAddress = context.ListenUriBaseAddress;

            if (baseAddress == null)
            {
                throw new ProtocolException("Address is null. You must provide an exlpicit address");
            }


            listenUri = new SsbUri(BuildUri(baseAddress, context.ListenUriRelativeAddress));

            //copy properties from binding element
            // TODO how do we enforce MaxReceivedMessgeSize
            this.maxMessageSize = (int)bindingElement.MaxReceivedMessageSize;

            this.connstring    = bindingElement.SqlConnectionString;
            this.bufferManager = BufferManager.CreateBufferManager(bindingElement.MaxBufferPoolSize, this.maxMessageSize);
            MessageEncodingBindingElement messageEncoderBindingElement = context.BindingParameters.Remove <MessageEncodingBindingElement>();

            if (messageEncoderBindingElement != null)
            {
                this.messageEncoderFactory = messageEncoderBindingElement.CreateMessageEncoderFactory();
            }
            else
            {
                this.messageEncoderFactory = SsbConstants.DefaultMessageEncoderFactory;
            }
        }
Пример #7
0
 void InitializeFrom(SsbBindingElement ssbBindingElement, TextMessageEncodingBindingElement textMessageEncodingBindingElement)
 {
     this.ssbbe = ssbBindingElement;
     this.encbe = textMessageEncodingBindingElement;
 }
Пример #8
0
 void Initialize()
 {
     this.ssbbe = new SsbBindingElement();
     this.encbe = new TextMessageEncodingBindingElement();
 }