Exemplo n.º 1
0
        public PreViewColumnCollection GetColumns(string fileName)
        {
            fileName = string.Format("~/{0}/{1}.xml", Functions.GetAppConfigString("ConfigFilePath", "config"), fileName);
            fileName = Server.MapPath(fileName);
            XmlTextReader reader = new XmlTextReader(fileName);

            // 将reader移动到Where标签
            if (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName.Trim().Equals("table"))
            {
                PreViewColumnCollection collection = new PreViewColumnCollection();
                while (reader.Read())
                {
                    if (reader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    PreViewColumn column = new PreViewColumn();
                    switch (reader.LocalName.Trim())
                    {
                    case "td":
                        column.ID = reader.GetAttribute("id");
                        if (reader.GetAttribute("width") != null && reader.GetAttribute("width") != "")
                        {
                            column.Width = int.Parse(reader.GetAttribute("width"));
                        }

                        if (reader.GetAttribute("unit") != null && reader.GetAttribute("unit") != "")
                        {
                            column.Unit = reader.GetAttribute("unit");
                        }

                        if (reader.GetAttribute("align") != null && reader.GetAttribute("align") != "")
                        {
                            column.Align = reader.GetAttribute("align");
                        }

                        if (reader.GetAttribute("fomat") != null && reader.GetAttribute("fomat") != "")
                        {
                            column.Fomat = reader.GetAttribute("fomat");
                        }
                        column.Caption = reader.GetAttribute("caption");
                        break;
                    }

                    if (column.ID != null && column.ID != "")
                    {
                        collection.Add(column);
                    }
                }
                reader.Close();
                return(collection);
            }
            else
            {
                if (reader != null)
                {
                    reader.Close();
                }
                throw new ApplicationException(string.Format("配置文件({0})格式不正确!", fileName));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 判断集合中是否存在特定PreViewColumn对象
 /// </summary>
 /// <param name="value">一个PreViewColumn对象的实例</param>
 /// <returns>如果存在该实例,则返回true;否则返回false</returns>
 public bool Contains(PreViewColumn value)
 {
     return(List.Contains(value));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 从集合中删除一个PreViewColumn对象
 /// </summary>
 /// <param name="value">一个PreViewColumn对象的实例</param>
 public void Remove(PreViewColumn value)
 {
     List.Remove(value);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 在集合的特定位置上插入一个PreViewColumn对象
 /// </summary>
 /// <param name="value">一个PreViewColumn对象的实例</param>
 /// <param name="index">从0开始的索引值,在该位置处插入一个对象</param>
 public void Insert(PreViewColumn value, int index)
 {
     List.Insert(index, value);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 取得特定PreViewColumn对象的索引
 /// </summary>
 /// <param name="value">一个PreViewColumn对象的实例</param>
 /// <returns>如果找到该对象,则返回其索引;否则,返回-1</returns>
 public int IndexOf(PreViewColumn value)
 {
     return(List.IndexOf(value));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 向集合中添加一个PreViewColumn对象
 /// </summary>
 /// <param name="value">一个PreViewColumn对象的实例</param>
 /// <returns>新元素在集合中的位置索引</returns>
 public int Add(PreViewColumn value)
 {
     return(List.Add(value));
 }