Esempio n. 1
0
        static void Main(string[] args)
        {
            var services = new ServiceCollection();

            ConfigureServices(services);

            using (ServiceProvider serviceProvider = services.BuildServiceProvider())
            {
                _logger = serviceProvider.GetService <ILogger <Program> >();
                AnalyserService analyser = serviceProvider.GetService <AnalyserService>();

                analyser.OnTakeoff += (sender, e) =>
                {
                    using (LogContext.PushProperty("FLS", true))
                    {
                        _logger.LogInformation("{Aircraft} {Immatriculation} - Took off from {NearLocation} ({DepartureLocationY}, {DepartureLocationX})", e.Flight.Aircraft, e.Immatriculation, e.NearLocation, e.Flight.DepartureLocation?.Y, e.Flight.DepartureLocation?.X);
                    }

                    Console.WriteLine($"{DateTime.UtcNow}: {e.Flight.Aircraft} {e.Immatriculation} - Took off from {e.NearLocation} ({e.Flight.DepartureLocation?.Y}, {e.Flight.DepartureLocation?.X})");
                };

                analyser.OnLanding += (sender, e) =>
                {
                    using (LogContext.PushProperty("FLS", true))
                    {
                        _logger.LogInformation("{Aircraft} {Immatriculation} - Landed at {NearLocation} ({ArrivalLocationY}, {ArrivalLocationX})", e.Flight.Aircraft, e.Immatriculation, e.NearLocation, e.Flight.ArrivalLocation?.Y, e.Flight.ArrivalLocation?.X);
                    }

                    Console.WriteLine($"{DateTime.UtcNow}: {e.Flight.Aircraft} {e.Immatriculation} - Landed at {e.NearLocation} ({e.Flight.ArrivalLocation?.Y}, {e.Flight.ArrivalLocation?.X})");
                };

                analyser.OnLaunchCompleted += (sender, e) =>
                {
                    Console.WriteLine($"{DateTime.UtcNow}: {e.Flight.Aircraft} - launch completed {e.Flight.DepartureLocation?.Y}, {e.Flight.DepartureLocation?.X}");
                };

                analyser.OnRadarContact += (sender, e) =>
                {
                    if (e.Flight.PositionUpdates.Any() == false)
                    {
                        return;
                    }

                    var lastPositionUpdate = e.Flight.PositionUpdates.OrderByDescending(q => q.TimeStamp).First();

                    Console.WriteLine($"{DateTime.UtcNow}: {e.Flight.Aircraft}  {e.Immatriculation} - Radar contact near {e.NearLocation} at {lastPositionUpdate.Latitude}, {lastPositionUpdate.Longitude} @ {lastPositionUpdate.Altitude}ft {lastPositionUpdate.Heading.ToHeadingArrow()}");
                };

                analyser.OnContextDispose += (sender, e) =>
                {
                    Console.WriteLine($"{DateTime.UtcNow}: {e.Context.Flight.Aircraft} - Context disposed");
                };

                analyser.Run();

                Console.WriteLine("Currently checking to see if we can receive some information!");
                Console.Read();
            }
        }
Esempio n. 2
0
        public void GetAllExternalLinks()
        {
            var analyserModel = new AnalyserModel();

            analyserModel.Content = "There are links for your reference, http://test.com, https://www.app.com.my";
            var analyserService = new AnalyserService(analyserModel);
            var result          = analyserService.Analysis();

            Assert.AreEqual(result.LinkList.Count, 2);
        }
Esempio n. 3
0
 public ActionResult Analyser(AnalyserModel model)
 {
     try
     {
         var analyserService = new AnalyserService(model);
         var models          = analyserService.Analysis();
         return(Json(models));
     }
     catch (Exception ex)
     {
         return(new HttpStatusCodeResult(404));
     }
 }
Esempio n. 4
0
        static async Task Main(string[] args)
        {
            if (args.Length == 0)
            {
                throw new ArgumentException("Directory required as argument");
            }

            try
            {
                await AnalyserService.AnalyseCodeInDirectory(args[0].Trim());
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error analysing files: {e.Message}");
                Console.WriteLine(e.StackTrace);
            }
        }
Esempio n. 5
0
        public void GetAllWords()
        {
            var analyserModel = new AnalyserModel();

            analyserModel.Content         = "Filler text is text that shares some characteristics of a real written text, but is random or otherwise generated. It may be used to display a sample of fonts, generate text for testing, or to spoof an e-mail spam filter.";
            analyserModel.FilterStopWords = true;
            var analyserService = new AnalyserService(analyserModel);
            var result          = analyserService.Analysis();

            Assert.AreEqual(result.WordList["text"], 4);
            Assert.IsFalse(result.WordList.ContainsKey("that"));

            analyserModel.FilterStopWords = false;
            analyserService = new AnalyserService(analyserModel);
            result          = analyserService.Analysis();
            Assert.IsTrue(result.WordList.ContainsKey("that"));
        }