コード例 #1
0
        private static CategoryEntry Load(List <Type> types, string config)
        {
            CategoryLine[] lines = CategoryLine.Load(config);

            if (lines.Length > 0)
            {
                int           index = 0;
                CategoryEntry root  = new CategoryEntry(null, lines, ref index);

                Fill(root, types);

                return(root);
            }

            return(new CategoryEntry());
        }
コード例 #2
0
		public CategoryEntry( CategoryEntry parent, CategoryLine[] lines, ref int index )
		{
			m_Parent = parent;

			string text = lines[index].Text;

			int start = text.IndexOf( '(' );

			if ( start < 0 )
				throw new FormatException( String.Format( "Input string not correctly formatted ('{0}')", text ) );

			m_Title = text.Substring( 0, start ).Trim();

			int end = text.IndexOf( ')', ++start );

			if ( end < start )
				throw new FormatException( String.Format( "Input string not correctly formatted ('{0}')", text ) );

			text = text.Substring( start, end-start );
			string[] split = text.Split( ';' );

			ArrayList list = new ArrayList();

			for ( int i = 0; i < split.Length; ++i )
			{
				Type type = ScriptCompiler.FindTypeByName( split[i].Trim() );

				if ( type == null )
					Console.WriteLine( "Match type not found ('{0}')", split[i].Trim() );
				else
					list.Add( type );
			}

			m_Matches = (Type[])list.ToArray( typeof( Type ) );
			list.Clear();

			int ourIndentation = lines[index].Indentation;

			++index;

			while ( index < lines.Length && lines[index].Indentation > ourIndentation )
				list.Add( new CategoryEntry( this, lines, ref index ) );

			m_SubCategories = (CategoryEntry[])list.ToArray( typeof( CategoryEntry ) );
			list.Clear();

			m_Matched = list;
		}