formatlist.cs

来自「代码模版 codtemplate」· CS 代码 · 共 69 行

CS
69
字号
using System;
using System.Collections;

namespace CodeTemplate
{
	internal class FormatList: IEnumerable
	{
		public FormatList()
		{
			m_formatList = new ArrayList();
		}

		public void Add(String name, String args)
		{
			m_formatList.Add(new Format(name, args));
		}

		public void Add(Format f)
		{
			m_formatList.Add(new Format(f));
		}

		public Boolean Empty
		{
			get { return m_formatList.Count == 0; }
		}

		public Format this[Int32 column]
		{
			get { return (Format) m_formatList[column]; }
			set { m_formatList[column] = value; }
		}

		private Int32 FindColumn(String name)
		{
			String nameUpper = name.ToUpper();
			for(Int32 i = 0; i < m_formatList.Count; ++i)
			{
				Format f = (Format)m_formatList[i];
				if(f.Name == nameUpper)
					return i;
			}

			return -1;
		}

		public Format this[String name]
		{
			get 
			{ 
				Int32 index = FindColumn(name);
				if(index >= 0 && index < m_formatList.Count)
					return (Format) m_formatList[index]; 

				else
					return null;
			}
			set { m_formatList[FindColumn(name)] = value; }
		}

		public IEnumerator GetEnumerator()
		{
			return m_formatList.GetEnumerator();
		}

		ArrayList m_formatList;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?