Пример #1
0
        public static INodeFinder CreateFinder(string finder, TypeReflectorOptions options)
        {
            INodeFinder f = Factories.Finder.Create(finder);

            uint cur = (uint)f.BindingFlags;

            SetFlag(ref cur, options.FlattenHierarchy, (uint)BindingFlags.FlattenHierarchy);
            SetFlag(ref cur, options.ShowNonPublic, (uint)BindingFlags.NonPublic);
            SetFlag(ref cur, options.ShowInheritedMembers, (uint)BindingFlags.FlattenHierarchy);

            f.BindingFlags = (BindingFlags)cur;

            cur = (uint)f.FindMembers;
            SetFlag(ref cur, options.ShowBase, (uint)FindMemberTypes.Base);
            SetFlag(ref cur, options.ShowConstructors, (uint)FindMemberTypes.Constructors);
            SetFlag(ref cur, options.ShowEvents, (uint)FindMemberTypes.Events);
            SetFlag(ref cur, options.ShowFields, (uint)FindMemberTypes.Fields);
            SetFlag(ref cur, options.ShowInterfaces, (uint)FindMemberTypes.Interfaces);
            SetFlag(ref cur, options.ShowMethods, (uint)FindMemberTypes.Methods);
            SetFlag(ref cur, options.ShowProperties, (uint)FindMemberTypes.Properties);
            SetFlag(ref cur, options.ShowTypeProperties, (uint)FindMemberTypes.TypeProperties);
            SetFlag(ref cur, options.ShowMonoBroken, (uint)FindMemberTypes.MonoBroken);
            SetFlag(ref cur, options.VerboseOutput, (uint)FindMemberTypes.VerboseOutput);
            f.FindMembers = (FindMemberTypes)cur;

            return(f);
        }
Пример #2
0
        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
        public static INodeFormatter CreateFormatter(string formatter, TypeReflectorOptions options)
        {
            INodeFormatter nformatter = Factories.Formatter.Create(formatter);
            NodeFormatter  f          = nformatter as NodeFormatter;

            if (f != null)
            {
                f.InvokeMethods = options.InvokeMethods;
            }

            return(nformatter);
        }
Пример #4
0
        public static ITypeDisplayer CreateDisplayer(TypeReflectorOptions options)
        {
            ITypeDisplayer d = null;

            if (options.Displayer != string.Empty)
            {
                d = Factories.Displayer.Create(options.Displayer);
            }
            else
            {
                d = CreateDefaultDisplayer();
            }

            if (d != null)
            {
                d.MaxDepth = options.MaxDepth;
            }

            return(d);
        }
Пример #5
0
		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 ();
		}
Пример #6
0
		public static INodeFormatter CreateFormatter (string formatter, TypeReflectorOptions options)
		{
			INodeFormatter nformatter = Factories.Formatter.Create (formatter);
			NodeFormatter f = nformatter as NodeFormatter;

			if (f != null) {
				f.InvokeMethods = options.InvokeMethods;
			}

			return nformatter;
		}
Пример #7
0
		public static INodeFormatter CreateFormatter (TypeReflectorOptions options)
		{
			return CreateFormatter (options.Formatter, options);
		}
Пример #8
0
		public static INodeFinder CreateFinder (string finder, TypeReflectorOptions options)
		{
			INodeFinder f = Factories.Finder.Create (finder);

			uint cur = (uint) f.BindingFlags;

			SetFlag (ref cur, options.FlattenHierarchy, (uint) BindingFlags.FlattenHierarchy);
			SetFlag (ref cur, options.ShowNonPublic, (uint) BindingFlags.NonPublic);
			SetFlag (ref cur, options.ShowInheritedMembers, (uint) BindingFlags.FlattenHierarchy);

			f.BindingFlags = (BindingFlags) cur;

			cur = (uint) f.FindMembers;
			SetFlag (ref cur, options.ShowBase, (uint) FindMemberTypes.Base);
			SetFlag (ref cur, options.ShowConstructors, (uint) FindMemberTypes.Constructors);
			SetFlag (ref cur, options.ShowEvents, (uint) FindMemberTypes.Events);
			SetFlag (ref cur, options.ShowFields, (uint) FindMemberTypes.Fields);
			SetFlag (ref cur, options.ShowInterfaces, (uint) FindMemberTypes.Interfaces);
			SetFlag (ref cur, options.ShowMethods, (uint) FindMemberTypes.Methods);
			SetFlag (ref cur, options.ShowProperties, (uint) FindMemberTypes.Properties);
			SetFlag (ref cur, options.ShowTypeProperties, (uint) FindMemberTypes.TypeProperties);
			SetFlag (ref cur, options.ShowMonoBroken, (uint) FindMemberTypes.MonoBroken);
			SetFlag (ref cur, options.VerboseOutput, (uint) FindMemberTypes.VerboseOutput);
			f.FindMembers = (FindMemberTypes) cur;

			return f;
		}
Пример #9
0
		public static ITypeDisplayer CreateDisplayer (TypeReflectorOptions options)
		{
			ITypeDisplayer d = null;
			if (options.Displayer != string.Empty)
				d = Factories.Displayer.Create (options.Displayer);
			else
				d = CreateDefaultDisplayer ();

			if (d != null) {
				d.MaxDepth = options.MaxDepth;
			}

			return d;
		}
Пример #10
0
		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;
		}
Пример #11
0
 public static INodeFormatter CreateFormatter(TypeReflectorOptions options)
 {
     return(CreateFormatter(options.Formatter, options));
 }
Пример #12
0
        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();
        }