Close() публичный Метод

public Close ( ) : void
Результат void
 public static XmlDictionaryReader GetReaderAtDetailContents11(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
 {
     XmlDictionaryString namespaceUri = DXD.Wsrm11Dictionary.Namespace;
     headerReader.ReadFullStartElement(XD.WsrmFeb2005Dictionary.SequenceFault, namespaceUri);
     headerReader.Skip();
     headerReader.ReadFullStartElement(XD.Message12Dictionary.FaultDetail, namespaceUri);
     if (((headerReader.NodeType == XmlNodeType.Element) && !(headerReader.NamespaceURI != detailNamespace)) && !(headerReader.LocalName != detailName))
     {
         return headerReader;
     }
     headerReader.Close();
     return null;
 }
 public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
 {
     XmlDictionaryReader reader;
     try
     {
         WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
         XmlDictionaryString namespaceUri = dictionary.Namespace;
         XmlBuffer buffer = null;
         int sectionIndex = 0;
         int depth = headerReader.Depth;
         headerReader.ReadFullStartElement(dictionary.SequenceFault, namespaceUri);
         while (headerReader.Depth > depth)
         {
             if (((headerReader.NodeType == XmlNodeType.Element) && (headerReader.NamespaceURI == detailNamespace)) && (headerReader.LocalName == detailName))
             {
                 if (buffer != null)
                 {
                     return null;
                 }
                 buffer = new XmlBuffer(0x7fffffff);
                 try
                 {
                     sectionIndex = buffer.SectionCount;
                     buffer.OpenSection(headerReader.Quotas).WriteNode(headerReader, false);
                     continue;
                 }
                 finally
                 {
                     buffer.CloseSection();
                 }
             }
             if (headerReader.Depth == depth)
             {
                 break;
             }
             headerReader.Read();
         }
         if (buffer == null)
         {
             return null;
         }
         buffer.Close();
         reader = buffer.GetReader(sectionIndex);
     }
     finally
     {
         headerReader.Close();
     }
     return reader;
 }
 public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion) : base(code, "MessageNumberRollover", reason, true, true)
 {
     try
     {
         base.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);
         if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
         {
             ulong num;
             detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber, WsrmIndex.GetNamespace(reliableMessagingVersion));
             if (!ulong.TryParse(detailReader.ReadContentAsString(), out num) || (num <= 0L))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidSequenceNumber", new object[] { num })));
             }
             detailReader.ReadEndElement();
         }
     }
     finally
     {
         detailReader.Close();
     }
 }
Пример #4
0
        public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader,
            ReliableMessagingVersion reliableMessagingVersion)
            : base(code, WsrmFeb2005Strings.MessageNumberRollover, reason, true, true)
        {
            try
            {
                this.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);

                if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber,
                        WsrmIndex.GetNamespace(reliableMessagingVersion));

                    string maxMessageNumberString = detailReader.ReadContentAsString();
                    ulong maxMessageNumber;
                    if (!UInt64.TryParse(maxMessageNumberString, out maxMessageNumber)
                        || (maxMessageNumber <= 0))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                            SR.GetString(SR.InvalidSequenceNumber, maxMessageNumber)));
                    }
                    // otherwise ignore value

                    detailReader.ReadEndElement();
                }
            }
            finally
            {
                detailReader.Close();
            }
        }
Пример #5
0
 static UniqueId ParseDetail(XmlDictionaryReader reader, ReliableMessagingVersion reliableMessagingVersion)
 {
     try
     {
         return WsrmUtilities.ReadIdentifier(reader, reliableMessagingVersion);
     }
     finally
     {
         reader.Close();
     }
 }
 public static string GetSubcode(XmlDictionaryReader headerReader, ReliableMessagingVersion reliableMessagingVersion)
 {
     string localName = null;
     try
     {
         string str3;
         WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
         XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
         headerReader.ReadStartElement(dictionary.SequenceFault, namespaceUri);
         headerReader.ReadStartElement(dictionary.FaultCode, namespaceUri);
         XmlUtil.ReadContentAsQName(headerReader, out localName, out str3);
         if (str3 != WsrmIndex.GetNamespaceString(reliableMessagingVersion))
         {
             localName = null;
         }
         headerReader.ReadEndElement();
         while (headerReader.IsStartElement())
         {
             headerReader.Skip();
         }
         headerReader.ReadEndElement();
     }
     finally
     {
         headerReader.Close();
     }
     return localName;
 }
        void GetHeaderId(
            XmlDictionaryReader reader,
            SecurityIdGenerator securityIdGenerator,
            bool closeReader,
            out string headerId,
            out bool idInserted)
        {
            // Look if the header already has a discovery Id attribute defined
            headerId = reader.GetAttribute(ProtocolStrings.IdAttributeName, this.DiscoveryInfo.DiscoveryNamespace);
            if (closeReader)
            {
                reader.Close();
            }

            idInserted = false;
            if (String.IsNullOrEmpty(headerId))
            {
                // The header doesn't contain a d:Id, so generate one.
                headerId = securityIdGenerator.GenerateId();
                idInserted = true;
            }
        }
Пример #8
0
 public override void Close()
 {
     reader.Close();
 }
Пример #9
0
		public void ReadString ()
		{
			reader = CreateReader ("\"true\"");
			Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
			reader.Read (); // dummy root element
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#2");
			Assert.AreEqual (XmlNodeType.Element, reader.NodeType, "#2-1");
			Assert.AreEqual ("root", reader.LocalName, "#2-2");
			Assert.AreEqual ("string", reader.GetAttribute ("type"), "#2-3");
			reader.Read (); // content (number)
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#3");
			Assert.AreEqual (XmlNodeType.Text, reader.NodeType, "#3-1");
			Assert.AreEqual ("true", reader.Value, "#3-2");
			reader.Read (); // endelement
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#4");
			Assert.AreEqual (XmlNodeType.EndElement, reader.NodeType, "#4-1");
			reader.Read (); // endoffile
			Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#5");
			reader.Close ();
			Assert.AreEqual (ReadState.Closed, reader.ReadState, "#6");
		}
Пример #10
0
		public void ReadNull ()
		{
			reader = CreateReader ("null");
			Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
			reader.Read (); // dummy root element
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#2");
			Assert.AreEqual (XmlNodeType.Element, reader.NodeType, "#2-1");
			Assert.AreEqual ("root", reader.LocalName, "#2-2");
			// When it is null, the value is never given and the reader is skipped to the end element.
			reader.Read (); // endlement
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#3");
			Assert.AreEqual (XmlNodeType.EndElement, reader.NodeType, "#3-1");
			reader.Read (); // endoffile
			Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#4");
			reader.Close ();
			Assert.AreEqual (ReadState.Closed, reader.ReadState, "#4");
		}
Пример #11
0
		public void ReadStateArray ()
		{
			reader = CreateReader ("[]");
			Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
			reader.Read (); // element
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#2");
			reader.Read (); // endelement
			Assert.AreEqual (ReadState.Interactive, reader.ReadState, "#3");
			reader.Read (); // endoffile
			Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#4");
			reader.Close ();
			Assert.AreEqual (ReadState.Closed, reader.ReadState, "#5");
		}
Пример #12
0
		public void ReadStateEmpty2 ()
		{
			reader = CreateReader ("  ");
			Assert.AreEqual (ReadState.Initial, reader.ReadState, "#1");
			reader.Read ();
			Assert.AreEqual (ReadState.EndOfFile, reader.ReadState, "#2");
			reader.Close ();
			Assert.AreEqual (ReadState.Closed, reader.ReadState, "#3");
		}
Пример #13
0
		// hmm... [ExpectedException (typeof (InvalidOperationException))]
		public void CloseAndMoveToFirstAttribute ()
		{
			reader = CreateReader ("{}");
			reader.Close ();
			reader.MoveToFirstAttribute ();
		}
Пример #14
0
		// hmm... [ExpectedException (typeof (InvalidOperationException))]
		public void CloseAndRead ()
		{
			reader = CreateReader ("{}");
			reader.Close ();
			reader.Read ();
		}
Пример #15
0
        public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace,
            XmlDictionaryReader headerReader)
        {
            try
            {
                WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString wsrmNs = wsrmFeb2005Dictionary.Namespace;
                XmlBuffer buffer = null;
                int index = 0;
                int depth = headerReader.Depth;
                headerReader.ReadFullStartElement(wsrmFeb2005Dictionary.SequenceFault, wsrmNs);

                while (headerReader.Depth > depth)
                {
                    if ((headerReader.NodeType == XmlNodeType.Element)
                        && (headerReader.NamespaceURI == detailNamespace)
                        && (headerReader.LocalName == detailName))
                    {
                        if (buffer != null)
                        {
                            return null;
                        }

                        buffer = new XmlBuffer(int.MaxValue);

                        try
                        {
                            index = buffer.SectionCount;
                            XmlDictionaryWriter writer = buffer.OpenSection(headerReader.Quotas);
                            // WriteNode moves the reader to the next sibling.
                            writer.WriteNode(headerReader, false);
                        }
                        finally
                        {
                            buffer.CloseSection();
                        }
                    }
                    else
                    {
                        if (headerReader.Depth == depth)
                            break;

                        headerReader.Read();
                    }
                }

                // Ensure at least one detail is found;
                if (buffer == null)
                {
                    return null;
                }

                // Close causes a state change.  It moves the buffer from Created to Reading.
                buffer.Close();
                XmlDictionaryReader detailReader = buffer.GetReader(index);
                return detailReader;
            }
            finally
            {
                headerReader.Close();
            }
        }
Пример #16
0
		public void CloseTwice ()
		{
			reader = CreateReader ("{}");
			reader.Close ();
			reader.Close ();
		}
Пример #17
0
        public static string GetSubcode(XmlDictionaryReader headerReader,
            ReliableMessagingVersion reliableMessagingVersion)
        {
            string subCode = null;

            try
            {
                WsrmFeb2005Dictionary wsrmFeb2005Dictionary = XD.WsrmFeb2005Dictionary;
                XmlDictionaryString wsrmNs = WsrmIndex.GetNamespace(reliableMessagingVersion);
                string ns;

                headerReader.ReadStartElement(wsrmFeb2005Dictionary.SequenceFault, wsrmNs);
                headerReader.ReadStartElement(wsrmFeb2005Dictionary.FaultCode, wsrmNs);
                XmlUtil.ReadContentAsQName(headerReader, out subCode, out ns);

                if (ns != WsrmIndex.GetNamespaceString(reliableMessagingVersion))
                    subCode = null;

                headerReader.ReadEndElement();

                while (headerReader.IsStartElement())
                    headerReader.Skip();

                headerReader.ReadEndElement();
            }
            finally
            {
                headerReader.Close();
            }

            return subCode;
        }
 public UnsupportedSelectionFault(Message message, FaultCode code, FaultReason reason, XmlDictionaryReader detailReader)
     : base(message, code, MakeConnectionConstants.Fault.UnsupportedSelectionFault, reason)
 {
     if (detailReader != null)
     {
         try
         {
             detailReader.ReadStartElement(MakeConnectionConstants.Fault.UnsupportedSelectionFault, MakeConnectionConstants.Namespace);
             this.elementName = detailReader.ReadContentAsString();
             detailReader.ReadEndElement();
         }
         finally
         {
             detailReader.Close();
         }
     }
 }