Beispiel #1
0
 public RequestOneWayChannelFactory(OneWayBindingElement bindingElement, BindingContext context) : base(context.Binding, context.BuildInnerChannelFactory <IRequestChannel>())
 {
     if (bindingElement.PacketRoutable)
     {
         this.packetRoutableHeader = PacketRoutableHeader.Create();
     }
 }
        void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
        {
            if (importer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer");
            }
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }
            XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "OneWay", "http://schemas.microsoft.com/ws/2005/05/routing/policy", true);

            if (element != null)
            {
                OneWayBindingElement item = new OneWayBindingElement();
                context.BindingElements.Add(item);
                for (int i = 0; i < element.ChildNodes.Count; i++)
                {
                    System.Xml.XmlNode node = element.ChildNodes[i];
                    if (((node != null) && (node.NodeType == XmlNodeType.Element)) && ((node.NamespaceURI == "http://schemas.microsoft.com/ws/2005/05/routing/policy") && (node.LocalName == "PacketRoutable")))
                    {
                        item.PacketRoutable = true;
                        return;
                    }
                }
            }
            else if (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous)
            {
                context.BindingElements.Add(new OneWayBindingElement());
            }
        }
        internal override bool IsMatch(BindingElement b)
        {
            if (b == null)
            {
                return(false);
            }
            OneWayBindingElement element = b as OneWayBindingElement;

            if (element == null)
            {
                return(false);
            }
            if (!this.channelPoolSettings.IsMatch(element.ChannelPoolSettings))
            {
                return(false);
            }
            if (this.packetRoutable != element.PacketRoutable)
            {
                return(false);
            }
            if (this.maxAcceptedChannels != element.MaxAcceptedChannels)
            {
                return(false);
            }
            return(true);
        }
        void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            if (context.BindingElements != null)
            {
                OneWayBindingElement oneWay = context.BindingElements.Find <OneWayBindingElement>();

                if (oneWay != null)
                {
                    // base assertion
                    XmlDocument doc       = new XmlDocument();
                    XmlElement  assertion = doc.CreateElement(OneWayPolicyConstants.Prefix,
                                                              OneWayPolicyConstants.OneWay, OneWayPolicyConstants.Namespace);

                    if (oneWay.PacketRoutable)
                    {
                        // add nested packet routable assertion
                        XmlElement child = doc.CreateElement(OneWayPolicyConstants.Prefix, OneWayPolicyConstants.PacketRoutable, OneWayPolicyConstants.Namespace);
                        assertion.AppendChild(child);
                    }

                    context.GetBindingAssertions().Add(assertion);
                }
            }
        }
 OneWayBindingElement(OneWayBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     this.channelPoolSettings = elementToBeCloned.ChannelPoolSettings.Clone();
     this.packetRoutable      = elementToBeCloned.PacketRoutable;
     this.maxAcceptedChannels = elementToBeCloned.maxAcceptedChannels;
 }
 public DuplexSessionOneWayChannelListener(OneWayBindingElement bindingElement, BindingContext context) : base(true, context.Binding, context.BuildInnerChannelListener <IDuplexSessionChannel>())
 {
     this.acceptLock           = new object();
     this.inputChannelAcceptor = new DuplexSessionOneWayInputChannelAcceptor(this);
     this.packetRoutable       = bindingElement.PacketRoutable;
     this.maxAcceptedChannels  = bindingElement.MaxAcceptedChannels;
     base.Acceptor             = this.inputChannelAcceptor;
     this.idleTimeout          = bindingElement.ChannelPoolSettings.IdleTimeout;
     this.onOpenInnerChannel   = Fx.ThunkCallback(new AsyncCallback(this.OnOpenInnerChannel));
     this.ownsInnerListener    = true;
     this.onInnerChannelClosed = new EventHandler(this.OnInnerChannelClosed);
 }
        public DuplexSessionOneWayChannelFactory(OneWayBindingElement bindingElement, BindingContext context) : base(context.Binding, context.BuildInnerChannelFactory <IDuplexSessionChannel>())
        {
            this.packetRoutable = bindingElement.PacketRoutable;
            ISecurityCapabilities property = base.InnerChannelFactory.GetProperty <ISecurityCapabilities>();

            if ((property != null) && property.SupportsClientAuthentication)
            {
                this.channelPoolSettings = bindingElement.ChannelPoolSettings.Clone();
            }
            else
            {
                this.channelPool = new ChannelPool <IDuplexSessionChannel>(bindingElement.ChannelPoolSettings);
            }
        }
Beispiel #8
0
        public DuplexSessionOneWayChannelFactory(OneWayBindingElement bindingElement, BindingContext context)
            : base(context.Binding, context.BuildInnerChannelFactory <IDuplexSessionChannel>())
        {
            this.packetRoutable = bindingElement.PacketRoutable;

            ISecurityCapabilities innerSecurityCapabilities = this.InnerChannelFactory.GetProperty <ISecurityCapabilities>();

            // can't pool across outer channels if the inner channels support client auth
            if (innerSecurityCapabilities != null && innerSecurityCapabilities.SupportsClientAuthentication)
            {
                this.channelPoolSettings = bindingElement.ChannelPoolSettings.Clone();
            }
            else
            {
                this.channelPool = new ChannelPool <IDuplexSessionChannel>(bindingElement.ChannelPoolSettings);
            }
        }
 void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context)
 {
     if (context == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
     }
     if (context.BindingElements != null)
     {
         OneWayBindingElement element = context.BindingElements.Find <OneWayBindingElement>();
         if (element != null)
         {
             XmlDocument document = new XmlDocument();
             XmlElement  item     = document.CreateElement("ow", "OneWay", "http://schemas.microsoft.com/ws/2005/05/routing/policy");
             if (element.PacketRoutable)
             {
                 XmlElement newChild = document.CreateElement("ow", "PacketRoutable", "http://schemas.microsoft.com/ws/2005/05/routing/policy");
                 item.AppendChild(newChild);
             }
             context.GetBindingAssertions().Add(item);
         }
     }
 }
        void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context)
        {
            if (importer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer");
            }

            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
            }

            XmlElement oneWayAssertion = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(),
                                                                               OneWayPolicyConstants.OneWay, OneWayPolicyConstants.Namespace, true);

            if (oneWayAssertion != null)
            {
                OneWayBindingElement bindingElement = new OneWayBindingElement();
                context.BindingElements.Add(bindingElement);

                for (int i = 0; i < oneWayAssertion.ChildNodes.Count; i++)
                {
                    XmlNode currentNode = oneWayAssertion.ChildNodes[i];
                    if (currentNode != null &&
                        currentNode.NodeType == XmlNodeType.Element &&
                        currentNode.NamespaceURI == OneWayPolicyConstants.Namespace &&
                        currentNode.LocalName == OneWayPolicyConstants.PacketRoutable)
                    {
                        bindingElement.PacketRoutable = true;
                        break;
                    }
                }
            }
            else if (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous)
            {
                context.BindingElements.Add(new OneWayBindingElement());
            }
        }
Beispiel #11
0
 OneWayBindingElement(OneWayBindingElement other)
 {
     pool = new ChannelPoolSettings(other.pool);
 }
Beispiel #12
0
 public DuplexOneWayChannelListener(OneWayBindingElement bindingElement, BindingContext context) : base(context.Binding, context.BuildInnerChannelListener <IDuplexChannel>())
 {
     this.packetRoutable = bindingElement.PacketRoutable;
 }
 public DuplexOneWayChannelFactory(OneWayBindingElement bindingElement, BindingContext context) : base(context.Binding, context.BuildInnerChannelFactory <IDuplexChannel>())
 {
     this.innnerFactory  = (IChannelFactory <IDuplexChannel>)base.InnerChannelFactory;
     this.packetRoutable = bindingElement.PacketRoutable;
 }
 private OneWayBindingElement(OneWayBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
     _packetRoutable      = elementToBeCloned.PacketRoutable;
     _maxAcceptedChannels = elementToBeCloned._maxAcceptedChannels;
 }