internal static ResponsiveService ResponsiveService(string agent, ResponsiveOptions options = null !) { var accessor = CreateHttpContextAccessor(agent); var device = DeviceService(agent); return(ResponsiveService(accessor, device, options)); }
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); }
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); }
private static Device DefaultView(Device device, ResponsiveOptions options) => device switch {
public static bool IsWebApi(this HttpContext context, ResponsiveOptions options) => context.Request.Path.StartsWithSegments(options.WebApiPath);
internal static ResponsiveService ResponsiveService(IHttpContextAccessor accessor, IDeviceService device, ResponsiveOptions options = null !) => new(accessor, device, options);