main.cs

来自「全功能c#编译器」· CS 代码 · 共 105 行

CS
105
字号
/*
 * Created by SharpDevelop.
 * User: Omnibrain
 * Date: 08.09.2004
 * Time: 22:57
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using System.Collections.Specialized;

using ICSharpCode.CsVbRefactory.Parser.CSharp;

namespace ICSharpCode.CsVbRefactory
{
	/// <summary>
	/// Description of Main.
	/// </summary>
	public class MainClass
	{
		public static StringCollection SearchDirectory(string directory, string filemask)
		{
			return SearchDirectory(directory, filemask, true);
		}
		
		public static StringCollection SearchDirectory(string directory, string filemask, bool searchSubdirectories)
		{
			StringCollection collection = new StringCollection();
			SearchDirectory(directory, filemask, collection, searchSubdirectories);
			return collection;
		}
		
		/// <summary>
		/// Finds all files which are valid to the mask <code>filemask</code> in the path
		/// <code>directory</code> and all subdirectories (if searchSubdirectories
		/// is true. The found files are added to the StringCollection
		/// <code>collection</code>.
		/// </summary>
		static void SearchDirectory(string directory, string filemask, StringCollection collection, bool searchSubdirectories)
		{
			try {
				string[] file = Directory.GetFiles(directory, filemask);
				foreach (string f in file) {
					collection.Add(f);
				}
				
				if (searchSubdirectories) {
					string[] dir = Directory.GetDirectories(directory);
					foreach (string d in dir) {
						try {
							SearchDirectory(d, filemask, collection, searchSubdirectories);
						} catch (Exception) {}
					}
				}
			} catch (Exception) {
			}
		}
		
		public static void Main(string[] args)
		{
//			Lexer lexer = new Lexer(new StringReader("'a"));
//			
//			if (lexer.NextToken().kind != Tokens.Literal) {
//				Console.WriteLine("Didn't recognize");
//			}
//			Console.WriteLine(lexer.Errors.ErrorOutput);
//			
			
//			string program = @"
//class Test
//{
//	Rectangle A()
//	{
//		double d = .5F;
//	}
//}
//";
//			ICSharpCode.CsVbRefactory.Parser.CSharp.Lexer lexer = new ICSharpCode.CsVbRefactory.Parser.CSharp.Lexer(new StringReader(program));
//			ICSharpCode.CsVbRefactory.Parser.CSharp.Parser parser = new ICSharpCode.CsVbRefactory.Parser.CSharp.Parser();
//			parser.Parse(lexer);
//			if (parser.Errors.ErrorOutput.Length > 0) {
//				Console.WriteLine(parser.Errors.ErrorOutput);
//				Console.ReadLine();
//			}
			
			string searchPath = Path.GetFullPath(Application.StartupPath + @"\..\..\..\..");
			StringCollection files = SearchDirectory(searchPath, "*.cs", true);
			ArrayList defs = new ArrayList();
			long oldSet = Environment.WorkingSet;
			
			DateTime start = DateTime.Now;
			foreach (string str in files) {
				ICSharpCode.CsVbRefactory.Parser.CSharp.Lexer lexer = new ICSharpCode.CsVbRefactory.Parser.CSharp.Lexer(new StreamReader(str));
				ICSharpCode.CsVbRefactory.Parser.CSharp.Parser parser = new ICSharpCode.CsVbRefactory.Parser.CSharp.Parser();
				parser.Parse(lexer);
			}
			Console.WriteLine("Time: " + (DateTime.Now - start) + " memory : " + (Environment.WorkingSet - oldSet));
		}
	}
}

⌨️ 快捷键说明

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