• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WriteState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WriteState的典型用法代码示例。如果您正苦于以下问题:C# WriteState类的具体用法?C# WriteState怎么用?C# WriteState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WriteState类属于命名空间,在下文中一共展示了WriteState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Close

 public override void Close()
 {
     if (!this.closed)
     {
         this.closed = true;
         this.state = WriteState.Closed;
         this.rawWritingEnabled = false;
     }
 }
开发者ID:ncdc,项目名称:qpid,代码行数:9,代码来源:RawXmlWriter.cs


示例2: RawXmlWriter

        public RawXmlWriter(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("Stream");
            }

            this.stream = stream;
            this.state = WriteState.Start;
        }
开发者ID:ncdc,项目名称:qpid,代码行数:10,代码来源:RawXmlWriter.cs


示例3: SetOutput

 protected void SetOutput(XmlStreamNodeWriter writer)
 {
     _inList = false;
     _writer = writer;
     _nodeWriter = writer;
     _writeState = WriteState.Start;
     _documentState = DocumentState.None;
     _nsMgr.Clear();
     if (_depth != 0)
     {
         _elements = null;
         _depth = 0;
     }
     _attributeLocalName = null;
     _attributeValue = null;
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:16,代码来源:XmlBaseWriter.cs


示例4: SetOutput

 protected void SetOutput(XmlStreamNodeWriter writer)
 {
     this.inList = false;
     this.writer = writer;
     this.nodeWriter = writer;
     this.writeState = WriteState.Start;
     this.documentState = DocumentState.None;
     this.nsMgr.Clear();
     if (this.depth != 0)
     {
         this.elements = null;
         this.depth = 0;
     }
     this.attributeLocalName = null;
     this.attributeValue = null;
     this.oldWriter = null;
     this.oldStream = null;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:18,代码来源:XmlBaseWriter.cs


示例5: setMode

 private static WriteState setMode(WriteState newState, WriteState fromState, StringBuilder sb)
 {
     if (newState == fromState)
         return newState;
     if (fromState != WriteState.Normal)
     {
         // needs to close the old state
         sb.Append(@"\X0\");
     }
     if (newState == WriteState.TwoBytes)
     {
         sb.Append(@"\X2\");
     }
     else if (newState == WriteState.FourBytes)
     {
         sb.Append(@"\X4\");
     }
     return newState;
 }
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:19,代码来源:IfcText.cs


示例6: Init

 private void Init(XmlNode root, bool clearCurrentContents)
 {
     this.root = root;
     if (clearCurrentContents)
         this.root.RemoveAll();
     if (root is XmlDocument)
     {
         owner = (XmlDocument)root;
         state = WriteState.Start;
     }
     else
     {
         owner = root.OwnerDocument;
         state = WriteState.Content;
     }
     current = root;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:17,代码来源:XmlNodeWriter.cs


示例7: WriteString

        /// <summary>
        /// Creates a System.Xml.XmlText node.  If the current node is already an XmlText
        /// node it appends the text to that node.
        /// </summary>
        public override void WriteString(string text)
        {
            XmlNode parent = current;
            if (state == WriteState.Attribute)
            {
                parent = ca;
            }
            else if (state == WriteState.Element)
            {
                state = WriteState.Content;
            }
            if (state != WriteState.Attribute && state != WriteState.Content)
                throw new InvalidOperationException("Writer is in the wrong state to be writing text content");

            XmlNode last = parent.LastChild;
            if (last == null || !(last is XmlText))
            {
                last = owner.CreateTextNode(text);
                parent.AppendChild(last);
            }
            else
            {
                XmlText t = last as XmlText;
                t.AppendData(text);
            }
        }
开发者ID:ewcasas,项目名称:DVTK,代码行数:30,代码来源:XmlNodeWriter.cs


示例8: WriteStartDocument

 /// <summary>
 /// Writes the XmlDeclaration node with a standalone attribute.  This is only allowed when the
 /// writer is in the Start state, which only happens if the writer was constructed with an
 /// XmlDocument object.
 /// </summary>
 /// <param name="standalone">If true, standalone attribute has value "yes" otherwise it has the value "no".</param>
 public override void WriteStartDocument(bool standalone)
 {
     if (state != WriteState.Start)
         throw new InvalidOperationException("Writer is not in the Start state or root node is not an XmlDocument object");
     current.AppendChild(owner.CreateXmlDeclaration("1.0", null, standalone ? "yes" : "no"));
     state = WriteState.Prolog;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:13,代码来源:XmlNodeWriter.cs


示例9: WriteRaw

        /// <summary>
        /// WriteRaw writes out the given string "unescaped", in other words it better be well formed XML markup.
        /// So for the XmlNodeWriter we parse this string and build the resulting tree, so it maps to setting the
        /// InnerXml property.  
        /// </summary>
        /// <param name="data"></param>
        public override void WriteRaw(string data)
        {
            if (data.IndexOf("<")<0)
            {
                WriteString(data);
                return;
            }

            switch (state)
            {
                case WriteState.Start:
                    goto case WriteState.Content;
                case WriteState.Prolog:
                    goto case WriteState.Content;
                case WriteState.Element:
                    state = WriteState.Content;
                    goto case WriteState.Content;
                case WriteState.Attribute:
                {
                    ArrayList saved = new ArrayList();
                    if (ca.HasChildNodes)
                    {
                        while (ca.FirstChild != null)
                        {
                            saved.Add(ca.FirstChild);
                            ca.RemoveChild(ca.FirstChild);
                        }
                    }
                    ca.InnerXml = data;
                    for (int i = saved.Count-1; i>=0; i--)
                    {
                        ca.PrependChild((XmlNode)saved[i]);
                    }
                }
                    break;
                case WriteState.Content:
                {
                    ArrayList saved = new ArrayList();
                    if (current.HasChildNodes)
                    {
                        while (current.FirstChild != null)
                        {
                            saved.Add(current.FirstChild);
                            current.RemoveChild(current.FirstChild);
                        }
                    }
                    current.InnerXml = data;
                    for (int i = saved.Count-1; i>=0; i--)
                    {
                        current.PrependChild((XmlNode)saved[i]);
                    }
                    state = WriteState.Content;
                }
                    break;
                case WriteState.Closed:
                    throw new InvalidOperationException("Writer is closed");
            }
        }
开发者ID:ewcasas,项目名称:DVTK,代码行数:64,代码来源:XmlNodeWriter.cs


示例10: WriteEntityRef

 /// <summary>
 /// Creates a System.Xml.XmlEntityReference node.
 /// </summary>
 /// <param name="name">The name of the entity reference</param>
 public override void WriteEntityRef(string name)
 {
     if (state == WriteState.Element)
         state = WriteState.Content;
     XmlNode n = current;
     if (state == WriteState.Attribute)
     {
         n = ca;
     }
     else if (state != WriteState.Content)
     {
         throw new InvalidOperationException("Invalid state '"+WriteState.ToString()+"' for entity reference");
     }
     n.AppendChild(owner.CreateEntityReference(name));
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:19,代码来源:XmlNodeWriter.cs


示例11: WriteEndDocument

 /// <summary>
 /// Closes any open elements and puts the writer back in the Start state.
 /// </summary>
 public override void WriteEndDocument()
 {
     current = root;
     state = WriteState.Start;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:8,代码来源:XmlNodeWriter.cs


示例12: Close

 public override void Close()
 {
     if (!IsClosed)
     {
         try
         {
             WriteEndDocument();
         }
         finally
         {
             try
             {
                 nodeWriter.Flush();
                 nodeWriter.Close();
             }
             finally
             {
                 writeState = WriteState.Closed;
                 if (depth != 0)
                 {
                     depth = 0;
                 }
             }
         }
     }
 }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:26,代码来源:XmlJsonWriter.cs


示例13: InitializeWriter

        void InitializeWriter()
        {
            nodeType = JsonNodeType.None;
            dataType = JsonDataType.None;
            isWritingDataTypeAttribute = false;
            wroteServerTypeAttribute = false;
            isWritingServerTypeAttribute = false;
            serverTypeValue = null;
            attributeText = null;

            if (depth != 0)
            {
                depth = 0;
            }
            if ((scopes != null) && (scopes.Length > JsonGlobals.maxScopeSize))
            {
                scopes = null;
            }

            // Can't let writeState be at Closed if reinitializing.
            writeState = WriteState.Start;
            endElementBuffer = false;
            indentLevel = 0;
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:24,代码来源:XmlJsonWriter.cs


示例14: WriteEndAttribute

		public override void WriteEndAttribute ()
		{
			if (state != WriteState.Attribute)
				throw StateError ("End of attribute");

			if (writer.Wrapped == preserver) {
				writer = writer.PreviousWrapper ?? new TextWriterWrapper (source, this);
				string value = preserver.ToString ();
				if (is_preserved_xmlns) {
					if (preserved_name.Length > 0 &&
					    value.Length == 0)
						throw ArgumentError ("Non-empty prefix must be mapped to non-empty namespace URI.");
					string existing = nsmanager.LookupNamespace (preserved_name, false);
					explicit_nsdecls.Add (preserved_name);
					if (open_count > 0) {

						if (v2 &&
						    elements [open_count - 1].Prefix == preserved_name &&
						    elements [open_count - 1].NS != value)
							throw new XmlException (String.Format ("Cannot redefine the namespace for prefix '{0}' used at current element", preserved_name));

						if (elements [open_count - 1].NS != String.Empty ||
						    elements [open_count - 1].Prefix != preserved_name) {
							if (existing != value)
								nsmanager.AddNamespace (preserved_name, value);
						}
					}
				} else {
					switch (preserved_name) {
					case "lang":
						if (open_count > 0)
							elements [open_count - 1].XmlLang = value;
						break;
					case "space":
						switch (value) {
						case "default":
							if (open_count > 0)
								elements [open_count - 1].XmlSpace = XmlSpace.Default;
							break;
						case "preserve":
							if (open_count > 0)
								elements [open_count - 1].XmlSpace = XmlSpace.Preserve;
							break;
						default:
							throw ArgumentError ("Invalid value for xml:space.");
						}
						break;
					}
				}
				writer.Write (value);
			}

			writer.Write (formatSettings.QuoteChar);
			
			if (writer.InBlock) {
				writer.MarkBlockEnd ();
				if (writer.Column > TextPolicy.FileWidth) {
					WriteIndentAttribute ();
					writer.WriteBlock (true);
					writer.AttributesPerLine++;
				} else {
					writer.WriteBlock (false);
				}
			}
			
			state = WriteState.Element;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:67,代码来源:XmlFormatterWriter.cs


示例15: WriteDocType

 /// <summary>
 /// Creates an System.Xml.XmlDocumentType node.
 /// </summary>
 public override void WriteDocType(string name, string pubid, string sysid, string subset)
 {
     if (state != WriteState.Prolog && state != WriteState.Start)
         throw new InvalidOperationException("Writer is not in the Start or Prolog state, or root node is not an XmlDocument object");
     if (owner.DocumentType != null)
         owner.RemoveChild(owner.DocumentType);
     owner.XmlResolver = null;
     current.AppendChild(owner.CreateDocumentType(name, pubid, sysid, subset));
     state = WriteState.Prolog;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:13,代码来源:XmlNodeWriter.cs


示例16: WriteEndAttribute

 /// <summary>
 /// Closes the previous WriteStartAttribute call.
 /// </summary>
 public override void WriteEndAttribute()
 {
     if (state != WriteState.Attribute)
         throw new InvalidOperationException("Writer is not in the Attribute state");
     state = WriteState.Element;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:9,代码来源:XmlNodeWriter.cs


示例17: Close

 internal virtual void Close( WriteState currentState ) {
     Close();
 }
开发者ID:uQr,项目名称:referencesource,代码行数:3,代码来源:XmlRawWriter.cs


示例18: WriteEndElement

 /// <summary>
 /// Closes the previous WriteStartElement call.
 /// </summary>
 public override void WriteEndElement()
 {
     if (current == root)
         throw new InvalidOperationException("Too many WriteEndElement calls have been made");
     current = current.ParentNode;
     state = WriteState.Content;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:10,代码来源:XmlNodeWriter.cs


示例19: InitializeWriter

        private void InitializeWriter()
        {
            _nodeType = JsonNodeType.None;
            _dataType = JsonDataType.None;
            _isWritingDataTypeAttribute = false;
            _wroteServerTypeAttribute = false;
            _isWritingServerTypeAttribute = false;
            _serverTypeValue = null;
            _attributeText = null;

            if (_depth != 0)
            {
                _depth = 0;
            }
            if ((_scopes != null) && (_scopes.Length > JsonGlobals.maxScopeSize))
            {
                _scopes = null;
            }

            // Can't let writeState be at Closed if reinitializing.
            _writeState = WriteState.Start;
            _endElementBuffer = false;
            _indentLevel = 0;
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:24,代码来源:XmlJsonWriter.cs


示例20: WriteProcessingInstruction

 /// <summary>
 /// Creates a System.Xml.XmlProcessingInstruction node.
 /// </summary>
 public override void WriteProcessingInstruction(string name, string text)
 {
     if (state == WriteState.Attribute || state == WriteState.Element)
         state = WriteState.Content;
     if (state != WriteState.Content && state != WriteState.Prolog && state != WriteState.Start)
         throw new InvalidOperationException("Writer is in the state '" + this.WriteState.ToString() + "' which is not valid for writing processing instructions");
     if (name == "xml")
     {
         XmlDocument doc2 = new XmlDocument();
         doc2.InnerXml = "<?xml " + text + "?><root/>";
         current.AppendChild(owner.ImportNode(doc2.FirstChild, true));
     }
     else
     {
         current.AppendChild(owner.CreateProcessingInstruction(name, text));
     }
     if (state == WriteState.Start) state = WriteState.Prolog;
 }
开发者ID:ewcasas,项目名称:DVTK,代码行数:21,代码来源:XmlNodeWriter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Writer类代码示例发布时间:2022-05-24
下一篇:
C# WriteConcern类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap