/// <summary> /// Serializes the <i>Obj</i> to an XML string. /// </summary> /// <param name="Obj"> /// The object to serialize.</param> /// <param name="ObjType">The object type.</param> /// <returns> /// The serialized object XML string. /// </returns> /// <remarks> /// The <see cref="PrettyPrint" /> property provides /// an easy-to-read formatted XML string. /// </remarks> public static string ToXml(object Obj, System.Type ObjType) { XmlSerializer ser; ser = new XmlSerializer(ObjType, PACTSerializer.TargetNamespace); MemoryStream memStream; memStream = new MemoryStream(); XmlTextWriter xmlWriter; xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8); if (PACTSerializer.PrettyPrint) { xmlWriter.Formatting = Formatting.Indented; xmlWriter.Indentation = 1; xmlWriter.IndentChar = Convert.ToChar(9); } xmlWriter.Namespaces = true; ser.Serialize(xmlWriter, Obj, PACTSerializer.GetNamespaces()); xmlWriter.Close(); memStream.Close(); string xml; xml = Encoding.UTF8.GetString(memStream.GetBuffer()); xml = xml.Substring(xml.IndexOf(Convert.ToChar(60))); xml = xml.Substring(0, (xml.LastIndexOf(Convert.ToChar(62)) + 1)); return(xml); }
/// <summary> /// Serializes the <i>Obj</i> to an XML string. /// </summary> /// <param name="Obj"> /// The object to serialize.</param> /// <param name="ObjType">The object type.</param> /// <returns> /// The serialized object XML string. /// </returns> /// <remarks> /// The <see cref="PrettyPrint" /> property provides /// an easy-to-read formatted XML string. /// </remarks> public static string ToXml(object Obj, System.Type ObjType, bool AllowNameSpace) { XmlSerializer ser; if (AllowNameSpace) { ser = new XmlSerializer(ObjType, PACTSerializer.TargetNamespace); } else { ser = new XmlSerializer(ObjType, ""); } MemoryStream memStream; memStream = new MemoryStream(); XmlWriterSettings xmlws = new XmlWriterSettings(); xmlws.OmitXmlDeclaration = true; xmlws.Encoding = Encoding.UTF8; XmlWriter xmlWriter = XmlWriter.Create(memStream, xmlws); //xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8); //xmlWriter.Settings.OmitXmlDeclaration = true; //if (PACTSerializer.PrettyPrint) //{ // xmlWriter.Formatting = Formatting.Indented; // xmlWriter.Indentation = 1; // xmlWriter.IndentChar = Convert.ToChar(9); //} // xmlWriter.Namespaces = true; if (AllowNameSpace) { ser.Serialize(xmlWriter, Obj, PACTSerializer.GetNamespaces()); } else { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); ser.Serialize(xmlWriter, Obj, ns); } xmlWriter.Close(); memStream.Close(); string xml; xml = Encoding.UTF8.GetString(memStream.GetBuffer()); xml = xml.Substring(xml.IndexOf(Convert.ToChar(60))); xml = xml.Substring(0, (xml.LastIndexOf(Convert.ToChar(62)) + 1)); return(xml); }
/// <summary> /// Creates a new <see cref="PACTRequest" /> /// object from an XML string. /// </summary> /// <param name="Xml"> /// XML string to create the object from.</param> /// <returns> /// A <see cref="PACTRequest" /> object. /// </returns> public static TreeColumn FromXml(string Xml) { return((TreeColumn)(PACTSerializer.FromXml(Xml, typeof(TreeColumn)))); }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); if (GetFeatureID(this) == 0) { return; } CommonClient oDMCommon = new CommonClient(); DataTable dt = oDMCommon.GetDataTable("SELECT * FROM AdmnLayoutLists WHERE ID=" + GetFeatureID(this).ToString(), GetCompanyDBIndex(this).ToString()); oDMCommon.Close(); strTable = dt.Rows[0]["TableName"].ToString(); strPrimaryKey = dt.Rows[0]["PrimaryKey"].ToString(); _Where = dt.Rows[0]["WhereClause"].ToString(); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(dt.Rows[0]["LayoutXML"].ToString()); XmlNodeList xList = xDoc.SelectNodes("XML/Columns/TreeColumn"); TreeColumn oCol; oColumns = new List <TreeColumn>(); _Query = "SELECT " + strPrimaryKey; this.IsEditable = true; Microsoft.Windows.Controls.DataGridTextColumn dgCol; dgCol = new Microsoft.Windows.Controls.DataGridTextColumn(); dgCol.Header = strPrimaryKey; dgCol.Binding = new Binding(strPrimaryKey); dgCol.Visibility = System.Windows.Visibility.Hidden; this.Columns.Add(dgCol); for (int i = 0; i < xList.Count; i++) { oCol = (TreeColumn)PACTSerializer.FromXml(xList[i].OuterXml, typeof(TreeColumn)); _Query += "," + oCol.Name; dgCol = new Microsoft.Windows.Controls.DataGridTextColumn(); dgCol.Header = oCol.Label; if (xList.Count == 1) { if (this.Width > 0) { dgCol.Width = this.Width; } else { dgCol.Width = oCol.Width; } } else { dgCol.Width = oCol.Width; } dgCol.CanUserResize = false; dgCol.CanUserSort = false; dgCol.Binding = new Binding(oCol.Name); iWidth += oCol.Width; this.Columns.Add(dgCol); oColumns.Add(oCol); } _Query += " FROM " + strTable; if (this.SelectedValue != null) { valueSelected = true; } //this.SelectedValue = new Binding(strPrimaryKey); this.SelectedValuePath = strPrimaryKey; }