public void Load(IServiceProvider serviceProvider)
        {
            CodeMetricWindow codeMetricWindow = new CodeMetricWindow(serviceProvider);

            this.windowManager       = (IWindowManager)serviceProvider.GetService(typeof(IWindowManager));
            this.windowManager.Load += new EventHandler(this.WindowManager_Load);
            this.windowManager.Windows.Add("CodeMetricWindow", codeMetricWindow, "Code Metrics");

            this.assemblyManager = (IAssemblyManager)serviceProvider.GetService(typeof(IAssemblyManager));
            this.assemblyCache   = (IAssemblyCache)serviceProvider.GetService(typeof(IAssemblyCache));

            this.commandBarManager = (ICommandBarManager)serviceProvider.GetService(typeof(ICommandBarManager));
            this.separator         = this.commandBarManager.CommandBars["Tools"].Items.AddSeparator();
            this.button            = this.commandBarManager.CommandBars["Tools"].Items.AddButton("&Code Metrics", new EventHandler(this.Button_Click), Keys.Control | Keys.E);
        }
Exemplo n.º 2
0
        public void Run()
        {
            this.windowManager.Windows["CodeMetricWindow"].Visible = true;
            System.Windows.Forms.Application.DoEvents();

            CodeMetricWindow codeMetricWindow = (CodeMetricWindow)this.windowManager.Windows["CodeMetricWindow"].Content;

            codeMetricWindow.ClearAssemblyList();

            string[] assemblyFiles = this.GetArguments("Assembly");
            foreach (string assemblyFile in assemblyFiles)
            {
                IAssembly assembly = this.assemblyManager.LoadFile(assemblyFile);
                if (assembly != null)
                {
                    codeMetricWindow.CodeMetricManager.AddAssembly(assembly);
                }
            }

            codeMetricWindow.StartAnalysis();

            while (codeMetricWindow.IsAnalyzing())
            {
                System.Windows.Forms.Application.DoEvents();
            }

            string outputPath = this.GetArgument("OutputPath");

            if ((outputPath != null) && (outputPath.Length > 0))
            {
                using (TextWriter textWriter = File.CreateText(outputPath))
                {
                    codeMetricWindow.CodeMetricManager.Save(textWriter);
                }
            }

            this.windowManager.Windows["CodeMetricWindow"].Visible = false;
            System.Windows.Forms.Application.DoEvents();
        }