Esempio n. 1
0
    internal static ResponsiveService ResponsiveService(string agent, ResponsiveOptions options = null !)
    {
        var accessor = CreateHttpContextAccessor(agent);
        var device   = DeviceService(agent);

        return(ResponsiveService(accessor, device, options));
    }
Esempio n. 2
0
 private static void ValidateOptions(ResponsiveOptions options)
 {
     if (options.Disable && options.IncludeWebApi)
     {
         throw new InvalidOperationException("IncludeWebApi is not needed if already Disable");
     }
 }
    public void DefaultMobile()
    {
        var options = new ResponsiveOptions();

        options.DefaultDesktop = Device.Mobile;
        options.DefaultTablet  = Device.Mobile;
        options.DefaultMobile  = Device.Mobile;

        Assert.Equal(Device.Mobile, MockService.ResponsiveService("mobile", options).View);
        Assert.Equal(Device.Mobile, MockService.ResponsiveService("tablet", options).View);
        Assert.Equal(Device.Mobile, MockService.ResponsiveService("desktop", options).View);
    }
        public ResponsiveService(/*ILogger<ResponsiveService> logger, */ IConfiguration config, DiscordSocketClient discord)
        {
            //_logger = logger;
            _discord = discord;

            var options = new ResponsiveOptions();

            config.Bind("ResponsiveOptions", options);
            Options = options;

            CancelEmoji = new Emoji(Options.CancelEmojiUnicode);
            YesEmoji    = new Emoji(Options.YesEmojiUnicode);
            NoEmoji     = new Emoji(Options.NoEmojiUnicode);
        }
Esempio n. 5
0
        public void TabletDefault_is_Mobile()
        {
            var desktop = DeviceType.Desktop;
            var tablet  = DeviceType.Tablet;
            var mobile  = DeviceType.Mobile;

            var options = new ResponsiveOptions(desktop, mobile, mobile);

            Assert.Equal(mobile, options.TabletDefault);
            Assert.NotEqual(tablet, options.TabletDefault);
            Assert.Equal(desktop, options.DesktopDefault);

            var manager = new ResolverManager(tablet, options);

            Assert.Equal(mobile, manager.Device);
        }
Esempio n. 6
0
 private static Device DefaultView(Device device, ResponsiveOptions options)
 => device switch
 {
Esempio n. 7
0
 public static bool IsWebApi(this HttpContext context, ResponsiveOptions options)
 => context.Request.Path.StartsWithSegments(options.WebApiPath);
Esempio n. 8
0
 internal static ResponsiveService ResponsiveService(IHttpContextAccessor accessor, IDeviceService device, ResponsiveOptions options = null !)
 => new(accessor, device, options);