黑夜的狼

沮丧吗,那就是一种无病呻吟!留恋它就是一种高度近视!目光应该放得更远一点! 别不想飞,只是要一步跨过太平洋!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
public interface IXmlAnalyze
{
object GetXmlModel(Page page, string dataKey);
}
public class XmlAnalyze : IXmlAnalyze
{
public static DataSet XmlDataSet = new DataSet("XmlDataSet");
private string filePath = string.Empty;
public XmlAnalyze()
{
filePath
= "/Resources/XML/TextBoxSelect.xml";
}
/// <summary>
/// Relative path
/// </summary>
/// <param name="filePath"></param>
public XmlAnalyze(string filePath)
{
this.filePath = filePath;
}
protected void LoadXMLData(Page page)
{
string fileAbsPath = page.Server.MapPath(filePath);
//xmlDoc.Load(fileAbsPath);
XmlDataSet.ReadXml(fileAbsPath,XmlReadMode.ReadSchema);
}
public virtual object GetXmlModel(Page page, string dataKey)
{
if (!XmlDataSet.Tables.Contains("TextBoxSelect"))
{
LoadXMLData(page);
}
if (!XmlDataSet.Tables.Contains("TextBoxSelect")) return null;
foreach (DataRow dr in XmlDataSet.Tables["TextBoxSelect"].Rows)
{
if (dr["DataKey"].ToString().ToLower() == dataKey.ToLower())
{
TextBoxSelectXmlModel model
= new TextBoxSelectXmlModel();
model.DataKey
= dataKey;
model.TableName
= dr["TableName"].ToString();
model.ShowFields
= dr["ShowFields"].ToString();
model.Title
= dr["Title"].ToString();
model.ShowFieldsHeader
= dr["ShowFieldsHeader"].ToString();
model.ValueTextFields
= dr["ValueTextFields"].ToString();
model.FieldWidth
= dr["FieldWidth"].ToString();
model.HiddenFields
= dr["HiddenFields"].ToString();
model.SearchFields
= dr["SearchFields"].ToString();
model.SearchFieldsHeader
= dr["SearchFieldsHeader"].ToString();
model.Where
= dr["Where"].ToString();
model.Order
= dr["Order"].ToString();
model.CallBackParams
= dr["CallBackParams"].ToString();

return model;
}
}
return null;
}
}
[Serializable]
public class TextBoxSelectXmlModel
{
public string DataKey { get; set; }
public string TableName { get; set; }
public string Title { get; set; }
public string ShowFields { get; set; }
public string ShowFieldsHeader { get; set; }
public string ValueTextFields { get; set; }
public string FieldWidth { get; set; }
public string HiddenFields { get; set; }
public string SearchFields { get; set; }
public string SearchFieldsHeader { get; set; }
public string Where { get; set; }
public string Order { get; set; }
public string CallBackParams { get; set; }
}

这是XML文件的分析工具

posted on 2011-03-11 05:33  anncesky  阅读(154)  评论(0编辑  收藏  举报