void LoadDesigner (Stream stream) { LoggingService.Info("ReportDesigner LoadDesigner_Start"); panel = CreatePanel(); defaultServiceContainer = CreateAndInitServiceContainer(); LoggingService.Info("Create DesignSurface and add event's"); designSurface = CreateDesignSurface(defaultServiceContainer); SetDesignerEvents(); var ambientProperties = new AmbientProperties(); defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties); defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); defaultServiceContainer.AddService(typeof(ITypeDiscoveryService),new TypeDiscoveryService()); defaultServiceContainer.AddService(typeof(IMenuCommandService), new ICSharpCode.Reporting.Addin.Services.MenuCommandService(panel, designSurface)); defaultServiceContainer.AddService(typeof(MemberRelationshipService),new DefaultMemberRelationshipService()); defaultServiceContainer.AddService(typeof(OpenedFile),base.PrimaryFile); LoggingService.Info("Load DesignerOptionService"); var designerOptionService = CreateDesignerOptions(); defaultServiceContainer.AddService( typeof( DesignerOptionService ), designerOptionService ); LoggingService.Info("Create ReportDesignerLoader"); loader = new ReportDesignerLoader(generator, stream); designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { // throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); LoggingService.Error("designer not loaded"); } //------------- defaultServiceContainer.AddService(typeof(INameCreationService),new NameCreationService()); var selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; /* undoEngine = new ReportDesignerUndoEngine(Host); */ var componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentAdded += OnComponentListChanged; componentChangeService.ComponentRemoved += OnComponentListChanged; componentChangeService.ComponentRename += OnComponentListChanged; this.Host.TransactionClosed += TransactionClose; UpdatePropertyPad(); hasUnmergedChanges = false; LoggingService.Info("ReportDesigner LoadDesigner_End"); }
public void ShowModelessDialog() { SettingsServiceArxNet settingsService = new SettingsServiceArxNet(); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new TestLoaderArxNet(new GuiTestEventDispatcherArxNet())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); ServiceManager.Services.InitializeServices(); AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); GuiOptionsArxNet guiOptions = new GuiOptionsArxNet(new string[0]); nUnitFormArxNet = new NUnitFormArxNet(guiOptions); c.Add(nUnitFormArxNet); nUnitFormArxNet.Show(); }
public static int Main(string[] args) { NUnitForm.CommandLineOptions command = new NUnitForm.CommandLineOptions(); GuiOptions parser = new GuiOptions(args); if(parser.Validate() && !parser.help) { if ( parser.cleanup ) { DomainManager.DeleteShadowCopyPath(); return 0; } if(!parser.NoArgs) { if (parser.IsAssembly) command.testFileName = parser.Assembly; command.configName = parser.config; command.testName = parser.fixture; command.noload = parser.noload; command.autorun = parser.run; if (parser.lang != null) Thread.CurrentThread.CurrentUICulture = new CultureInfo( parser.lang ); if ( parser.HasInclude ) { command.categories = parser.include; command.exclude = false; } else if ( parser.HasExclude ) { command.categories = parser.exclude; command.exclude = true; } } // Add Standard Services to ServiceManager ServiceManager.Services.AddService( new SettingsService() ); ServiceManager.Services.AddService( new DomainManager() ); ServiceManager.Services.AddService( new RecentFilesService() ); ServiceManager.Services.AddService( new TestLoader( new GuiTestEventDispatcher() ) ); ServiceManager.Services.AddService( new AddinRegistry() ); ServiceManager.Services.AddService( new AddinManager() ); // Initialize Services ServiceManager.Services.InitializeServices(); // Create container in order to allow ambient properties // to be shared across all top-level forms. AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService( typeof( AmbientProperties ), ambient ); NUnitForm form = new NUnitForm( command ); c.Add( form ); try { Application.Run( form ); } finally { ServiceManager.Services.StopAllServices(); } } else { string message = parser.GetHelpText(); UserMessage.DisplayFailure( message,"Help Syntax" ); return 2; } return 0; }
/// <devdoc> /// Override to GetService so we can route requests /// to the package's service provider. /// </devdoc> protected override object GetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } if (serviceType == typeof(AmbientProperties)) { if (_ambientProperties == null) { IUIService uis = GetService(typeof(IUIService)) as IUIService; _ambientProperties = new AmbientProperties(); _ambientProperties.Font = (Font)uis.Styles["DialogFont"]; } return _ambientProperties; } if (_provider != null) { object service = _provider.GetService(serviceType); if (service != null) { return service; } } return base.GetService(serviceType); }
/// <devdoc> /// Override to GetService so we can route requests /// to the package's service provider. /// </devdoc> protected override object GetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } if (_provider != null) { if (serviceType.IsEquivalentTo(typeof(AmbientProperties))) { if (_uis == null) { _uis = (IUIService)_provider.GetService(typeof(IUIService)); } if (_ambientProperties == null) { _ambientProperties = new AmbientProperties(); } if (_uis != null) { // update the _ambientProperties in case the styles have changed // since last time. _ambientProperties.Font = (Font)_uis.Styles["DialogFont"]; } return _ambientProperties; } object service = _provider.GetService(serviceType); if (service != null) { return service; } } return base.GetService(serviceType); }
private void LoadDesigner(Stream stream) { Console.WriteLine("LoadDesigner(Stream stream)"); LoggingService.Info("Form Designer: BEGIN INITIALIZE"); CreatePanel(); defaultServiceContainer = new DefaultServiceContainer(); defaultServiceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); defaultServiceContainer.AddService(typeof(IToolboxService),new ToolboxService()); defaultServiceContainer.AddService(typeof(IHelpService), new HelpService()); this.designSurface = CreateDesignSurface(defaultServiceContainer); designSurface.Loading += this.DesignerLoading; designSurface.Loaded += this.DesignerLoaded; designSurface.Flushed += this.DesignerFlushed; designSurface.Unloading += this.DesingerUnloading; AmbientProperties ambientProperties = new AmbientProperties(); defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties); defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); defaultServiceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new MenuCommandService(panel,this.designSurface )); defaultServiceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); //need this to resolve the filename and manipulate //ReportSettings in ReportDefinitionDeserializer.LoadObjectFromXmlDocument //if the filename in ReportSettings is different from load location defaultServiceContainer.AddService(typeof(OpenedFile),base.PrimaryFile); DesignerOptionService dos = new System.Windows.Forms.Design.WindowsFormsDesignerOptionService(); dos.Options.Properties.Find( "UseSmartTags", true ).SetValue( dos, true ); dos.Options.Properties.Find( "ShowGrid", true ).SetValue( dos, false ); dos.Options.Properties.Find( "UseSnapLines", true ).SetValue( dos, true ); defaultServiceContainer.AddService( typeof( DesignerOptionService ), dos ); this.loader = new ReportDesignerLoader(generator,stream); this.designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); } defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService()); ISelectionService selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; undoEngine = new ReportDesignerUndoEngine(Host); IComponentChangeService componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentAdded += OnComponentListChanged; componentChangeService.ComponentRemoved += OnComponentListChanged; componentChangeService.ComponentRename += OnComponentListChanged; this.Host.TransactionClosed += TransactionClose; UpdatePropertyPad(); hasUnmergedChanges = false; LoggingService.Info("Form Designer: END INITIALIZE"); }
public void LoadDesigner(string formFile) { UnloadDesigner(); DefaultServiceContainer serviceContainer = new DefaultServiceContainer(); serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService); serviceContainer.AddService(typeof(IHelpService), new HelpService()); serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService()); AmbientProperties ambientProperties = new AmbientProperties(); serviceContainer.AddService(typeof(AmbientProperties), ambientProperties); this.typeResolutionService = new TypeResolutionService(); serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService); serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService()); serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); designSurface = CreateDesignSurface(serviceContainer); designSurface.Loading += this.DesignerLoading; designSurface.Loaded += this.DesignerLoaded; designSurface.Flushed += this.DesignerFlushed; designSurface.Unloading += this.DesignerUnloading; designerResourceService = new DesignerResourceService(this);//roman// serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService); loader = new CodeDomHostLoader(this.Host, formFile, FileName); serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(Host)); ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(Host); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); designSurface.BeginLoad(loader); if (!designSurface.IsLoaded) { throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); } undoEngine = new FormsDesignerUndoEngine(Host); serviceContainer.AddService(typeof(UndoEngine), undoEngine); IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += ComponentChanged; componentChangeService.ComponentAdded += ComponentListChanged; componentChangeService.ComponentRemoved += ComponentListChanged; componentChangeService.ComponentRename += ComponentListChanged; this.Host.TransactionClosed += TransactionClose; ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; if (IsTabOrderMode) { // fixes SD2-1015 tabOrderMode = false; // let ShowTabOrder call the designer command again ShowTabOrder(); } UpdatePropertyPad(); hasUnmergedChanges = false; MakeDirty(); PropertyGrid grid = PropertyPad.Grid; var gridView = (Control)grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(grid); var edit = (Control)gridView.GetType().GetField("edit", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gridView); edit.KeyPress += PropertyPadEditorKeyPress; edit.ContextMenu = new ContextMenu(); }
public static int Main(string[] args) { // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService(); InternalTrace.Initialize("nunit-gui_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); log.Info("Starting NUnit GUI"); GuiOptions guiOptions = new GuiOptions(args); GuiAttachedConsole attachedConsole = null; if (guiOptions.console) { log.Info("Creating attached console"); attachedConsole = new GuiAttachedConsole(); } if (guiOptions.help) { MessageDisplay.Display(guiOptions.GetHelpText()); return 0; } if (!guiOptions.Validate()) { string message = "Error in command line"; MessageDisplay.Error(message + Environment.NewLine + Environment.NewLine + guiOptions.GetHelpText()); log.Error(message); return 2; } if (guiOptions.cleanup) { log.Info("Performing cleanup of shadow copy cache"); DomainManager.DeleteShadowCopyPath(); return 0; } if (!guiOptions.NoArgs) { if (guiOptions.lang != null) { log.Info("Setting culture to " + guiOptions.lang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(guiOptions.lang); } } try { // Add Standard Services to ServiceManager log.Info("Adding Services"); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); // Initialize Services log.Info("Initializing Services"); ServiceManager.Services.InitializeServices(); } catch (Exception ex) { MessageDisplay.FatalError("Service initialization failed.", ex); log.Error("Service initialization failed", ex); return 2; } // Create container in order to allow ambient properties // to be shared across all top-level forms. log.Info("Initializing AmbientProperties"); AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); log.Info("Constructing Form"); NUnitForm form = new NUnitForm(guiOptions); c.Add(form); try { log.Info("Starting Gui Application"); Application.Run(form); log.Info("Application Exit"); } catch( Exception ex ) { log.Error("Gui Application threw an excepion", ex ); throw; } finally { log.Info("Stopping Services"); ServiceManager.Services.StopAllServices(); } if (attachedConsole != null) { Console.WriteLine("Press Enter to exit"); Console.ReadLine(); attachedConsole.Close(); } log.Info("Exiting NUnit GUI"); InternalTrace.Close(); return 0; }
void LoadDesigner() { LoggingService.Info("Form Designer: BEGIN INITIALIZE"); DefaultServiceContainer serviceContainer = new DefaultServiceContainer(); serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService); serviceContainer.AddService(typeof(IHelpService), new HelpService()); serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService()); serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), new DesignerResourceService(this.resourceStore)); AmbientProperties ambientProperties = new AmbientProperties(); serviceContainer.AddService(typeof(AmbientProperties), ambientProperties); this.typeResolutionService = new TypeResolutionService(this.PrimaryFileName); serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService); serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService()); serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); serviceContainer.AddService(typeof(ProjectResourceService), new ProjectResourceService(ParserService.GetParseInformation(this.DesignerCodeFile.FileName).CompilationUnit.ProjectContent)); // Provide the ImageResourceEditor for all Image and Icon properties this.addedTypeDescriptionProviders.Add(typeof(Image), TypeDescriptor.AddAttributes(typeof(Image), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor)))); this.addedTypeDescriptionProviders.Add(typeof(Icon), TypeDescriptor.AddAttributes(typeof(Icon), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor)))); if (generator.CodeDomProvider != null) { serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider); } designSurface = CreateDesignSurface(serviceContainer); designSurface.Loading += this.DesignerLoading; designSurface.Loaded += this.DesignerLoaded; designSurface.Flushed += this.DesignerFlushed; designSurface.Unloading += this.DesignerUnloading; serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(this, designSurface)); ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(this, designSurface); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); this.loader = loaderProvider.CreateLoader(generator); designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); } undoEngine = new FormsDesignerUndoEngine(Host); serviceContainer.AddService(typeof(UndoEngine), undoEngine); IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += ComponentChanged; componentChangeService.ComponentAdded += ComponentListChanged; componentChangeService.ComponentRemoved += ComponentListChanged; componentChangeService.ComponentRename += ComponentListChanged; this.Host.TransactionClosed += TransactionClose; ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; if (IsTabOrderMode) { // fixes SD2-1015 tabOrderMode = false; // let ShowTabOrder call the designer command again ShowTabOrder(); } UpdatePropertyPad(); hasUnmergedChanges = false; LoggingService.Info("Form Designer: END INITIALIZE"); }
/* public void startNunitInSeparateAppDomain(string fileToLoad) { // var args = new[] { fileToLoad}; // (O2CorLib.dll) assembly that will be loaded and searched for Unit tests var args = new string[] {}; string exeToRun = Path.Combine(pathToNUnitBinFolder, "nunit-x86.exe"); appDomain = AppDomainUtils.newAppDomain_ExecuteAssembly("nUnitExec", pathToNUnitBinFolder, exeToRun, args); }*/ // ReSharper restore SuggestUseVarKeywordEvident /* public bool isAttached { get { return NUnitControl != null; } }*/ /* public Control NUnitControl { get { if (nUnitRunnerDll == null) loadNUnitDll(); //return null; var label = new Label {Text = "aaaaaaaaaa"}; return label; } }*/ // On this one lets not use var keywords (since that will make it easier to understand what is going on) // ReSharper disable SuggestUseVarKeywordEvident public Form getMainForm() { var nUnitGuiRunner = new O2ObjectFactory(NUnitGuiRunnerDll); var nUnitUtil = new O2ObjectFactory(nUnitUtilDll); var nUnitUikit = new O2ObjectFactory(nUnitUikitDll); // [code to implement] public static int Main(string[] args) // [code to implement] GuiOptions guiOptions = new GuiOptions(args); //var args = new[] { Config.getExecutingAssembly() }; // assembly that will be loaded and searched for Unit tests var args = new[] { nUnitUtilDll }; O2Object guiOptions = nUnitGuiRunner.ctor("GuiOptions", new[] { args }); // [code to implement] /* ServiceManager.Services.AddService(new SettingsService()) ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency());*/ O2Object serviceManager_Services = nUnitUtil.staticTypeGetProperty("ServiceManager", "Services"); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("SettingsService") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("DomainManager") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("RecentFilesService") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("TestLoader", new[] {nUnitUikit.ctor("GuiTestEventDispatcher")}) }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("AddinRegistry") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("AddinManager") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("TestAgency") }); // [code to implement] ServiceManager.Services.InitializeServices(); serviceManager_Services.call("InitializeServices"); // [code to implement] AppContainer container = new AppContainer(); O2Object container = nUnitUikit.ctor("AppContainer"); // [don't need to implement this one] AmbientProperties serviceInstance = new AmbientProperties(); var serviceInstance = new AmbientProperties(); // [code to implement] container.Services.AddService(typeof(AmbientProperties), serviceInstance); O2Object container_services = container.get("Services"); container_services.call("AddService", new object[] { typeof(AmbientProperties), serviceInstance }); // [code to implement] NUnitForm component = new NUnitForm(guiOptions); O2Object component = nUnitGuiRunner.ctor("NUnitForm", new[] { guiOptions }); // [code to implement] container.Add(component); container.call("Add", new object[] { component }); // [code to implement] new GuiAttachedConsole(); nUnitUikit.ctor("GuiAttachedConsole"); return (Form)component.Obj; /*return (form is Form) ? (Form) form.Obj : null; if (form is Form) return (Form) form.Obj; else return null; */ }
public static int Main(string[] args) { NTrace.Info( "Starting NUnit GUI" ); GuiOptions guiOptions = new GuiOptions(args); GuiAttachedConsole attachedConsole = null; if ( guiOptions.console ) attachedConsole = new GuiAttachedConsole(); if( !guiOptions.Validate() || guiOptions.help) { string message = guiOptions.GetHelpText(); UserMessage.DisplayFailure( message,"Help Syntax" ); return 2; } if ( guiOptions.cleanup ) { DomainManager.DeleteShadowCopyPath(); return 0; } if(!guiOptions.NoArgs) { if (guiOptions.lang != null) Thread.CurrentThread.CurrentUICulture = new CultureInfo( guiOptions.lang ); } // Add Standard Services to ServiceManager ServiceManager.Services.AddService( new SettingsService() ); ServiceManager.Services.AddService( new DomainManager() ); ServiceManager.Services.AddService( new RecentFilesService() ); ServiceManager.Services.AddService( new TestLoader( new GuiTestEventDispatcher() ) ); ServiceManager.Services.AddService( new AddinRegistry() ); ServiceManager.Services.AddService( new AddinManager() ); ServiceManager.Services.AddService( new TestAgency() ); // Initialize Services ServiceManager.Services.InitializeServices(); // Create container in order to allow ambient properties // to be shared across all top-level forms. AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService( typeof( AmbientProperties ), ambient ); NUnitForm form = new NUnitForm( guiOptions ); c.Add( form ); try { Application.Run( form ); } finally { ServiceManager.Services.StopAllServices(); } if ( attachedConsole != null ) { Console.WriteLine( "Press Enter to exit" ); Console.ReadLine(); attachedConsole.Close(); } NTrace.Info( "Exiting NUnit GUI" ); return 0; }
public int Main(string[] args) { if (nunitRunned) { Type type; FieldInfo field; //利用反射将含静态成员的类复位 //ServiceManager类复位 type = typeof(ServiceManager); field = type.GetField("services", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(ServiceManager.Services, new ArrayList()); field = type.GetField("serviceIndex", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(ServiceManager.Services, new Hashtable()); //Services类复位 type = typeof(Services); field = type.GetField("addinManager", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("addinRegistry", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("agency", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("domainManager", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("loader", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("projectService", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("recentFiles", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("userSettings", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); //ServicesArxNet类复位 type = typeof(ServicesArxNet); field = type.GetField("addinManager", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("addinRegistry", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("agency", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("domainManager", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("loader", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("projectService", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("recentFiles", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); field = type.GetField("userSettings", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.SetField); field.SetValue(null, null); } // Create SettingsService early so we know the trace level right at the start SettingsServiceArxNet settingsService = new SettingsServiceArxNet(); InternalTrace.Initialize("nunit-gui_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); log.Info("Starting NUnit GUI"); GuiOptionsArxNet guiOptions = new GuiOptionsArxNet(args); GuiAttachedConsole attachedConsole = null; if (guiOptions.console) { log.Info("Creating attached console"); attachedConsole = new GuiAttachedConsole(); } if (guiOptions.help) { MessageDisplay.Display(guiOptions.GetHelpText()); return 0; } if (!guiOptions.Validate()) { string message = "Error in command line"; MessageDisplay.Error(message + Environment.NewLine + Environment.NewLine + guiOptions.GetHelpText()); log.Error(message); return 2; } if (guiOptions.cleanup) { log.Info("Performing cleanup of shadow copy cache"); DomainManager.DeleteShadowCopyPath(); return 0; } if (!guiOptions.NoArgs) { if (guiOptions.lang != null) { log.Info("Setting culture to " + guiOptions.lang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(guiOptions.lang); } } try { // Add Standard Services to ServiceManager log.Info("Adding Services"); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new TestLoaderArxNet(new GuiTestEventDispatcherArxNet())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); // Initialize Services log.Info("Initializing Services"); ServiceManager.Services.InitializeServices(); } catch (SystemException ex) { MessageDisplay.FatalError("Service initialization failed.", ex); log.Error("Service initialization failed", ex); return 2; } // Create container in order to allow ambient properties // to be shared across all top-level forms. log.Info("Initializing AmbientProperties"); AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); log.Info("Constructing Form"); NUnitFormArxNet form = new NUnitFormArxNet(guiOptions); c.Add(form); try { log.Info("Starting Gui Application"); //FormsApplication.Run(form); Document doc = CADApplication.DocumentManager.MdiActiveDocument; CADApplication.ShowModelessDialog(doc.Window.Handle, form); //CADApplication.ShowModalDialog(form); //CADApplication.ShowModelessDialog(form); //log.Info("Application Exit"); } catch (SystemException ex) { log.Error("Gui Application threw an excepion", ex); //2012.12.23改 log.Info("Stopping Services"); ServiceManager.Services.StopAllServices(); ServiceManager.Services.ClearServices(); //2012.12.23改 throw; } /*finally { log.Info("Stopping Services"); ServiceManager.Services.StopAllServices(); } if (attachedConsole != null) { Console.WriteLine("Press Enter to exit"); Console.ReadLine(); attachedConsole.Close(); } log.Info("Exiting NUnit GUI"); InternalTrace.Close();*/ return 0; }