Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LiteApiMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next, provided by ASP.NET</param>
        /// <param name="options">The options, passed by <see cref="IApplicationBuilder"/> extension method.</param>
        /// <param name="services">The services, provided by ASP.NET</param>
        /// <exception cref="Exception">Middleware is already registered.</exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException">Assemblies with controllers is not passed to the LiteApiMiddleware</exception>
        public LiteApiMiddleware(RequestDelegate next, LiteApiOptions options, IServiceProvider services)
        {
            if (IsRegistered)
            {
                throw new Exception("Middleware is already registered.");
            }
            Options = options ?? throw new ArgumentNullException(nameof(options));

            options.InternalServiceResolver.Initialize(services, options);

            if (options.ControllerAssemblies?.Count == 0)
            {
                throw new ArgumentException("Assemblies with controllers is not passed to the LiteApiMiddleware");
            }
            if (options.LoggerFactory != null)
            {
                _logger           = new InternalLogger(true, options.LoggerFactory.CreateLogger <LiteApiMiddleware>());
                _isLoggingEnabled = true;
            }
            else
            {
                _logger = new InternalLogger(false, null);
            }
            // Services = services;
            _next        = next;
            IsRegistered = true;

            Initialize(services);

            _actionInvoker    = options.InternalServiceResolver.GetActionInvoker();
            _discoveryHandler = options.InternalServiceResolver.GetDiscoveryHandler();
            _pathResolver     = options.InternalServiceResolver.GetPathResolver();
        }
 public void FindBluetoothPrinters(IDiscoveryHandler handler)
 {
     try
     {
         BluetoothDiscoverer.Current.FindPrinters(null, handler);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 3
0
 public static void FindDevices(Context paramContext, IDiscoveryHandler paramDiscoveryHandler)
 {
     try
     {
         BluetoothDiscoverer.FindDevices(paramContext, paramDiscoveryHandler, null);
     }
     catch (ConnectionException localConnectionException)
     {
         throw new ZebraPrinterConnectionException(localConnectionException.GetBaseException().ToString());
     }
 }
        public void FindBluetoothPrinters(IDiscoveryHandler handler)
        {
            const string permission = Manifest.Permission.AccessCoarseLocation;

            if (ContextCompat.CheckSelfPermission(context, permission) == Permission.Granted)
            {
                BluetoothDiscoverer.Current.FindPrinters(context, handler);
                return;
            }
            TempHandler = handler;
            //Finally request permissions with the list of permissions and Id
            ActivityCompat.RequestPermissions(MainActivity.GetActivity(), PermissionsLocation, RequestLocationId);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Finds the bluetooth printers.
        /// </summary>
        /// <param name="handler">Handler.</param>
        public void FindBluetoothPrinters(IDiscoveryHandler handler)
        {
            const string permission = Manifest.Permission.AccessCoarseLocation;

            if (Activity.CheckSelfPermission(permission) == (int)Permission.Granted)
            {
                SetSearchState();
                BluetoothDiscoverer.Current.FindPrinters(Context, handler);
                return;
            }

            // Finally request permissions with the list of permissions and ID
            RequestPermissions(PermissionsLocation, RequestLocationId);
        }
Ejemplo n.º 6
0
 public void FindBluetoothPrinters(IDiscoveryHandler handler, Activity activity)
 {
     try
     {
         const string permission = Manifest.Permission.AccessCoarseLocation;
         if (ContextCompat.CheckSelfPermission(Android.App.Application.Context, permission) == (int)Permission.Granted)
         {
             BluetoothDiscoverer.Current.FindPrinters(Android.App.Application.Context, handler);
             return;
         }
         TempHandler = handler;
         //Finally request permissions with the list of permissions and Id
         ActivityCompat.RequestPermissions(activity, PermissionsLocation, RequestLocationId);
     }catch (Exception ex)
     { }
 }
Ejemplo n.º 7
0
        public static void FindDevices(Context paramContext, IDiscoveryHandler paramDiscoveryHandler, IDeviceFilter paramDeviceFilter)
        {
            BluetoothAdapter localBluetoothAdapter = BluetoothAdapter.DefaultAdapter;

            if (localBluetoothAdapter == null)
            {
                paramDiscoveryHandler.DiscoveryError("No bluetooth radio found");
            }
            else if (!localBluetoothAdapter.IsEnabled)
            {
                paramDiscoveryHandler.DiscoveryError("Bluetooth radio is currently disabled");
            }
            else
            {
                if (localBluetoothAdapter.IsDiscovering)
                {
                    localBluetoothAdapter.CancelDiscovery();
                }
                new BluetoothDiscoverer(paramContext.ApplicationContext, paramDiscoveryHandler, paramDeviceFilter).DoBluetoothDiscovery();
            }
        }
Ejemplo n.º 8
0
 public BluetoothDiscoverer(Context paramContext, IDiscoveryHandler paramDiscoveryHandler, IDeviceFilter paramDeviceFilter)
 {
     this.mContext          = paramContext;
     this.deviceFilter      = paramDeviceFilter;
     this.mDiscoveryHandler = paramDiscoveryHandler;
 }
 public void FindUsbPrinters(IDiscoveryHandler handler)
 {
     throw new NotImplementedException();
 }
 public void FindBluetoothPrinters(IDiscoveryHandler handler)
 {
     BluetoothDiscoverer.Current.FindPrinters(null, handler);
 }
 public void FindUSBPrinters(IDiscoveryHandler handler)
 {
 }
 public void FindUSBPrinters(IDiscoveryHandler handler)
 {
     Android.Content.Context context = Android.App.Application.Context;                  //Xamarin.Forms.Forms.Context;
     UsbDiscoverer.Current.FindPrinters(context, handler);
 }
Ejemplo n.º 13
0
 public DiscoveryPoller(
     IDiscoveryHandler discoveryHandler)
 {
     _discoveryHandler = discoveryHandler;
 }
Ejemplo n.º 14
0
 public IndexModel(
     IDiscoveryHandler discoveryHandler,
     MicrowaveWebApiConfiguration configuration) : base(configuration)
 {
     _discoveryHandler = discoveryHandler;
 }
 public ServiceMapPage(
     IDiscoveryHandler handler,
     MicrowaveWebApiConfiguration configuration) : base(configuration)
 {
     _handler = handler;
 }
Ejemplo n.º 16
0
 public DiscoveryController(IDiscoveryHandler discoveryHandler)
 {
     _discoveryHandler = discoveryHandler;
 }
Ejemplo n.º 17
0
 public void FindUSBPrinters(IDiscoveryHandler handler)
 {
     // UsbDiscoverer.Current.FindPrinters(Android.App.Application.Context, handler);
 }
 public void FindBluetoothPrinters(IDiscoveryHandler handler)
 {
     BluetoothDiscoverer.Current.FindPrinters(Android.App.Application.Context, handler);
 }
 public void FindUSBPrinters(IDiscoveryHandler handler)
 {
     UsbDiscoverer.Current.FindPrinters(context, handler);
 }
 public void FindUsbPrinters(IDiscoveryHandler handler)
 {
     UsbDiscoverer.Current.FindPrinters(Application.Context, handler);
 }