Ejemplo n.º 1
0
        private void PopulateNode(WsXmlNode node, WsXmlNode parent, XmlReader reader)
        {
            node.LocalName    = reader.LocalName;
            node.NamespaceURI = reader.NamespaceURI;
            node.Prefix       = reader.Prefix;
            node.ParentNode   = parent;

            // Read attributes if they exist
            if (reader.HasAttributes)
            {
                reader.MoveToFirstAttribute();
                do
                {
                    WsXmlAttribute attribute = new WsXmlAttribute();
                    attribute.Value     = reader.Value;
                    attribute.LocalName = reader.LocalName;
                    if (reader.NamespaceURI != String.Empty)
                    {
                        attribute.NamespaceURI = reader.NamespaceURI;
                    }

                    attribute.Prefix = reader.Prefix;
                    node.Attributes.Append(attribute);
                }while (reader.MoveToNextAttribute());

                reader.MoveToElement();
            }
        }
Ejemplo n.º 2
0
        internal String GetNodeValue(String localName, String namespaceUri)
        {
            WsXmlNode node = GetNode(localName, namespaceUri);

            if (node != null)
            {
                return(node.Value);
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an instance a DpwsSubscribeRequest class initialized with the service endpoint Address,
        /// notifyTo callback endpoint address and event duration.
        /// </summary>
        /// <param name="subscriptionType">A DpwsServieType object containing a definition of the service being subscripbed to.</param>
        /// <param name="endpointAddress">A string containing an event source endpoint address.</param>
        /// <param name="notifyToAddress">A string containing the notifyTo endpoint address.</param>
        /// <param name="expires">
        /// A string containing the subscription expiration time in duration format. If
        /// null the event does not expire.
        /// </param>
        /// <param name="identifier">A WsWsaRefParamter object containing a unique identifier.
        /// This value will be included in an event messages soap header as a reference parameter.
        /// This value is not processed by a service it is intended to provide a unique identified
        /// a client can use for any purpose.</param>
        /// <remarks>
        /// This constructor sets the endTo address to null indicating that the notifyTo address should receive
        /// subscription end messages. A user ID for the event is not set by default.
        /// </remarks>
        /// <exception cref="ArgumentException">If duration format is invalid.</exception>
        public DpwsSubscribeRequest(DpwsServiceType subscriptionType, string endpointAddress, string notifyToAddress, string expires, WsXmlNode identifier)
        {
            if (endpointAddress == null || notifyToAddress == null)
                throw new ArgumentNullException();

            this.SubscriptionType = subscriptionType;
            this.EndpointAddress = new Uri(endpointAddress);

            this.NotifyTo = new WsWsaEndpointRef(new Uri(notifyToAddress));
            this.EndTo = new WsWsaEndpointRef(new Uri(notifyToAddress));

            if (identifier != null)
            {
                this.NotifyTo.RefProperties.Add(identifier);
                this.EndTo.RefProperties.Add(identifier);
            }

            if (expires != null)
                this.Expires = new WsDuration(expires);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Use to append an XmlNode to the ChildNodes collection.
 /// </summary>
 /// <param name="newNode"></param>
 /// <returns></returns>
 public WsXmlNode AppendChild(WsXmlNode newNode)
 {
     this.ChildNodes.Add(newNode);
     return newNode;
 }
Ejemplo n.º 5
0
        private void PopulateNode(WsXmlNode node, WsXmlNode parent, XmlReader reader)
        {
            node.LocalName = reader.LocalName;
            node.NamespaceURI = reader.NamespaceURI;
            node.Prefix = reader.Prefix;
            node.ParentNode = parent;

            // Read attributes if they exist
            if (reader.HasAttributes)
            {
                reader.MoveToFirstAttribute();
                do
                {
                    WsXmlAttribute attribute = new WsXmlAttribute();
                    attribute.Value = reader.Value;
                    attribute.LocalName = reader.LocalName;
                    if (reader.NamespaceURI != String.Empty)
                    {
                        attribute.NamespaceURI = reader.NamespaceURI;
                    }

                    attribute.Prefix = reader.Prefix;
                    node.Attributes.Append(attribute);
                }

                while (reader.MoveToNextAttribute());

                reader.MoveToElement();
            }
        }
Ejemplo n.º 6
0
        internal WsXmlNode(XmlReader reader)
            : this()
        {
            if (reader.IsStartElement() == false)
            {
                throw new XmlException();
            }

            WsXmlNode currentElement = this;
            WsXmlNode parentElement = currentElement;
            int previousDepth = reader.Depth;
            int originalDepth = previousDepth;

            PopulateNode(this, null, reader);
            reader.Read();

            // Walk the document
            while (true)
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        // We are decending the branch
                        while (reader.Depth < previousDepth)
                        {
                            parentElement = parentElement.ParentNode;
                            --previousDepth;
                        }

                        // We are accending the branch
                        if (reader.Depth > previousDepth)
                        {
                            parentElement = currentElement;
                            ++previousDepth;
                        }

                        currentElement = new WsXmlNode();
                        parentElement.AppendChild(currentElement);

                        PopulateNode(currentElement, parentElement, reader);
                        break;
                    case XmlNodeType.Text:
                        currentElement.Value = reader.Value;
                        break;
                }

                if (reader.Depth <= originalDepth)
                    break;

                // Read more xml
                reader.Read();
            }

            if (reader.Depth == originalDepth && reader.NodeType == XmlNodeType.EndElement)
            {
                reader.Read();
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds an XmlNode to the end of the collection.
 /// </summary>
 /// <param name="value">The XmlNode to be added to the end of the collection. The value can be null.</param>
 /// <returns>The XmlNodes index at which the value has been added.</returns>
 public int Add(WsXmlNode value)
 {
     return m_nodeList.Add(value);
 }
Ejemplo n.º 8
0
        public MFTestResults XmlTest5_WsXmlNodeList()
        {
            /// <summary>
            /// 1. Verifies the properties of a WsWsaEndpointRefs object
            /// 2. Adds elements to it
            /// 3. Re-verifies
            /// 4. Empties the object
            /// 5. Re-verifies
            /// </summary>
            ///
            bool testResult = true;
            try
            {
                WsXmlNodeList testWXNs = new WsXmlNodeList();

                if (testWXNs.Count != 0)
                    throw new Exception("Count did not set correctly on new");

                testWXNs.Add(new WsXmlNode());

                WsXmlNode testWXN = new WsXmlNode();
                testWXN.LocalName = "testWXN local name";
                testWXNs.Add(testWXN);

                if (testWXNs.Count != 2)
                    throw new Exception("Count did not set correctly on new");

            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
Ejemplo n.º 9
0
        public MFTestResults XmlTest_XmlNode()
        {
            /// <summary>
            /// 1. Gets and verifies each of the properties of a WsXmlNode object
            /// 2. Sets and re-verifies all properties
            /// See 18325 for more info re: childNodes
            /// </summary>
            ///
            bool testResult = true;
            try
            {
                WsXmlNode testWXN = new WsXmlNode();

                Log.Comment("LocalName");
                if (testWXN.LocalName != null)
                    if (testWXN.LocalName.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("LocalName wrong type");

                testWXN.LocalName = "test datum 1";

                if (testWXN.LocalName.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("LocalName wrong type after set");

                if (testWXN.LocalName != "test datum 1")
                    throw new Exception("LocalName wrong data");


                Log.Comment("NamespaceURI");
                if (testWXN.NamespaceURI != null)
                    if (testWXN.NamespaceURI.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("NamespaceURI wrong type");

                testWXN.NamespaceURI = "test datum 3";

                if (testWXN.NamespaceURI.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("NamespaceURI wrong type after set");

                if (testWXN.NamespaceURI != "test datum 3")
                    throw new Exception("NamespaceURI wrong data");

                Log.Comment("Prefix");
                if (testWXN.Prefix != null)
                    if (testWXN.Prefix.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("Prefix wrong type");

                testWXN.Prefix = "test datum 4";

                if (testWXN.Prefix.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("Prefix wrong type after set");

                if (testWXN.Prefix != "test datum 4")
                    throw new Exception("Prefix wrong data");

                Log.Comment("Value");
                if (testWXN.Value != null)
                    if (testWXN.Value.GetType() !=
                        Type.GetType("System.String"))
                        throw new Exception("Value wrong type");

                testWXN.Value = "test datum 5";

                if (testWXN.Value.GetType() !=
                    Type.GetType("System.String"))
                    throw new Exception("Value wrong type after set");

                if (testWXN.Value != "test datum 5")
                    throw new Exception("Value wrong data");

                Log.Comment("Attributes");
                if (testWXN.Attributes != null)
                    if (testWXN.Attributes.GetType() !=
                        Type.GetType("Ws.Services.Xml.WsXmlAttributeCollection"))
                        throw new Exception("Value wrong type");

                Log.Comment("ChildNodes");
                if (testWXN.ChildNodes != null)
                    if (testWXN.ChildNodes.GetType() !=
                        Type.GetType("Ws.Services.Xml.WsXmlNodeList"))
                        throw new Exception("ChildNodes wrong type");
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }

            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Writes an array of elements at the current position in the document.
 /// </summary>
 /// <param name="writer">The XmlWriter used to write the elements.</param>
 /// <param name="elements">An array of XmlElements to write.</param>
 protected void WriteAnyElement(XmlWriter writer, WsXmlNode[] elements, bool isRequired)
 {
     if (elements == null || elements.Length == 0)
         if (isRequired)
             throw new XmlException("Parsing Error. The parameter element is either null or empty.");
         else
             return;
     for (int i = 0; i < elements.Length; i++)
     {
         elements[i].WriteTo(writer);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Starting at the current reader position, builds an arrray of
        /// XmlElement objects up to the end tag of the enclosing element or until namespace
        /// validation rules are violated.
        /// </summary>
        /// <param name="reader">An XmlReader positioned at a start element.</param>
        /// <param name="isRequired">True if minoccurs > 0 for an element.</param>
        /// <returns>An array of XmlElements.</returns>
        /// <remarks>ProcessContent validation is not supported.</remarks>
        protected WsXmlNode[] ReadAnyElement(XmlReader reader, bool isRequired)
        {
            if (isRequired && !reader.IsStartElement())
                throw new XmlException("Parsing Error. Any element is required.");

            ArrayList nodeList = new ArrayList();
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                WsXmlNode tempNode = new WsXmlNode(reader);
                nodeList.Add(tempNode);
            }

            return (WsXmlNode[])nodeList.ToArray(typeof(WsXmlNode));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Use to append an XmlNode to the ChildNodes collection.
 /// </summary>
 /// <param name="newNode"></param>
 /// <returns></returns>
 public WsXmlNode AppendChild(WsXmlNode newNode)
 {
     this.ChildNodes.Add(newNode);
     return(newNode);
 }
Ejemplo n.º 13
0
        internal WsXmlNode(XmlReader reader)
            : this()
        {
            if (reader.IsStartElement() == false)
            {
                throw new XmlException();
            }

            WsXmlNode currentElement = this;
            WsXmlNode parentElement  = currentElement;
            int       previousDepth  = reader.Depth;
            int       originalDepth  = previousDepth;

            PopulateNode(this, null, reader);
            reader.Read();

            // Walk the document
            while (true)
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    // We are decending the branch
                    while (reader.Depth < previousDepth)
                    {
                        parentElement = parentElement.ParentNode;
                        --previousDepth;
                    }

                    // We are accending the branch
                    if (reader.Depth > previousDepth)
                    {
                        parentElement = currentElement;
                        ++previousDepth;
                    }

                    currentElement = new WsXmlNode();
                    parentElement.AppendChild(currentElement);

                    PopulateNode(currentElement, parentElement, reader);
                    break;

                case XmlNodeType.Text:
                    currentElement.Value = reader.Value;
                    break;
                }

                if (reader.Depth <= originalDepth)
                {
                    break;
                }

                // Read more xml
                reader.Read();
            }

            if (reader.Depth == originalDepth && reader.NodeType == XmlNodeType.EndElement)
            {
                reader.Read();
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Adds an XmlNode to the end of the collection.
 /// </summary>
 /// <param name="value">The XmlNode to be added to the end of the collection. The value can be null.</param>
 /// <returns>The XmlNodes index at which the value has been added.</returns>
 public int Add(WsXmlNode value)
 {
     return(m_nodeList.Add(value));
 }