Пример #1
0
        public App(IEliteDangerousAPI api, IEliteDangerousINARA inara)
        {
            _api   = api;
            _inara = inara;

            _api.StatusChanged += (sender, status) => Console.WriteLine($"API status {status}");
        }
Пример #2
0
        public App(IEliteDangerousAPI api)
        {
            _api = api;

            _api.StatusChanged += (sender, status) => Console.WriteLine($"API status {status}");
            _api.Errors        += (sender, exception) =>
            {
                if (exception.Type == JournalErrorType.OnReadingRecord)
                {
                    Console.WriteLine(
                        $"API error {exception.Type} json: {((JournalRecordException)exception).JournalRecord}");
                }
                else
                {
                    Console.WriteLine($"API error {exception.Type}");
                }
            };

            _api.Warnings += (sender, exception) =>
            {
                if (exception.Type == JournalErrorType.EventNotFound)
                {
                    var ex = (JournalEventNotFoundException)exception;
                    Console.WriteLine(
                        $"API no definition for {ex.EventName} json: {ex.JournalRecord}");
                }
            };

            _api.AllEvents += (s, e) => Console.WriteLine($"API event at {e.Event.Timestamp:O} {e.EventName} type {e.EventType.Name}");
        }
Пример #3
0
 public EliteDangerousINARA(IOptions <InaraOptions> options, ISystemClock clock, IEliteDangerousAPI eliteDangerousAPI = null, ILoggerFactory loggerFactory = null)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     Clock   = clock ?? throw new ArgumentNullException(nameof(clock));
     Log     = (loggerFactory ?? new NullLoggerFactory()).CreateLogger <EliteDangerousINARA>();
     Options = options.Value;
     if (string.IsNullOrWhiteSpace(Options.ApplicationName))
     {
         throw new ArgumentNullException(nameof(Options.ApplicationName));
     }
     if (string.IsNullOrWhiteSpace(Options.ApplicationVersion))
     {
         throw new ArgumentNullException(nameof(Options.ApplicationVersion));
     }
     if (string.IsNullOrWhiteSpace(Options.ApiKey))
     {
         throw new ArgumentNullException(nameof(Options.ApiKey));
     }
     if (string.IsNullOrWhiteSpace(Options.Url))
     {
         throw new ArgumentNullException(nameof(Options.Url));
     }
     Client = new HttpClient {
         BaseAddress = new Uri(Options.Url)
     };
     _eliteAPI = eliteDangerousAPI;
 }
        public MainWindow(IEliteDangerousAPI api)
        {
            InitializeComponent();

            icApiErrors.ItemsSource = _errors;
            icJournal.ItemsSource   = _journal;

            _api = api;
            _api.PlayerChanged   += OnApiPlayerChanged;
            _api.ShipChanged     += OnApiShipChanged;
            _api.LocationChanged += OnApiLocationChanged;
            _api.StatusChanged   += OnApiStatusChanged;
            _api.Errors          += OnApiErrors;
            _api.BeforeEvent     += OnApiBeforeEvent;
        }
Пример #5
0
 public ApiService(IEliteDangerousAPI api, string path)
 {
     this.api = api;
     api.ChangeJournal(new System.IO.DirectoryInfo(path));
     api.Start();
 }
Пример #6
0
 public Core(ILogger <Core> log, IEliteDangerousAPI api)
 {
     // Get our dependencies through dependency injection
     _log = log;
     _api = api;
 }
Пример #7
0
 public MainWindow(IEliteDangerousAPI api)
 {
     InitializeComponent();
     _api  = api;
     Title = App.Title;
 }
Пример #8
0
 public Core(IEliteDangerousAPI api)
 {
     // Get our dependencies through dependency injection
     _api = api;
 }
 /// <summary>
 /// Wrapper for event modules
 /// </summary>
 /// <param name="api">The EliteDangerousAPI</param>
 protected EliteDangerousEventModule(IEliteDangerousAPI api)
 {
     EliteAPI = api;
 }