Пример #1
0
        private XmlStub.HostModeType GetXmlFromHostMode(HostMode hostMode)
        {
            switch (hostMode)
            {
            case HostMode.General:
                return(awzcore.Serialization.XmlStub.HostModeType.general);

            case HostMode.GUI:
                return(awzcore.Serialization.XmlStub.HostModeType.gui);

            case HostMode.Console:
                return(awzcore.Serialization.XmlStub.HostModeType.console);

            case HostMode.WindowsService:
                return(awzcore.Serialization.XmlStub.HostModeType.winservice);

            case HostMode.WebServer:
                return(awzcore.Serialization.XmlStub.HostModeType.webserver);

            case HostMode.Browser:
                return(awzcore.Serialization.XmlStub.HostModeType.browser);

            default:
                return(awzcore.Serialization.XmlStub.HostModeType.general);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="coreScannerService"></param>
        /// <param name="mode"></param>
        /// <param name="scannerId"></param>
        /// <param name="isSilent"></param>
        /// <param name="isPermanent"></param>
        public static void SetHostMode(
            this ICoreScannerService scannerService,
            HostMode mode,
            Int32 scannerId,
            Boolean isSilent,
            Boolean isPermanent)
        {
            Contract.Requires(scannerService != null);
            Contract.Requires(scannerId > 0);

            XDocument inXml = new XDocument(
                new XElement("inArgs",
                             new XElement("scannerID", scannerId),
                             new XElement("cmdArgs",
                                          new XElement("arg-string", mode.GetStringCode()),
                                          new XElement("arg-bool", isSilent),
                                          new XElement("arg-bool", isPermanent))));

            scannerService
            .ExecuteCommand(OperationCode.DeviceSwitchHostMode, inXml.ToString());
        }
Пример #3
0
        public static String GetStringCode(
            this HostMode hostMode)
        {
            switch (hostMode)
            {
            case HostMode.USB_IBMHID: return("XUA-45001-1");

            case HostMode.USB_IBMTT: return("XUA-45001-2");

            case HostMode.USB_HIDKB: return("XUA-45001-3");

            case HostMode.USB_OPOS: return("XUA-45001-8");

            case HostMode.USB_SNAPI: return("XUA-45001-9");

            case HostMode.USB_SNAPI_NoImaging: return("XUA-45001-10");

            case HostMode.USB_CDC: return("XUA-45001-11");

            default: throw new ArgumentOutOfRangeException("hostMode");
            }
        }
Пример #4
0
 public void ChangeHostMode(HostMode hostMode)
 {
     ExcecuteCommand($"sys mode p={(int)hostMode}");
 }
Пример #5
0
        /// <summary>
        /// Initializes the ServiceHost
        /// </summary>
        /// <param name="serviceConfigurationAction">The service configuration action.</param>
        public static IHost Initialize(Action <HostBuilderContext, IServiceCollection> configAction, HostMode hostMode = HostMode.Primary)
        {
            var aHost = new HostBuilder().ConfigureServices(configAction).Build();

            if (hostMode == HostMode.Primary)
            {
                Host = aHost;
            }
            else
            {
                SecondaryHost = aHost;
            }

            return(aHost);
        }
Пример #6
0
 /// <summary>
 /// Initializes the ServiceHost with a specified root path.
 /// </summary>
 /// <param name="rootPath">The root path.</param>
 /// <param name="serviceConfigurationAction">The service configuration action.</param>
 public static IHost Initialize(string rootPath, Action <HostBuilderContext, IServiceCollection> servicesConfigurationAction, HostMode hostMode = HostMode.Primary) => Initialize((c) => { c.AddCommandLine(new string[] { $"ContentRoot={rootPath}" }); }, servicesConfigurationAction, hostMode);
Пример #7
0
        /// <summary>
        /// Initializes the ServiceHost
        /// </summary>
        /// <param name="hostConfigurationBuilder">The host configuration builder.</param>
        /// <param name="serviceConfigurationAction">The service configuration action.</param>
        public static IHost Initialize(Action <IConfigurationBuilder> hostConfigurationBuilder, Action <HostBuilderContext, IServiceCollection> servicesConfigurationAction, HostMode hostMode = HostMode.Primary)
        {
            IHostBuilder builder = new HostBuilder();

            if (hostConfigurationBuilder != null)
            {
                builder = builder.ConfigureHostConfiguration(hostConfigurationBuilder);
            }

            if (servicesConfigurationAction != null)
            {
                builder = builder.ConfigureServices(servicesConfigurationAction);
            }

            var aHost = builder.Build();

            if (hostMode == HostMode.Primary)
            {
                Host = aHost;
            }
            else
            {
                SecondaryHost = aHost;
            }

            return(aHost);
        }
Пример #8
0
 /// <summary>
 /// Creates a new, reuseable scope instance on the spcecified host
 /// </summary>
 /// <param name="mode">The mode.</param>
 /// <returns></returns>
 public static IServiceScope CreateScope(HostMode mode = HostMode.Primary) => (mode == HostMode.Primary ? Host.Services.CreateScope() : SecondaryHost.Services.CreateScope());