当前位置: 首页>>代码示例>>C#>>正文


C# Error.AppendChild方法代码示例

本文整理汇总了C#中Error.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# Error.AppendChild方法的具体用法?C# Error.AppendChild怎么用?C# Error.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Error的用法示例。


在下文中一共展示了Error.AppendChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProtocolViolationException

        bool ISocketEventListener.OnRead(BaseSocket sock, byte[] buf, int offset, int length)
        {
            if (!m_running)
            {
                Debug.WriteLine("shutting down.  extra bytes received.");
                return false;
            }

            Debug.WriteLine("OnRead: " + ((HttpSocket)sock).Name);

            // Parse out the first start tag or empty element, which will be
            // <body/>.
            XpNet.UTF8Encoding e = new XpNet.UTF8Encoding();
            XpNet.ContentToken ct = new XpNet.ContentToken();
            XpNet.TOK tok = e.tokenizeContent(buf, offset, offset + length, ct);

            if ((tok != XpNet.TOK.START_TAG_WITH_ATTS) &&
                (tok != XpNet.TOK.EMPTY_ELEMENT_WITH_ATTS))
            {
                m_listener.OnError(this, new ProtocolViolationException("Invalid HTTP binding XML.  Token type: " + tok.ToString()));
                return false;
            }

            string name = ENC.GetString(buf,
                                        offset + e.MinBytesPerChar,
                                        ct.NameEnd - offset - e.MinBytesPerChar);

            Debug.Assert(name == "body");
            Body b = new Body(m_doc);
            string val;
            int start;
            int end;
            for (int i = 0; i < ct.getAttributeSpecifiedCount(); i++)
            {
                start = ct.getAttributeNameStart(i);
                end = ct.getAttributeNameEnd(i);
                name = ENC.GetString(buf, start, end - start);

                start = ct.getAttributeValueStart(i);
                end = ct.getAttributeValueEnd(i);
                val = ENC.GetString(buf, start, end - start);

                if (!name.StartsWith("xmlns"))
                    b.SetAttribute(name, val);
            }

            if (b.SID != null)
                m_sid = b.SID;

            if (m_sid == null)
            {
                m_listener.OnError(this, new ProtocolViolationException("Invalid HTTP binding.  No SID."));
                return false;
            }

            if (b.Wait != -1)
                m_wait = b.Wait;

            if (StartStream)
            {
                StartStream = false;
                m_authID = b.AuthID;
                if (!FakeReceivedStream())
                    return false;
            }

            lock (m_queue)
            {
                if (!m_running)
                    return false;

                if (b.Type == BodyType.terminate)
                {
                    m_running = false;
                    Error err = new Error(m_doc);
                    err.AppendChild(m_doc.CreateElement(b.Condition.ToString(), URI.STREAM_ERROR));
                    byte[] sbuf = ENC.GetBytes(err.OuterXml);
                    m_listener.OnRead(this, sbuf, 0, sbuf.Length);
                    sbuf = ENC.GetBytes("</stream:stream>");
                    m_listener.OnRead(this, sbuf, 0, sbuf.Length);
                    Close();
                    return false;
                }
            }


            if (tok == XpNet.TOK.START_TAG_WITH_ATTS)
            {
                // len(</body>) = 7
                start = ct.TokenEnd;
                if (m_listener.OnRead(this, buf, start, offset + length - start - 7))
                    RequestRead();
            }
            else
                RequestRead();

            lock (m_queue)
            {
                Monitor.Pulse(m_queue);
            }
//.........这里部分代码省略.........
开发者ID:sq5gvm,项目名称:JabberNet-2010,代码行数:101,代码来源:XEP124Socket.cs

示例2: GetStreamError

 /// <summary>
 /// Get an error stanza with a urn:ietf:params:xml:ns:xmpp-streams condition.
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="type"></param>
 /// <param name="code"></param>
 /// <param name="condition"></param>
 /// <returns></returns>
 public static Error GetStreamError(XmlDocument doc, ErrorType type, int code, string condition)
 {
     Error error = new Error(doc);
     error.ErrorType = type;
     error.Code = code;
     error.AppendChild(doc.CreateElement(condition, URI.STREAM));
     return error;
 }
开发者ID:sq5gvm,项目名称:JabberNet-2010,代码行数:16,代码来源:Error.cs


注:本文中的Error.AppendChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。