public lReceiptsSearchPanel() { m_searchCtrls = new lSearchCtrl_config[] { new lSearchCtrl_config { m_fieldName = "date", m_pos = new myPoint(1, 1), m_size = new mySize(1, 1) }, new lSearchCtrl_config { m_fieldName = "receipt_number", m_pos = new myPoint(1, 2), m_size = new mySize(1, 1), m_searchMatch = true } }; }
static void Main(string[] args) { test_w_point_size(); //test_getInstance(); //test_w_knowtype(); //test_w_resolver(); lTableInfo_config tbl1 = new lTableInfo_config(); tbl1.m_tblName = "receipts"; tbl1.m_tblAlias = "Bang thu"; tbl1.m_cols = new lColInfo[] { new lColInfo { m_alias = "alias", m_field = "field", m_lookupTbl = "lookupTbl", m_type = lColInfo.lColType.text }, new lColInfo { m_alias = "col2", m_field = "field", m_lookupTbl = "lookupTbl", m_type = lColInfo.lColType.text }, }; lTableInfo_config[] tbls = new lTableInfo_config[] { tbl1 }; DataContractJsonSerializer jsonz = new DataContractJsonSerializer(typeof(lTableInfo_config[])); jsonz.WriteObject(Console.OpenStandardOutput(), tbls); lReceiptsSearchPanel panel = new lReceiptsSearchPanel(); lSearchPanel_config panel_config = (lSearchPanel_config)panel; lSearchPanel_config[] panels = new lSearchPanel_config[] { panel_config }; //jsonz = new DataContractJsonSerializer(typeof(lSearchPanel_config[])); //jsonz.WriteObject(Console.OpenStandardOutput(), panels); XmlSerializer xs = new XmlSerializer(typeof(lColInfo)); xs.Serialize(Console.OpenStandardOutput(), tbl1.m_cols[0]); //xs.Deserialize() lSearchCtrl_config[] ctrls = new lSearchCtrl_config[] { new lSearchCtrl_config { m_fieldName = "date", m_pos = new myPoint(1, 1), m_size = new mySize(1, 1) }, new lSearchCtrl_config { m_fieldName = "receipt_number", m_pos = new myPoint(1, 2), m_size = new mySize(1, 1), m_searchMatch = true } }; DataContractJsonSerializerSettings jsonsettings = new DataContractJsonSerializerSettings(); jsonz = new DataContractJsonSerializer(typeof(lSearchCtrl_config[])); jsonz.WriteObject(Console.OpenStandardOutput(), ctrls); { DataContractSerializerSettings settings = new DataContractSerializerSettings(); XmlDictionary dic = new XmlDictionary(); settings.RootName = new XmlDictionaryString(dic, "tableInfo", 1); DataContractSerializer tmpz = new DataContractSerializer(typeof(lTableInfo_config), settings); tmpz.WriteObject(Console.OpenStandardOutput(), tbl1); } DataContractSerializer xmlz = new DataContractSerializer(typeof(lTableInfo_config[])); DataContractSerializer xmlz2 = new DataContractSerializer(typeof(lSearchCtrl_config[])); string pathXml = "config.xml"; XmlDocument doc = new XmlDocument(); XmlWriter wrt; //XmlReader rd; if (!System.IO.File.Exists(pathXml)) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; wrt = XmlWriter.Create("config.xml", settings); wrt.WriteStartElement("config"); wrt.WriteStartElement("dataPanel"); xmlz.WriteObjectContent(wrt, tbls); wrt.WriteEndElement(); wrt.WriteStartElement("searchPanel"); //xmlz2.WriteObjectContent(wrt, ctrls); //jsonz.WriteObject(wrt, ctrls); jsonz.WriteObjectContent(wrt, ctrls); wrt.WriteEndElement(); wrt.WriteEndElement(); wrt.Close(); } //doc.Load(pathXml); //XmlNode node = doc.SelectSingleNode("searchPanel"); XmlReader rd = XmlReader.Create(pathXml); rd.Read(); rd.ReadToFollowing("dataPanel"); var objs1 = xmlz.ReadObject(rd, false); rd.ReadToFollowing("searchPanel"); #if false rd.ReadToDescendant("root"); rd.MoveToContent(); rd.MoveToElement(); rd.ReadEndElement(); rd.Skip(); Console.WriteLine(rd.Name); var objs = jsonz.ReadObject(rd); #else var objs = jsonz.ReadObject(rd, false); #endif //XmlNode node = doc.FirstChild; //doc.SelectSingleNode("dataPanel"); }