public static IDevice Device(this HttpRequest request) { var service = new UserAgentService(request.HttpContext); var resolver = new DeviceResolver(service); return(resolver.Device); }
public static IBrowser Browser(this HttpRequest request) { var service = new UserAgentService(request.HttpContext); var resolver = new BrowserResolver(service); return(resolver.Browser); }
public static IPlatform Platform(this HttpRequest request) { var service = new UserAgentService(request.HttpContext); var resolver = new PlatformResolver(service); return(resolver.Platform); }
public static IEngine Engine(this HttpRequest request) { var service = new UserAgentService(request.HttpContext); var resolver = new EngineResolver(service); return(resolver.Engine); }
private static HttpWebRequest GetRequest(string method, string url, EnumContentType contentType) { var request = WebRequest.CreateHttp(new Uri(url)); request.ContentType = ConvertContentTypeToString(contentType); request.AutomaticDecompression = DecompressionMethods.GZip; request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials; request.Method = method; request.UserAgent = UserAgentService.GetUserAgent(); request.Timeout = 60000; return(request); }
public async Task CaptureAsync(int batchSize) { await CleanupFailedSnapshots(); uaString = await UserAgentService.GetMostPopularStringAsync(); var lists = await GetListsToCapture(batchSize); var snaps = await CreateAndSaveSnaps <Snapshot>(lists); var listsToRetry = snaps.Where(s => s.WebExcepted).Select(s => s.List); await CreateAndSaveSnaps <SnapshotWayback>(listsToRetry); }
public void Detect() { foreach (var accessor in Accessors) { var contextService = new HttpContextService(accessor); var userAgentService = new UserAgentService(contextService); var platformService = new PlatformService(userAgentService); var engineService = new EngineService(userAgentService, platformService); var browserService = new BrowserService(userAgentService, engineService); var deviceService = new DeviceService(userAgentService); _ = browserService.Name; _ = browserService.Version; _ = deviceService.Type; } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var agent = "useragent"; var context = new DefaultHttpContext(); context.Request.Headers["User-Agent"] = agent; var accessor = new HttpContextAccessor { HttpContext = context }; var contextService = new HttpContextService(accessor); var useragent = new UserAgentService(contextService); Console.WriteLine(useragent.UserAgent); }
public void Ctor_IServiceProvider_Success() { var agent = "Agent"; var context = new DefaultHttpContext(); context.Request.Headers["User-Agent"] = agent; var accessor = new HttpContextAccessor { HttpContext = context }; var contextService = new HttpContextService(accessor); var useragentService = new UserAgentService(contextService); Assert.NotNull(useragentService.UserAgent); Assert.Equal(agent, useragentService.UserAgent.ToString()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); PopupService.Init(); AndroidEnvironment.UnhandledExceptionRaiser += HandleAndroidException; Forms.Init(this, bundle); //XXX: Must initialize the UAS first on a main thread before anything can use it UserAgentService.Init(); PullToRefreshLayoutRenderer.Init(); CachedImageRenderer.Init(); ImageService.Instance.Initialize(new Configuration { HttpClient = RestService.Instance.Client, FadeAnimationEnabled = false, FadeAnimationForCachedImages = false, BitmapOptimizations = false, TransformPlaceholders = false }); var downloadCache = ImageService.Instance.Config.DownloadCache as DownloadCache; if (downloadCache != null) { downloadCache.DelayBetweenRetry = TimeSpan.FromSeconds(0); } else { Logger.Log("WARNING: Unable to cast FFImageLoading DownloadCache!"); } var app = new App(); LoadApplication(app); app.Activate(); if ((int)Build.VERSION.SdkInt >= 21) { ActionBar.SetIcon(new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent))); } }
public async void GetMostPopularStringAsync_ReturnsStringContainingMozilla() { var actualString = await UserAgentService.GetMostPopularStringAsync(); Assert.Contains("Mozilla", actualString); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Logger.Log("AppDelegate.FinishedLaunching"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; Xamarin.Forms.Forms.Init(); //XXX: Must initialize the UAS first on a main thread before anything can use it UserAgentService.Init(); FFImageLoading.Forms.Touch.CachedImageRenderer.Init(); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration() { HttpClient = RestService.Instance.Client, FadeAnimationEnabled = false, FadeAnimationForCachedImages = false, BitmapOptimizations = false, TransformPlaceholders = false }); var downloadCache = (FFImageLoading.ImageService.Instance.Config.DownloadCache as FFImageLoading.Cache.DownloadCache); if (downloadCache != null) { downloadCache.DelayBetweenRetry = TimeSpan.FromSeconds(0); } else { Logger.Log("WARNING: Unable to cast FFImageLoading DownloadCache!"); } PopupService.Init(); Settings.AppID = "1626108114272416"; Settings.DisplayName = "PlayOnCloud"; AudioToolbox.AudioSession.Initialize(); AudioToolbox.AudioSession.Category = AudioToolbox.AudioSessionCategory.MediaPlayback; LoadApplication(new App()); var result = base.FinishedLaunching(app, options); RootController = app.KeyWindow.RootViewController; DisplayCrashReport(app.KeyWindow.RootViewController); if ((options != null) && options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) { Logger.Log("AppDelegate.FinishedLaunching: Remote Notification"); backgroundTaskId = UIApplication.SharedApplication.BeginBackgroundTask(() => { UIApplication.SharedApplication.EndBackgroundTask(backgroundTaskId); backgroundTaskId = 0; }); } //UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum); Logger.Log("AppDelegate.FinishedLaunching: Complete"); return(result); }
static async Task Main(string[] args) { var logPath = @"E:\proj\my\ImageGallery\log\pexel"; var pixel_dbPath = @"E:\proj\my\ImageGallery\pixel.db"; //var im_dbPath = @"E:\proj\my\ImageGallery\im.db"; var im_dbPath = @"E:\proj\my\ImageGallery\test.im.db"; //var jsonDbPath= @"E:\proj\my\ImageGallery\db.json"; var jsonDbPath = @"E:\proj\my\ImageGallery\test.db.json"; var userAgentsPath = @"E:\proj\github\ichensky\ImageGallery\data\useragents.txt"; var pixelMigrationsPath = @"E:\proj\github\ichensky\ImageGallery\src\db\pixel.txt"; var imMigrationsPath = @"E:\proj\github\ichensky\ImageGallery\src\db\im.txt"; var pathToGoogleKeys = @"E:\proj\github\ichensky\ImageGallery\keys\google"; var msVisionKeysPath = @"E:\proj\github\ichensky\ImageGallery\keys\msvisionkeys.txt"; LogManager.Configuration = LoggerService.DefaultConfiguration(logPath); var logger = LogManager.GetLogger(Services.Logger.log.ToString()); var userAgents = await File.ReadAllLinesAsync(userAgentsPath); var userAgentsService = new UserAgentService(logger, userAgents); var stopwatchService = new StopwatchService(logger); var attemptService = new AttemptService(logger); var httpClientSerive = new HttpClientService(logger, stopwatchService, userAgentsService); var usersParser = new UsersParser(logger, httpClientSerive, attemptService); var imagesParser = new ImagesParser(logger, httpClientSerive, attemptService); var imageMetaParser = new ImageMetaParser(logger, httpClientSerive, attemptService); var fileLoader = new FileLoader(logger, httpClientSerive, attemptService); var googleService = new GoogleService(logger, pathToGoogleKeys); var msvisionService = new MSVisionService(logger, msVisionKeysPath); var pixel_builder = new DbContextOptionsBuilder().UseSqlite($"Data Source={pixel_dbPath}"); var imBuilder = new DbContextOptionsBuilder().UseSqlite($"Data Source={im_dbPath}"); //await googleService.Clean(); //var migrationService = new MigrationsService(pixel_builder.Options); //logger.Info("Applying migrations to database."); //await migrationService.MigrateAsync(migrationsPath); var pixelService = new PixelService(logger, pixel_builder.Options, usersParser, imagesParser, imageMetaParser, fileLoader, googleService, msvisionService); //await pixelService.UpdateUsers(5514); //await pixelService.UpdateUsersImages(16124); //await pixelService.UpdateImagesMeta(388970); //await pixelService.PixelImagesToGoogle(); //await pixelService.CleanGoogleImages(); //-- //-- //await pixelService.LoadMSVisionMeta(); //-- //-- //var jsonDb = await pixelService.GenJsonDb(); //File.WriteAllText(jsonDbPath, jsonDb); //-- //-- if (File.Exists(im_dbPath)) { var err = "Deleting database file ..."; logger.Warn(err); File.Delete(im_dbPath); } var migrationService = new MigrationsService(imBuilder.Options); logger.Info("Applying migrations to database."); await migrationService.MigrateAsync(imMigrationsPath); //var im_connection = new Microsoft.Data.Sqlite.SqliteConnection($"DataSource={im_dbPath}"); //im_connection.Open(); //var connectionInMemory = new Microsoft.Data.Sqlite.SqliteConnection("DataSource=:memory:"); //connectionInMemory.Open(); //var builderInMemory = new DbContextOptionsBuilder().UseSqlite(connectionInMemory); //im_connection.BackupDatabase(connectionInMemory); var pixelToImageGalleryService = new PixelToImageGalleryService( logger, pixel_builder.Options, imBuilder.Options); //builderInMemory.Options); //-- //var jsonDb = await pixelToImageGalleryService.GenJsonDb(); //File.WriteAllText(jsonDbPath, jsonDb); //-- var json = File.ReadAllText(jsonDbPath); await pixelToImageGalleryService.GenDb(json); //connectionInMemory.BackupDatabase(im_connection); Console.WriteLine("Hello World!"); }