Exemplo 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));
    }
Exemplo n.º 2
0
 private static void ValidateOptions(ResponsiveOptions options)
 {
     if (options.Disable && options.IncludeWebApi)
     {
         throw new InvalidOperationException("IncludeWebApi is not needed if already Disable");
     }
 }
Exemplo n.º 3
0
    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);
        }
Exemplo 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);
        }
Exemplo n.º 6
0
 private static Device DefaultView(Device device, ResponsiveOptions options)
 => device switch
 {
Exemplo n.º 7
0
 public static bool IsWebApi(this HttpContext context, ResponsiveOptions options)
 => context.Request.Path.StartsWithSegments(options.WebApiPath);
Exemplo n.º 8
0
 internal static ResponsiveService ResponsiveService(IHttpContextAccessor accessor, IDeviceService device, ResponsiveOptions options = null !)
 => new(accessor, device, options);