Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        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);
        }
        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);
            }
        }
        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());
            }
        }