コード例 #1
0
ファイル: TypeReflectorApp.cs プロジェクト: retahc/old-code
 public static void FindTypes(ITypeDisplayer displayer, TypeLoader loader, IList types)
 {
     try {
         ICollection typesFound = loader.LoadTypes(types);
         Trace.WriteLine(
             string.Format("Types Found: {0}", typesFound.Count.ToString()));
         if (typesFound.Count > 0)
         {
             int curType = 1;
             foreach (Type type in typesFound)
             {
                 displayer.AddType(type, curType++, typesFound.Count);
             }
         }
         else
         {
             displayer.ShowError("Unable to find types.");
         }
     } catch (Exception e) {
         displayer.ShowError(string.Format("Unable to display type: {0}.",
                                           e.ToString()));
     }
 }
コード例 #2
0
ファイル: TypeReflectorApp.cs プロジェクト: emtees/old-code
		public static TypeLoader CreateLoader (TypeReflectorOptions options)
		{
			TypeLoader loader = new TypeLoader (options.Assemblies, options.References);
			loader.MatchBase = options.MatchBase;
			loader.MatchFullName = options.MatchFullName;
			loader.MatchClassName = options.MatchClassName;
			loader.MatchNamespace = options.MatchNamespace;
			loader.MatchMethodReturnType = options.MatchReturnType;
			return loader;
		}
コード例 #3
0
ファイル: TypeReflectorApp.cs プロジェクト: emtees/old-code
		public static void FindTypes (ITypeDisplayer displayer, TypeLoader loader, IList types)
		{
			try {
				ICollection typesFound = loader.LoadTypes (types);
				Trace.WriteLine (
					string.Format ("Types Found: {0}", typesFound.Count.ToString()));
				if (typesFound.Count > 0) {
					int curType = 1;
					foreach (Type type in typesFound) {
						displayer.AddType (type, curType++, typesFound.Count);
					}
				}
				else
					displayer.ShowError ("Unable to find types.");
			} catch (Exception e) {
				displayer.ShowError (string.Format ("Unable to display type: {0}.", 
					e.ToString()));
			}
		}
コード例 #4
0
ファイル: TypeReflectorApp.cs プロジェクト: retahc/old-code
        public static void Execute(string[] args)
        {
            InitFactories();

            TypeReflectorOptions options = new TypeReflectorOptions();

            bool quit = false;

            try {
                options.ParseOptions(args);
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                Console.WriteLine("See `{0} --help' for more information", ProgramOptions.ProgramName);
                return;
            }

            foreach (DictionaryEntry de in Factories.Displayer)
            {
                Trace.WriteLine(
                    string.Format("registered displayer: {0}={1}", de.Key,
                                  ((TypeFactoryEntry)de.Value).Type));
            }

            if (options.FoundHelp)
            {
                Console.WriteLine(options.OptionsHelp);
                quit = true;
            }

            if (options.DefaultAssemblies)
            {
                Console.WriteLine("The default search assemblies are:");
                foreach (string s in TypeReflectorOptions.GetDefaultAssemblies())
                {
                    Console.WriteLine("  {0}", s);
                }
                quit = true;
            }

            if (options.Version)
            {
                PrintVersion();
                quit = true;
            }

            if (quit)
            {
                return;
            }

            TraceArray("Explicit Assemblies: ", options.Assemblies);
            TraceArray("Referenced Assemblies: ", options.References);
            TraceArray("Search for Types: ", options.Types);

            TypeLoader loader = CreateLoader(options);

            TraceArray("Actual Search Assemblies: ", loader.Assemblies);
            TraceArray("Actual Search Assemblies: ", loader.References);

            ITypeDisplayer displayer = CreateDisplayer(options);

            if (displayer == null)
            {
                Console.WriteLine("Error: invalid displayer: " + options.Displayer);
                return;
            }

            if (loader.Assemblies.Count == 0 && loader.References.Count == 0 &&
                displayer.AssembliesRequired)
            {
                Console.WriteLine("Error: no assemblies specified.");
                Console.WriteLine("See `{0} --help' for more information",
                                  ProgramOptions.ProgramName);
                return;
            }

            INodeFormatter formatter = CreateFormatter(options);

            if (formatter == null)
            {
                Console.WriteLine("Error: invalid formatter: " + options.Formatter);
                return;
            }

            INodeFinder finder = CreateFinder(options);

            if (finder == null)
            {
                Console.WriteLine("Error: invalid finder: " + options.Finder);
                return;
            }

            displayer.Finder    = finder;
            displayer.Formatter = formatter;
            displayer.Options   = options;

            displayer.InitializeInterface();

            IList types = options.Types;

            if (types.Count == 0)
            {
                types = new string[] { "." }
            }
            ;

            // Find the requested types and display them.
            if (loader.Assemblies.Count != 0 || loader.References.Count != 0)
            {
                FindTypes(displayer, loader, types);
            }

            displayer.Run();
        }