コード例 #1
0
ファイル: ServiceManager.cs プロジェクト: pmq20/mono_forked
        public IService GetService(Type serviceType)
        {
            IService theService = (IService)serviceIndex[serviceType];

            if (theService == null)
            {
                foreach (IService service in services)
                {
                    // TODO: Does this work on Mono?
                    if (serviceType.IsInstanceOfType(service))
                    {
                        serviceIndex[serviceType] = service;
                        theService = service;
                        break;
                    }
                }
            }

            if (theService == null)
            {
                NTrace.Error(string.Format("Requested service {0} was not found", serviceType.FullName));
            }
            else
            {
                NTrace.Info(string.Format("Request for service {0} satisfied by {1}", serviceType.Name, theService.GetType().Name));
            }

            return(theService);
        }
コード例 #2
0
        private void OnLoadStateButtonClick(NEventArgs arg1)
        {
            if (m_MemoryStream == null)
            {
                return;
            }

            m_MemoryStream.Seek(0, SeekOrigin.Begin);

            try
            {
                NDomNodeDeserializer deserializer = new NDomNodeDeserializer();

                NTestNode root = (NTestNode)deserializer.LoadFromStream(m_MemoryStream, ENPersistencyFormat.Binary)[0];

/*				NDocumentBlock root = (NDocumentBlock)deserializer.LoadFromStream(m_MemoryStream, ENPersistencyFormat.Binary)[0];
 *
 *                              if (root != null)
 *                              {
 *                                      m_RichText.Document = new NRichTextDocument(root);
 *                              }*/
            }
            catch (Exception ex)
            {
                NTrace.WriteLine(ex.Message);
            }
        }
コード例 #3
0
        public void Register(string path)
        {
            try
            {
                AssemblyName assemblyName = new AssemblyName();
                assemblyName.Name     = Path.GetFileNameWithoutExtension(path);
                assemblyName.CodeBase = path;
                Assembly assembly = Assembly.Load(assemblyName);
                NTrace.Debug("Loaded " + Path.GetFileName(path));

                foreach (Type type in assembly.GetExportedTypes())
                {
                    if (type.GetCustomAttributes(typeof(NUnitAddinAttribute), false).Length == 1)
                    {
                        Addin addin = new Addin(type);
                        addinRegistry.Register(addin);
                        NTrace.Debug("Registered addin: " + addin.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                // NOTE: Since the gui isn't loaded at this point,
                // the trace output will only show up in Visual Studio
                NTrace.Error("Failed to load" + path, ex);
            }
        }
コード例 #4
0
        private void UpdateTabPages()
        {
            errorsTabMenuItem.Checked = settings.GetSetting("Gui.ResultTabs.DisplayErrorsTab", true);
            notRunTabMenuItem.Checked = settings.GetSetting("Gui.ResultTabs.DisplayNotRunTab", true);

            NTrace.Debug("Updating tab pages");
            updating = true;

            tabControl.TabPages.Clear();

            if (errorsTabMenuItem.Checked)
            {
                tabControl.TabPages.Add(errorTab);
            }
            if (notRunTabMenuItem.Checked)
            {
                tabControl.TabPages.Add(notRunTab);
            }

            displayController.UpdatePages();

            tabControl.SelectedIndex = settings.GetSetting("Gui.ResultTabs.SelectedTab", 0);

            updating = false;
        }
コード例 #5
0
ファイル: NExampleBase.cs プロジェクト: Nevron-Software/NOV
        /// <summary>
        /// Gets a rich text box that show the syntax highlighted source code of the example.
        /// </summary>
        /// <returns></returns>
        protected virtual NWidget GetExampleSource()
        {
            NRichTextView richText = new NRichTextView();

            richText.HRuler.Visibility = ENVisibility.Collapsed;
            richText.VRuler.Visibility = ENVisibility.Collapsed;
            richText.ReadOnly          = true;

            try
            {
                // Decompress the source code of the example
                Type exampleType = Schema.DomType.Type;
                NSourceCodeDecompressor decompressor = new NSourceCodeDecompressor(exampleType);
                SourceCodeStream.Position = 0;
                NCompression.DecompressZip(SourceCodeStream, decompressor);

                // Highlight the decompressed source code
                NSyntaxHighlighter syntaxHighlighter = new NSyntaxHighlighter();

                MemoryStream decompressedStream = decompressor.GetSourceCodeStream();
                if (decompressedStream != null)
                {
                    Stream htmlStream = syntaxHighlighter.Highlight(decompressedStream);

                    // Load the colorized source code in the source code rich text view
                    richText.LoadFromStream(htmlStream, new NHtmlTextFormat());
                }
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Failed to get example source.", ex);
            }

            return(richText);
        }
コード例 #6
0
        private Assembly Load(string path)
        {
            Assembly assembly = null;

            // Change currentDirectory in case assembly references unmanaged dlls
            using (new DirectorySwapper(Path.GetDirectoryName(path)))
            {
                // Throws if this isn't a managed assembly or if it was built
                // with a later version of the same assembly.
                AssemblyName.GetAssemblyName(Path.GetFileName(path));

                // TODO: Figure out why we can't load using the assembly name
                // in all cases. Might be a problem with the tests themselves.
                assembly = Assembly.Load(Path.GetFileNameWithoutExtension(path));

                if (assembly != null)
                {
                    CoreExtensions.Host.InstallAdhocExtensions(assembly);
                }

                NTrace.Info("Loaded assembly " + assembly.FullName, "'TestAssemblyBuilder'");

                return(assembly);
            }
        }
コード例 #7
0
        public void Start()
        {
            NTrace.Info("Starting");
            this.channel = ServerUtilities.GetTcpChannel();
            NTrace.Debug("Acquired Tcp Channel");

            try
            {
                this.agency = (TestAgency)Activator.GetObject(typeof(TestAgency), agencyUrl);
                NTrace.DebugFormat("Connected to TestAgency at {0}", agencyUrl);
            }
            catch (Exception ex)
            {
                NTrace.ErrorFormat("Unable to connect to test agency at {0}", agencyUrl);
                NTrace.Error(ex.Message);
            }

            try
            {
                this.agency.Register(this, ProcessId);
                NTrace.Debug("Registered with TestAgency");
            }
            catch (Exception ex)
            {
                NTrace.Error("Failed to register with TestAgency", ex);
            }
        }
コード例 #8
0
ファイル: ServiceManager.cs プロジェクト: pmq20/mono_forked
 public void InitializeServices()
 {
     foreach (IService service in services)
     {
         NTrace.Info("Initializing " + service.GetType().Name);
         service.InitializeService();
     }
 }
コード例 #9
0
 public void DestroyRunner()
 {
     NTrace.Debug("Destroying ProcessRunner");
     if (myRunner != null)
     {
         myRunner.Dispose();
     }
 }
コード例 #10
0
 public void Stop()
 {
     NTrace.Info("Stopping");
     lock ( theLock )
     {
         if (this.channel != null)
         {
             ChannelServices.UnregisterChannel(this.channel);
         }
         Monitor.PulseAll(theLock);
     }
 }
コード例 #11
0
        public void ReleaseAgent(TestAgent agent)
        {
            AgentRecord r = agentData[agent.Id];

            if (r == null)
            {
                NTrace.Error(string.Format("Unable to release agent {0} - not in database", agent.Id));
            }
            else
            {
                r.Status = AgentStatus.Ready;
                NTrace.Debug("Releasing agent " + agent.Id.ToString());
            }
        }
コード例 #12
0
        private AgentRecord FindAvailableRemoteAgent(AgentType type)
        {
            foreach (AgentRecord r in agentData)
            {
                if (r.Status == AgentStatus.Ready)
                {
                    NTrace.DebugFormat("Reusing agent {0}", r.Id);
                    r.Status = AgentStatus.Busy;
                    return(r);
                }
            }

            return(null);
        }
コード例 #13
0
        private AgentRecord CreateRemoteAgent(AgentType type, int waitTime)
        {
            int pid = LaunchAgentProcess();

            NTrace.DebugFormat("Waiting for agent {0} to register", pid);
            while (waitTime > 0)
            {
                int pollTime = Math.Min(200, waitTime);
                Thread.Sleep(pollTime);
                waitTime -= pollTime;
                if (agentData[pid].Agent != null)
                {
                    NTrace.DebugFormat("Returning new agent record {0}", pid);
                    return(agentData[pid]);
                }
            }

            return(null);
        }
コード例 #14
0
        void OnSaveStateButtonClick(NEventArgs arg1)
        {
            try
            {
                m_MemoryStream = new MemoryStream();

                NSerializer serializer          = new NSerializer();
                PersonInfo  serializationObject = new PersonInfo(
                    m_NameTextBox.Text,
                    m_AddressTextBox.Text,
                    m_MarriedCheckBox.Checked,
                    m_GenderComboBox.SelectedIndex == 0 ? GenderSingleton.Male : GenderSingleton.Female,
                    m_OtherTextBox.Text);
                serializer.SaveToStream(serializationObject, m_MemoryStream, ENPersistencyFormat.Binary);
            }
            catch (Exception ex)
            {
                NTrace.WriteLine(ex.Message);
            }
        }
コード例 #15
0
        static void Main()
        {
            try
            {
                // install Nevron Open Vision for WPF
                NNovApplicationInstaller.Install(
                    NTextModule.Instance,
                    NChartModule.Instance,
                    NDiagramModule.Instance,
                    NScheduleModule.Instance,
                    NGridModule.Instance,
                    NBarcodeModule.Instance);

                // show the main window
                Window window = new Window();
                window.Title       = "Nevron Open Vision Examples for WPF";
                window.WindowState = WindowState.Maximized;

                // load icon from stream
                using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("Nevron.Nov.Examples.Wpf.Resources.NevronOpenVision.ico"))
                {
                    // Decode the icon from the stream and set the first frame to the BitmapSource
                    BitmapDecoder decoder = IconBitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
                    BitmapSource  source  = decoder.Frames[1];

                    // set image source
                    window.Icon = source;
                }

                // place a NOV UI Element that contains an NExampleContent widget
                window.Content = new NNovWidgetHost <NExamplesContent>();

                // show the window
                Application app = new Application();
                app.Run(window);
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Exception in Main", ex);
            }
        }
コード例 #16
0
        private void LoadExample(NXmlElement element)
        {
            string groupNamespace = NExamplesHomePage.GetNamespace(element);
            string name           = element.GetAttributeValue("name");
            string type           = groupNamespace + "." + element.GetAttributeValue("type");

            try
            {
                type = "Nevron.Nov.Examples." + type;
                Type exampleType = Type.GetType(type);
                if (exampleType != null)
                {
                    NDomType domType = NDomType.FromType(exampleType);
                    NDebug.Assert(domType != null, "The example type:" + type + " is not a valid type");

                    // Create the example
                    DateTime     start   = DateTime.Now;
                    NExampleBase example = domType.CreateInstance() as NExampleBase;
                    example.Title = name;
                    example.Initialize();
                    m_Splitter.Pane2.Content = example;

                    string stats = "Example created in: " + (DateTime.Now - start).TotalSeconds + " seconds, ";

                    // Evaluate the example
                    start = DateTime.Now;
                    OwnerDocument.Evaluate();
                    stats += " evaluated in: " + (DateTime.Now - start).TotalSeconds + " seconds";

                    m_StatusLabel.Text = stats;
                }

                // Set the breadcrumb
                CreateBreadcrumb(element);
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Failed to load example", ex);
                m_Splitter.Pane2.Content = new NErrorPanel("Failed to load example. Exception was: " + ex.Message);
            }
        }
コード例 #17
0
        private void OnSaveStateButtonClick(NEventArgs arg1)
        {
            try
            {
                m_MemoryStream = new MemoryStream();

                NDomNodeSerializer serializer = new NDomNodeSerializer();

                NTestNode testNode = new NTestNode();

                testNode.SetValue(NTestNode.ExtendedPropertyEx, false);
                serializer.SaveToStream(new NNode[] { testNode }, m_MemoryStream, ENPersistencyFormat.Binary);

//				serializer.SaveToStream(new NNode[] { m_RichText.Content }, m_MemoryStream, ENPersistencyFormat.Binary);

                m_LoadStateButton.Enabled = true;
            }
            catch (Exception ex)
            {
                NTrace.WriteLine(ex.Message);
            }
        }
コード例 #18
0
        private void OnShowDesignerClick(NEventArgs args)
        {
            try
            {
                NNode         node         = (NNode)args.TargetNode.Tag;
                NEditorWindow editorWindow = NEditorWindow.CreateForInstance(
                    node,
                    null,
                    OwnerWindow,
                    null);

                if (node is NStyleNodeCollectionTree)
                {
                    editorWindow.PreferredSize = new NSize(500, 360);
                }

                editorWindow.Open();
            }
            catch (Exception ex)
            {
                NTrace.WriteException("OnShowDesignerClick failed.", ex);
            }
        }
コード例 #19
0
ファイル: NTemplate.cs プロジェクト: Nevron-Software/NOV
        /// <summary>
        /// Creates the template in the specified document
        /// </summary>
        /// <remarks>
        /// This method will call the CreateTemplate method.
        /// The call will be embraced in a transaction with the specified TransactionDescription
        /// </remarks>
        /// <param name="document">document in which to create the template</param>
        /// <returns>true if the template was successfully created, otherwise false</returns>
        public virtual bool Create(NDrawingDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            document.StartHistoryTransaction(m_sTransactionDescription);

            try
            {
                CreateTemplate(document);
            }
            catch (Exception ex)
            {
                NTrace.WriteLine("Failed to create template. Exception was: " + ex.Message);
                document.RollbackHistoryTransaction();
                return(false);
            }

            document.CommitHistoryTransaction();
            return(true);
        }
コード例 #20
0
        protected override NWidget CreateExampleControls()
        {
            NList <NPropertyEditor> editors = NDesigner.GetDesigner(m_MenuBar).CreatePropertyEditors(
                m_MenuBar,
                NMenuBar.OrientationProperty,
                NMenuBar.OpenPopupsOnMouseInProperty,
                NMenuBar.ClosePopupsOnMouseOutProperty
                );

            NStackPanel stack = new NStackPanel();

            stack.FillMode = ENStackFillMode.Last;
            stack.FitMode  = ENStackFitMode.Last;

            for (int i = 0; i < editors.Count; i++)
            {
                stack.Add(editors[i]);
            }

            m_EventsLog = new NExampleEventsLog();
            stack.Add(m_EventsLog);
            NTrace.WriteLine("Create Menu Example Controls");
            return(new NUniSizeBoxGroup(stack));
        }
コード例 #21
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // install Nevron Open Vision for Windows Forms
                NNovApplicationInstaller.Install(
                    NTextModule.Instance,
                    NChartModule.Instance,
                    NDiagramModule.Instance,
                    NScheduleModule.Instance,
                    NGridModule.Instance,
                    NBarcodeModule.Instance);

                // show the main form
                bool startWithNovWindow = false;
                if (startWithNovWindow)
                {
                    // create a NOV top level window
                    NTopLevelWindow window = NApplication.CreateTopLevelWindow();
                    window.BackgroundFill = new NColorFill(NColor.White);
                    window.Content        = new NExamplesContent();
                    window.Closed        += OnWindowClosed;
                    window.Title          = "Nevron Open Vision Examples for Windows Forms";
                    window.AllowXResize   = true;
                    window.AllowYResize   = true;
                    window.ShowInTaskbar  = true;
                    window.Modal          = true;
                    window.PreferredSize  = new NSize(500, 500);
                    window.StartPosition  = ENWindowStartPosition.CenterScreen;
                    window.Open();

                    // run the application
                    ApplicationContext context = new ApplicationContext();
                    Application.Run(context);
                }
                else
                {
                    // create a WinForms form
                    Form form = new Form();

                    // set form icon
                    using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("Nevron.Nov.Examples.WinForm.Resources.NevronOpenVision.ico"))
                    {
                        Icon icon = new Icon(stream);
                        form.Icon = icon;
                    }

                    // set form title and state
                    form.Text        = "Nevron Open Vision Examples for Windows Forms";
                    form.WindowState = FormWindowState.Maximized;

                    // place a NOV WinForms Control that contains an NExampleContent widget
                    NNovWidgetHost <NExamplesContent> host = new NNovWidgetHost <NExamplesContent>();
                    host.Dock = DockStyle.Fill;
                    form.Controls.Add(host);

                    // run the form
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Exception in Main", ex);
            }
        }
コード例 #22
0
        private void OnTestSerializationButtonClick(NEventArgs arg)
        {
            ENPersistencyFormat persistencyFormat = (ENPersistencyFormat)arg.TargetNode.Tag;
            NStopwatch          stopwatch;

            try
            {
                Type   nodeType = typeof(NNode);
                Type[] types = nodeType.Assembly.GetTypes();
                int    nodeCount = 0, successfullySerialized = 0;

                stopwatch = NStopwatch.StartNew();
                StringBuilder output = new StringBuilder();
                for (int i = 0, count = types.Length; i < count; i++)
                {
                    Type type = types[i];

                    // not a NNode type, abstract or generic => skip
                    if (!nodeType.IsAssignableFrom(type) || type.IsAbstract || type.IsGenericType)
                    {
                        continue;
                    }

                    NNode node;
                    try
                    {
                        nodeCount++;
                        NNode typeInstance = (NNode)Activator.CreateInstance(type);

                        // Serialize
                        MemoryStream       memoryStream = new MemoryStream();
                        NDomNodeSerializer serializer   = new NDomNodeSerializer();
                        serializer.SerializeDefaultValues = true;
                        serializer.SaveToStream(new NNode[] { typeInstance }, memoryStream, persistencyFormat);

                        // Deserialize to check if the serialization has succeeded
                        NDomNodeDeserializer deserializer = new NDomNodeDeserializer();
                        memoryStream = new MemoryStream(memoryStream.ToArray());
                        node         = deserializer.LoadFromStream(memoryStream, persistencyFormat)[0];

                        output.AppendLine("Sucessfully serialized node type [" + type.Name + "].");
                        successfullySerialized++;
                    }
                    catch (Exception ex)
                    {
                        output.AppendLine("Failed to serialize node type [" + type.Name + "]. Exception was [" + ex.Message + "]");
                    }
                }

                stopwatch.Stop();

                output.AppendLine("==================================================");
                output.AppendLine("Nodes serialized: " + successfullySerialized.ToString() + " of " + nodeCount.ToString());
                output.AppendLine("Time elapsed: " + stopwatch.ElapsedMilliseconds.ToString() + " ms");

                m_TextBox.Text = output.ToString();
                m_TextBox.SetCaretPos(new NTextPosition(m_TextBox.Text.Length, false));
                m_TextBox.EnsureCaretVisible();
            }
            catch (Exception ex)
            {
                NTrace.WriteLine(ex.Message);
            }

            // Restore the default cursor
            this.OwnerWindow.Cursor = null;
        }
コード例 #23
0
ファイル: ServiceManager.cs プロジェクト: pmq20/mono_forked
 public void AddService(IService service)
 {
     services.Add(service);
     NTrace.Debug("Added " + service.GetType().Name);
 }
コード例 #24
0
ファイル: AppEntry.cs プロジェクト: wsgan001/asegrp
        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);
        }
コード例 #25
0
        public static int Main(string[] args)
        {
            NTrace.Info("NUnit-console.exe starting");

            ConsoleOptions options = new ConsoleOptions(args);

            if (!options.nologo)
            {
                WriteCopyright();
            }

            if (options.help)
            {
                options.Help();
                return(ConsoleUi.OK);
            }

            if (options.NoArgs)
            {
                Console.Error.WriteLine("fatal error: no inputs specified");
                options.Help();
                return(ConsoleUi.OK);
            }

            if (!options.Validate())
            {
                foreach (string arg in options.InvalidArguments)
                {
                    Console.Error.WriteLine("fatal error: invalid argument: {0}", arg);
                }
                options.Help();
                return(ConsoleUi.INVALID_ARG);
            }

            // 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() );
            ServiceManager.Services.AddService(new AddinRegistry());
            ServiceManager.Services.AddService(new AddinManager());
            // TODO: Resolve conflict with gui testagency when running
            // console tests under the gui.
            //ServiceManager.Services.AddService( new TestAgency() );

            // Initialize Services
            ServiceManager.Services.InitializeServices();

            try
            {
                ConsoleUi consoleUi = new ConsoleUi();
                return(consoleUi.Execute(options));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return(ConsoleUi.FILE_NOT_FOUND);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception:\n{0}", ex.ToString());
                return(ConsoleUi.UNEXPECTED_ERROR);
            }
            finally
            {
                if (options.wait)
                {
                    Console.Out.WriteLine("\nHit <enter> key to continue");
                    Console.ReadLine();
                }

                NTrace.Info("NUnit-console.exe terminating");
            }
        }
コード例 #26
0
 protected override TestRunner CreateRunner(int runnerID)
 {
     myRunner = new ProcessRunner(runnerID);
     NTrace.Debug("Creating ProcessRunner");
     return(myRunner);
 }