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


C# XmlWriteMode类代码示例

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


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

示例1: ToXmlText

        /// <summary>
        /// DataTable 내용을 Xml Text로 변경한다.
        /// </summary>
        /// <param name="table">Instance of DataTable</param>
        /// <param name="writeMode">Xml Text 생성 모드</param>
        /// <returns>생성된 Xml 문자열</returns>
        public static string ToXmlText(DataTable table, XmlWriteMode writeMode = XmlWriteMode.WriteSchema) {
            table.ShouldNotBeNull("table");

            if(IsDebugEnabled)
                log.Debug("Convert DataTable to Xml Text. table=[{0}], writeMode=[{1}]", table.TableName, writeMode);

            var sb = new StringBuilder();

            using(var writer = new StringWriter(sb))
                table.WriteXml(writer, writeMode);

            return sb.ToString();
        }
开发者ID:debop,项目名称:NFramework,代码行数:19,代码来源:DbFunc.Xml.cs

示例2: escribir

        public void escribir(string Peticion, string Status)
        {
            XmlWriteMode xml = new XmlWriteMode();
            //Creamos el nodo que deseamos insertar.
            XmlNode empleado = crearNodoXml(DateTime.Now.ToString(),Peticion,Status);

            //Obtenemos el nodo raiz del documento.
            XmlNode nodoRaiz = documento.DocumentElement;

            //Insertamos el nodo empleado al final del archivo
            nodoRaiz.InsertAfter(empleado, nodoRaiz.LastChild);   

            documento.Save("C:\\logBusqueda.xml");
        }
开发者ID:alonsonic,项目名称:Desarrollo,代码行数:14,代码来源:xmlLog.cs

示例3: WriteXml

 public void WriteXml(String fileName, XmlWriteMode mode)
 {
     WriteXml(fileName, mode, false);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:DataTable.cs

示例4: WriteXml

 /// <summary>
 ///     Writes the current data, and optionally the schema, for the <see cref="T:System.Data.DataTable"/> using the specified file and 
 ///     <see cref="T:System.Data.XmlWriteMode"/>. To write the schema, set the value for the <paramref name="mode"/> parameter to WriteSchema. 
 ///     To save the data for the table and all its descendants, set the <paramref name="writeHierarchy"/> parameter to true.
 /// </summary>
 /// <param name="fileName">
 ///     The name of the file to which the data will be written.
 /// </param>
 /// <param name="mode">
 ///     One of the <see cref="T:System.Data.XmlWriteMode"/> values.
 /// </param>
 /// <param name="writeHierarchy">
 ///     If true, write the contents of the current table and all its descendants. If false (the default value), write the data for the current table only.
 /// </param>
 public void WriteXml(string fileName,
                      XmlWriteMode mode,
                      bool writeHierarchy)
 {
     this.DataTableInstance.WriteXml(fileName, mode, writeHierarchy);
 }
开发者ID:YannBrulhart,项目名称:SystemWrapper-1,代码行数:20,代码来源:DataTableWrap.cs

示例5: WriteColumnAsAttribute

		internal static void WriteColumnAsAttribute (XmlWriter writer, XmlWriteMode mode, DataColumn col, DataRow row, DataRowVersion version)
		{
			if (!row.IsNull (col))
				WriteAttributeString (writer, mode, col.Namespace, col.Prefix, XmlHelper.Encode (col.ColumnName), WriteObjectXml (row[col, version]));
		}
开发者ID:t-ashula,项目名称:mono,代码行数:5,代码来源:DataSet.cs

示例6: WriteColumnAsElement

		internal static void WriteColumnAsElement (XmlWriter writer, XmlWriteMode mode, DataColumn col, DataRow row, DataRowVersion version)
		{
			string colnspc = null;
			object rowObject = row [col, version];

			if (rowObject == null || rowObject == DBNull.Value)
				return;

			if (col.Namespace != String.Empty)
				colnspc = col.Namespace;

			//TODO check if I can get away with write element string
			WriteStartElement (writer, mode, colnspc, col.Prefix, XmlHelper.Encode (col.ColumnName));	
			if (typeof (IXmlSerializable).IsAssignableFrom (col.DataType) 
			    || col.DataType == typeof (object)) {
				IXmlSerializable serializableObj = rowObject as IXmlSerializable;
				if (serializableObj == null)
					throw new InvalidOperationException ();
				((IXmlSerializable)rowObject).WriteXml (writer);				
			} else {
				writer.WriteString (WriteObjectXml (rowObject));
			}

			writer.WriteEndElement ();
		}
开发者ID:t-ashula,项目名称:mono,代码行数:25,代码来源:DataSet.cs

示例7: WriteTable

		internal static void WriteTable (XmlWriter writer,
			DataRow [] rows,
			XmlWriteMode mode,
			DataRowVersion version, bool skipIfNested)
		{
			if (rows.Length == 0) return;
			DataTable table = rows[0].Table;

			if (table.TableName == null || table.TableName == "")
				throw new InvalidOperationException("Cannot serialize the DataTable. DataTable name is not set.");

			//The columns can be attributes, hidden, elements, or simple content
			//There can be 0-1 simple content cols or 0-* elements
			System.Collections.ArrayList atts;
			System.Collections.ArrayList elements;
			DataColumn simple = null;

			SplitColumns (table, out atts, out elements, out simple);
			//sort out the namespacing

			foreach (DataRow row in rows) {
				if (skipIfNested) {
					// Skip rows that is a child of any tables.
					bool skip = false;
					for (int i = 0; i < table.ParentRelations.Count; i++) {
						DataRelation prel = table.ParentRelations [i];
						if (!prel.Nested)
							continue;
						if (row.GetParentRow (prel) != null) {
							skip = true;
							continue;
						}
					}
					if (skip)
						continue;
				}

				if (!row.HasVersion(version) ||
				   (mode == XmlWriteMode.DiffGram && row.RowState == DataRowState.Unchanged
				      && version == DataRowVersion.Original))
					continue;

				// First check are all the rows null. If they are we just write empty element
				bool AllNulls = true;
				foreach (DataColumn dc in table.Columns) {
					if (row [dc.ColumnName, version] != DBNull.Value) {
						AllNulls = false;
						break;
					}
				}

				// If all of the columns were null, we have to write empty element
				if (AllNulls) {
					writer.WriteElementString (XmlHelper.Encode (table.TableName), "");
					continue;
				}

				WriteTableElement (writer, mode, table, row, version);

				foreach (DataColumn col in atts)
					WriteColumnAsAttribute (writer, mode, col, row, version);

				if (simple != null) {
					writer.WriteString (WriteObjectXml (row[simple, version]));
				} else {
					foreach (DataColumn col in elements)
						WriteColumnAsElement (writer, mode, col, row, version);
				}

				foreach (DataRelation relation in table.ChildRelations) {
					if (relation.Nested)
						WriteTable (writer, row.GetChildRows (relation), mode, version, false);
				}

				writer.WriteEndElement ();
			}

		}
开发者ID:t-ashula,项目名称:mono,代码行数:78,代码来源:DataSet.cs

示例8: WriteTables

		private void WriteTables (XmlWriter writer, XmlWriteMode mode, DataTableCollection tableCollection, DataRowVersion version)
		{
			//WriteTable takes care of skipping a table if it has a
			//Nested Parent Relationship
			foreach (DataTable table in tableCollection)
				WriteTable ( writer, table, mode, version);
		}
开发者ID:t-ashula,项目名称:mono,代码行数:7,代码来源:DataSet.cs

示例9: WriteXml

 public void WriteXml(XmlWriter writer, XmlWriteMode mode)
 {
     IntPtr ptr;
     Bid.ScopeEnter(out ptr, "<ds.DataSet.WriteXml|API> %d#, mode=%d{ds.XmlWriteMode}\n", this.ObjectID, (int) mode);
     try
     {
         if (writer != null)
         {
             if (mode == XmlWriteMode.DiffGram)
             {
                 new NewDiffgramGen(this).Save(writer);
             }
             else
             {
                 new XmlDataTreeWriter(this).Save(writer, mode == XmlWriteMode.WriteSchema);
             }
         }
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:DataSet.cs

示例10: WriteXml

		public void WriteXml (XmlWriter writer, XmlWriteMode mode)
		{
			if (mode == XmlWriteMode.DiffGram) {
				SetRowsID();
				WriteDiffGramElement(writer);
			}

			// It should not write when there is no content to be written
			bool shouldOutputContent = (mode != XmlWriteMode.DiffGram);
			for (int n = 0; n < tableCollection.Count && !shouldOutputContent; n++)
				shouldOutputContent = tableCollection [n].Rows.Count > 0;

			if (shouldOutputContent) {
				WriteStartElement (writer, mode, Namespace, Prefix, XmlHelper.Encode (DataSetName));

				if (mode == XmlWriteMode.WriteSchema)
					DoWriteXmlSchema (writer);

				WriteTables (writer, mode, Tables, DataRowVersion.Default);
				writer.WriteEndElement ();
			}

			if (mode == XmlWriteMode.DiffGram) {
				if (HasChanges(DataRowState.Modified | DataRowState.Deleted)) {
					DataSet beforeDS = GetChanges (DataRowState.Modified | DataRowState.Deleted);
					WriteStartElement (writer, XmlWriteMode.DiffGram, XmlConstants.DiffgrNamespace, XmlConstants.DiffgrPrefix, "before");
					WriteTables (writer, mode, beforeDS.Tables, DataRowVersion.Original);
					writer.WriteEndElement ();
				}
			}

			if (mode == XmlWriteMode.DiffGram)
				writer.WriteEndElement (); // diffgr:diffgram

			writer.Flush ();
		}
开发者ID:t-ashula,项目名称:mono,代码行数:36,代码来源:DataSet.cs

示例11: WriteTableElement

		internal static void WriteTableElement (XmlWriter writer, XmlWriteMode mode, DataTable table, DataRow row, DataRowVersion version)
		{
			//sort out the namespacing
			string nspc = (table.Namespace.Length > 0 || table.DataSet == null) ? table.Namespace : table.DataSet.Namespace;

			WriteStartElement (writer, mode, nspc, table.Prefix, XmlHelper.Encode (table.TableName));

			if (mode == XmlWriteMode.DiffGram) {
				WriteAttributeString (writer, mode, XmlConstants.DiffgrNamespace, XmlConstants.DiffgrPrefix, "id", table.TableName + (row.XmlRowID + 1));
				WriteAttributeString (writer, mode, XmlConstants.MsdataNamespace, XmlConstants.MsdataPrefix, "rowOrder", XmlConvert.ToString (row.XmlRowID));
				string modeName = null;
				if (row.RowState == DataRowState.Modified)
					modeName = "modified";
				else if (row.RowState == DataRowState.Added)
					modeName = "inserted";

				if (version != DataRowVersion.Original && modeName != null)
					WriteAttributeString (writer, mode, XmlConstants.DiffgrNamespace, XmlConstants.DiffgrPrefix, "hasChanges", modeName);
			}
		}
开发者ID:t-ashula,项目名称:mono,代码行数:20,代码来源:DataSet.cs

示例12: WriteStartElement

		internal static void WriteStartElement (XmlWriter writer, XmlWriteMode mode, string nspc, string prefix, string name)
		{
			writer.WriteStartElement (prefix, name, nspc);
		}
开发者ID:t-ashula,项目名称:mono,代码行数:4,代码来源:DataSet.cs

示例13: WriteAttributeString

		internal static void WriteAttributeString (XmlWriter writer, XmlWriteMode mode, string nspc, string prefix, string name, string stringValue)
		{
			switch ( mode) {
			//	case XmlWriteMode.WriteSchema:
			//		writer.WriteAttributeString (prefix, name, nspc);
			//		break;
				case XmlWriteMode.DiffGram:
					writer.WriteAttributeString (prefix, name, nspc,stringValue);
					break;
				default:
					writer.WriteAttributeString (name, stringValue);
					break;
			};
		}
开发者ID:t-ashula,项目名称:mono,代码行数:14,代码来源:DataSet.cs

示例14: WriteIndividualTableContent

		internal void WriteIndividualTableContent (XmlWriter writer, DataTable table, XmlWriteMode mode)
		{
			if (mode == XmlWriteMode.DiffGram) {
				table.SetRowsID ();
				WriteDiffGramElement (writer);
			}

			WriteStartElement (writer, mode, Namespace, Prefix, XmlHelper.Encode (DataSetName));

			WriteTable (writer, table, mode, DataRowVersion.Default);

			if (mode == XmlWriteMode.DiffGram) {
				writer.WriteEndElement (); //DataSet name
				if (HasChanges (DataRowState.Modified | DataRowState.Deleted)) {

					DataSet beforeDS = GetChanges (DataRowState.Modified | DataRowState.Deleted);
					WriteStartElement (writer, XmlWriteMode.DiffGram, XmlConstants.DiffgrNamespace, XmlConstants.DiffgrPrefix, "before");
					WriteTable (writer, beforeDS.Tables [table.TableName], mode, DataRowVersion.Original);
					writer.WriteEndElement ();
				}
			}
			writer.WriteEndElement (); // DataSet name or diffgr:diffgram
		}
开发者ID:t-ashula,项目名称:mono,代码行数:23,代码来源:DataSet.cs


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