Beispiel #1
0
 public ServiceDebugHost(Service service, string serviceName,
     ServiceSettings settings, Logger logger)
 {
     this.serviceName = serviceName;
     this.service = service;
     this.service.Logger = logger;
     this.serviceSettings = settings;
     this.logger = logger;
 }
        public ServiceRuntimeHost(Service service, string serviceName,
            ServiceSettings serviceSettings, Logger logger)
        {
            this.service = service;
            this.service.Logger = logger;
            this.logger = logger;
            this.serviceSettings = serviceSettings;

            // set Microsoft service base properties
            this.ServiceName = serviceName;
            this.AutoLog = true;
            this.CanHandlePowerEvent = false;
            this.CanHandleSessionChangeEvent = false;
            this.CanPauseAndContinue = false;
            this.CanStop = true;
            this.CanShutdown = true;
        }
Beispiel #3
0
        private static XElement SerializeServiceSettings(ServiceSettings service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }
            XElement xService = new XElement("service");

            xService.SetAttributeValue("name", service.Name);
            xService.SetAttributeValue("type", SerializeType(service.TypeClass, service.TypeAssembly));

            xService.Add(SerializeSettings(service.Settings));
            xService.Add(SerializeInstallerSettings(service.InstallerSettings));
            xService.Add(SerializeTraceLoggerSettings(service.TraceLoggerSettings));

            return xService;
        }
Beispiel #4
0
        private static ServiceSettings DeserializeServiceSettings(XElement xService)
        {
            ServiceSettings result = new ServiceSettings();
            // service.@name
            result.Name = xService.Attribute(XName.Get("name")).Value;

            // service.@type
            string typeClass;
            string typeAssembly;
            DeserializeType(xService, out typeClass, out typeAssembly);
            result.TypeClass = typeClass;
            result.TypeAssembly = typeAssembly;

            // service.settings
            XElement xSettings = xService.XPathSelectElement("./settings");
            result.Settings = DeserializeSettings(xSettings);

            // service.installer
            XElement xInstaller = xService.XPathSelectElement("./installer");
            result.InstallerSettings = DeserializeInstallerSettings(xInstaller);

            // service.trace-logger
            XElement xTraceLogger = xService.XPathSelectElement("./trace-logger");
            result.TraceLoggerSettings = DeserializeTraceLoggerSettings(xTraceLogger);

            return result;
        }