// <Summary> // This method is used to export a DataRow object to xml. // </Summary> public string ExportDataRow(DataRow dataRow, int indent = 0) { // initial value string dataRowXml = ""; // locals string indentString = TextHelper.Indent(indent); string indentString2 = TextHelper.Indent(indent + 2); // If the dataRow object exists if (NullHelper.Exists(dataRow)) { // Create a StringBuilder StringBuilder sb = new StringBuilder(); // Append the indentString sb.Append(indentString); // Write the open dataRow node sb.Append("<DataRow>" + Environment.NewLine); // Write out each property // Write out the value for Changes sb.Append(indentString2); sb.Append("<Changes>" + dataRow.Changes + "</Changes>" + Environment.NewLine); // Write out the value for Delete sb.Append(indentString2); sb.Append("<Delete>" + dataRow.Delete + "</Delete>" + Environment.NewLine); // Write out the value for Fields // Create the FieldsWriter FieldsWriter fieldsWriter = new FieldsWriter(); // Export the Fields collection to xml string dataFieldXml = fieldsWriter.ExportList(dataRow.Fields, indent + 2); sb.Append(dataFieldXml); sb.Append(Environment.NewLine); // Write out the value for Index sb.Append(indentString2); sb.Append("<Index>" + dataRow.Index + "</Index>" + Environment.NewLine); // Write out the value for ParentTable sb.Append(indentString2); sb.Append("<ParentTable>" + dataRow.ParentTable + "</ParentTable>" + Environment.NewLine); // Append the indentString sb.Append(indentString); // Write out the close dataRow node sb.Append("</DataRow>" + Environment.NewLine); // set the return value dataRowXml = sb.ToString(); } // return value return(dataRowXml); }
// <Summary> // This method is used to export a StoredProcedure object to xml. // </Summary> public string ExportStoredProcedure(StoredProcedure storedProcedure, int indent = 0) { // initial value string storedProcedureXml = ""; // locals string indentString = TextHelper.Indent(indent); string indentString2 = TextHelper.Indent(indent + 2); // If the storedProcedure object exists if (NullHelper.Exists(storedProcedure)) { // Create a StringBuilder StringBuilder sb = new StringBuilder(); // Append the indentString sb.Append(indentString); // Write the open storedProcedure node sb.Append("<StoredProcedure>" + Environment.NewLine); // Write out each property // Write out the value for DoesNotHaveParameters sb.Append(indentString2); sb.Append("<DoesNotHaveParameters>" + storedProcedure.DoesNotHaveParameters + "</DoesNotHaveParameters>" + Environment.NewLine); // Write out the value for HasParameters sb.Append(indentString2); sb.Append("<HasParameters>" + storedProcedure.HasParameters + "</HasParameters>" + Environment.NewLine); // Write out the value for HasReturnSetSchema sb.Append(indentString2); sb.Append("<HasReturnSetSchema>" + storedProcedure.HasReturnSetSchema + "</HasReturnSetSchema>" + Environment.NewLine); // Write out the value for Parameters // Create the StoredProcedureParametersWriter StoredProcedureParametersWriter parametersWriter = new StoredProcedureParametersWriter(); // Export the Parameters collection to xml string storedProcedureParameterXml = parametersWriter.ExportList(storedProcedure.Parameters, indent + 2); sb.Append(storedProcedureParameterXml); sb.Append(Environment.NewLine); // Write out the value for ProcedureName sb.Append(indentString2); sb.Append("<ProcedureName>" + storedProcedure.ProcedureName + "</ProcedureName>" + Environment.NewLine); // Write out the value for ReturnSetSchema // Create the FieldsWriter FieldsWriter returnSetSchemaWriter = new FieldsWriter(); // Export the ReturnSetSchemas collection to xml string dataFieldXml = returnSetSchemaWriter.ExportList(storedProcedure.ReturnSetSchema, indent + 2); sb.Append(dataFieldXml); sb.Append(Environment.NewLine); // Write out the value for StoredProcedureType sb.Append(indentString2); sb.Append("<StoredProcedureType>" + storedProcedure.StoredProcedureType + "</StoredProcedureType>" + Environment.NewLine); // Write out the value for Text sb.Append(indentString2); sb.Append("<Text>" + storedProcedure.Text + "</Text>" + Environment.NewLine); // Append the indentString sb.Append(indentString); // Write out the close storedProcedure node sb.Append("</StoredProcedure>" + Environment.NewLine); // set the return value storedProcedureXml = sb.ToString(); } // return value return(storedProcedureXml); }
// <Summary> // This method is used to export a DataTable object to xml. // </Summary> public string ExportDataTable(DataTable dataTable, int indent = 0) { // initial value string dataTableXml = ""; // locals string indentString = TextHelper.Indent(indent); string indentString2 = TextHelper.Indent(indent + 2); // If the dataTable object exists if (NullHelper.Exists(dataTable)) { // Create a StringBuilder StringBuilder sb = new StringBuilder(); // Append the indentString sb.Append(indentString); // Write the open dataTable node sb.Append("<DataTable>" + Environment.NewLine); // Write out each property // Write out the value for Changes sb.Append(indentString2); sb.Append("<Changes>" + dataTable.Changes + "</Changes>" + Environment.NewLine); // Write out the value for CheckConstraints // Create the CheckConstraintsWriter CheckConstraintsWriter checkConstraintsWriter = new CheckConstraintsWriter(); // Export the CheckConstraints collection to xml string checkConstraintXml = checkConstraintsWriter.ExportList(dataTable.CheckConstraints, indent + 2); sb.Append(checkConstraintXml); sb.Append(Environment.NewLine); // Write out the value for ClassFileName sb.Append(indentString2); sb.Append("<ClassFileName>" + dataTable.ClassFileName + "</ClassFileName>" + Environment.NewLine); // Write out the value for ClassName sb.Append(indentString2); sb.Append("<ClassName>" + dataTable.ClassName + "</ClassName>" + Environment.NewLine); // Write out the value for ConnectionString sb.Append(indentString2); sb.Append("<ConnectionString>" + dataTable.ConnectionString + "</ConnectionString>" + Environment.NewLine); // Write out the value for ContainsBinaryData sb.Append(indentString2); sb.Append("<ContainsBinaryData>" + dataTable.ContainsBinaryData + "</ContainsBinaryData>" + Environment.NewLine); // Write out the value for CreateBindingCallback sb.Append(indentString2); sb.Append("<CreateBindingCallback>" + dataTable.CreateBindingCallback + "</CreateBindingCallback>" + Environment.NewLine); // Write out the value for CreateCollectionClass sb.Append(indentString2); sb.Append("<CreateCollectionClass>" + dataTable.CreateCollectionClass + "</CreateCollectionClass>" + Environment.NewLine); // Write out the value for Exclude sb.Append(indentString2); sb.Append("<Exclude>" + dataTable.Exclude + "</Exclude>" + Environment.NewLine); // Write out the value for Fields // Create the FieldsWriter FieldsWriter fieldsWriter = new FieldsWriter(); // Export the Fields collection to xml string dataFieldXml = fieldsWriter.ExportList(dataTable.Fields, indent + 2); sb.Append(dataFieldXml); sb.Append(Environment.NewLine); // Write out the value for ForeignKeys // Create the ForeignKeysWriter ForeignKeyConstraintsWriter foreignKeysWriter = new ForeignKeyConstraintsWriter(); // Export the ForeignKeys collection to xml string foreignKeyConstraintXml = foreignKeysWriter.ExportList(dataTable.ForeignKeys, indent + 2); sb.Append(foreignKeyConstraintXml); sb.Append(Environment.NewLine); // Write out the value for HasCheckConstraints sb.Append(indentString2); sb.Append("<HasCheckConstraints>" + dataTable.HasCheckConstraints + "</HasCheckConstraints>" + Environment.NewLine); // Write out the value for HasIndexes sb.Append(indentString2); sb.Append("<HasIndexes>" + dataTable.HasIndexes + "</HasIndexes>" + Environment.NewLine); // Write out the value for HasParentDatabase sb.Append(indentString2); sb.Append("<HasParentDatabase>" + dataTable.HasParentDatabase + "</HasParentDatabase>" + Environment.NewLine); // Write out the value for HasPrimaryKey sb.Append(indentString2); sb.Append("<HasPrimaryKey>" + dataTable.HasPrimaryKey + "</HasPrimaryKey>" + Environment.NewLine); // Write out the value for HasSchemaName sb.Append(indentString2); sb.Append("<HasSchemaName>" + dataTable.HasSchemaName + "</HasSchemaName>" + Environment.NewLine); // Write out the value for Indexes // Create the IndexesWriter IndexesWriter indexesWriter = new IndexesWriter(); // Export the Indexes collection to xml string dataIndexXml = indexesWriter.ExportList(dataTable.Indexes, indent + 2); sb.Append(dataIndexXml); sb.Append(Environment.NewLine); // Write out the value for IsView sb.Append(indentString2); sb.Append("<IsView>" + dataTable.IsView + "</IsView>" + Environment.NewLine); // Write out the value for Name sb.Append(indentString2); sb.Append("<Name>" + dataTable.Name + "</Name>" + Environment.NewLine); // Write out the value for ObjectNameSpaceName sb.Append(indentString2); sb.Append("<ObjectNameSpaceName>" + dataTable.ObjectNameSpaceName + "</ObjectNameSpaceName>" + Environment.NewLine); // Write out the value for ParentDatabase sb.Append(indentString2); sb.Append("<ParentDatabase>" + dataTable.ParentDatabase + "</ParentDatabase>" + Environment.NewLine); // Write out the value for PrimaryKey sb.Append(indentString2); sb.Append("<PrimaryKey>" + dataTable.PrimaryKey + "</PrimaryKey>" + Environment.NewLine); // Write out the value for Rows // Create the DataRowsWriter DataRowsWriter rowsWriter = new DataRowsWriter(); // Export the Rows collection to xml string dataRowXml = rowsWriter.ExportList(dataTable.Rows, indent + 2); sb.Append(dataRowXml); sb.Append(Environment.NewLine); // Write out the value for SchemaName sb.Append(indentString2); sb.Append("<SchemaName>" + dataTable.SchemaName + "</SchemaName>" + Environment.NewLine); // Write out the value for Scope sb.Append(indentString2); sb.Append("<Scope>" + dataTable.Scope + "</Scope>" + Environment.NewLine); // Write out the value for Serializable sb.Append(indentString2); sb.Append("<Serializable>" + dataTable.Serializable + "</Serializable>" + Environment.NewLine); // Write out the value for SQLGenerator sb.Append(indentString2); sb.Append("<SQLGenerator>" + dataTable.SQLGenerator + "</SQLGenerator>" + Environment.NewLine); // Write out the value for TableId sb.Append(indentString2); sb.Append("<TableId>" + dataTable.TableId + "</TableId>" + Environment.NewLine); // Write out the value for XmlFileName sb.Append(indentString2); sb.Append("<XmlFileName>" + dataTable.XmlFileName + "</XmlFileName>" + Environment.NewLine); // Append the indentString sb.Append(indentString); // Write out the close dataTable node sb.Append("</DataTable>" + Environment.NewLine); // set the return value dataTableXml = sb.ToString(); } // return value return(dataTableXml); }