Exemplo n.º 1
0
        public RouteApp(
            AppConfig config,
            IHostApplicationLifetime lifetime,
            IIndex <string, IConfigurationUpdater> configUpdaters,
            IIndex <ImportType, IImporter> importers,
            IIndex <ExportType, IExporter> exporters,
            IIndex <ProcessorType, IRouteProcessor> snapProcessors,
            IJ4JLogger logger
            )
        {
            _config    = config;
            _lifetime  = lifetime;
            _importers = importers;

            _exporter = exporters[config.ExportType];

            _distProc = snapProcessors[ProcessorType.Distance];
            _distProc.PointsProcessed += PointsProcessedHandler;

            _logger = logger;
            _logger.SetLoggedType(GetType());

            if (configUpdaters.TryGetValue(AutofacKey, out var updater) &&
                updater.Update(_config))
            {
                _routeProc = snapProcessors[config.ProcessorType];
                _routeProc.PointsProcessed += PointsProcessedHandler;

                return;
            }

            _logger.Fatal("Incomplete configuration, aborting");
            _lifetime.StopApplication();
        }
Exemplo n.º 2
0
        public StoreKeyApp(
            AppConfig config,
            IHostApplicationLifetime lifetime,
            IIndex <string, IConfigurationUpdater> configUpdaters,
            J4JHostInfo hostInfo,
            IJ4JProtection protection,
            IJ4JLogger?logger
            )
        {
            _config     = config;
            _lifetime   = lifetime;
            _hostInfo   = hostInfo;
            _protection = protection;

            _logger = logger;
            _logger?.SetLoggedType(GetType());

            if (!configUpdaters.TryGetValue(AutofacKey, out var updater) || !updater.Update(_config))
            {
                return;
            }

            _logger?.Fatal("Incomplete configuration, aborting");
            _lifetime.StopApplication();
        }
Exemplo n.º 3
0
        private async Task <int> OnExecuteAsync(
            CommandLineApplication app,
            CancellationToken cancellationToken = default
            )
        {
            _logger = AppServiceProvider.Instance.GetRequiredService <IJ4JLogger>();
            _logger.SetLoggedType <Program>();

            Configuration = AppServiceProvider.Instance.GetRequiredService <AppConfiguration>();

            if (Retrieve)
            {
                return(RetrieveDataFromAlphaVantage());
            }

            if (!String.IsNullOrEmpty(PathToSecuritiesFile))
            {
                return(UpdateSecurities());
            }

            if (!String.IsNullOrEmpty(PathToPriceFile))
            {
                return(ExportDataToCSV());
            }

            // shouldn't get here; something weird happened
            _logger.Error("Unexpected termination");
            return(-1);
        }
Exemplo n.º 4
0
        public ProcessorVM(
            IAppConfig appConfig,
            IUserConfig userConfig,
            IIndex <ImportType, IImporter> importers,
            IIndex <ExportType, IExporter> exporters,
            IIndex <ProcessorType, IRouteProcessor> snapProcessors,
            IJ4JLogger?logger)
        {
            _logger = logger;
            _logger?.SetLoggedType(GetType());

            _appConfig = appConfig;

            if (_logger != null)
            {
                _logger.LogEvent += DisplayLogEventAsync;
            }

            _userConfig = userConfig;

            _importers      = importers;
            _exporters      = exporters;
            _snapProcessors = snapProcessors;

            AbortCommand        = new RelayCommand <ProcessWindow>(AbortCommandHandler);
            WindowLoadedCommand = new AsyncRelayCommand(WindowLoadedCommandAsync);
        }
Exemplo n.º 5
0
        internal ExcelTable(ExcelSheet sheet,
                            int upperLeftRow,
                            int upperLeftColumn,
                            TableOrientation orientation,
                            IJ4JLogger?logger = null)
        {
            ExcelSheet = sheet;

            _logger = logger ?? throw new NullReferenceException(nameof(logger));
            _logger?.SetLoggedType(GetType());

            if (upperLeftRow < 0)
            {
                throw new ArgumentException($"Upper left row cannot be < 0 ({upperLeftRow})");
            }

            if (upperLeftColumn < 0)
            {
                throw new ArgumentException($"Upper left column cannot be < 0 ({upperLeftColumn})");
            }

            ExcelSheet      = sheet;
            UpperLeftRow    = upperLeftRow;
            UpperLeftColumn = upperLeftColumn;

            Orientation = orientation;
        }
Exemplo n.º 6
0
        protected Actions(ActionsContext context,
                          IJ4JLogger?logger = null)
        {
            Context = context;

            Logger = logger;
            Logger?.SetLoggedType(GetType());
        }
Exemplo n.º 7
0
        public TickRanges(IEnumerable <ITickRange> rangers,
                          IJ4JLogger?logger = null)
        {
            _rangers = rangers.ToList();

            _logger = logger;
            _logger?.SetLoggedType(GetType());
        }
Exemplo n.º 8
0
        public RangeCalculator(ITickManagers managers,
                               IJ4JLogger?logger)
        {
            _managers = managers;

            _logger = logger;
            _logger?.SetLoggedType(GetType());
        }
Exemplo n.º 9
0
        public DataRetriever(
            AlphaVantageContext dbContext,
            IJ4JLogger logger)
        {
            DbContext = dbContext;

            Logger = logger;
            Logger.SetLoggedType(this.GetType());
        }
Exemplo n.º 10
0
        protected FileHandler(
            IGeoConfig config,
            IJ4JLogger?logger
            )
        {
            Configuration = config;

            Logger = logger;
            Logger?.SetLoggedType(GetType());
        }
Exemplo n.º 11
0
        public J4JCommandLineSource(IParser parser,
                                    IJ4JLogger?logger)
        {
            Parser = parser;

            _logger = logger;
            _logger?.SetLoggedType(GetType());

            CommandLineSource = Initialize();
        }
Exemplo n.º 12
0
        public J4JCommandLineSource(IParser parser,
                                    IJ4JLogger?logger,
                                    params ICleanupTokens[] cleanupTokens)
        {
            Parser = parser;

            _logger = logger;
            _logger?.SetLoggedType(GetType());

            CommandLineSource = Initialize();
        }
Exemplo n.º 13
0
        protected SelectableTree(
            IJ4JLogger?logger,
            IEqualityComparer <TKey>?keyComparer = null
            )
        {
            _keyComparer = keyComparer ?? EqualityComparer <TKey> .Default;

            _masterDict = new Dictionary <TKey, TEntity>(keyComparer);

            Logger = logger;
            Logger?.SetLoggedType(GetType());
        }
Exemplo n.º 14
0
        protected RouteProcessor(
            IGeoConfig config,
            ProcessorType processorType,
            IJ4JLogger?logger)
        {
            Configuration = config.ProcessorInfo !;
            Processor     = config.ProcessorType;
            ProcessorType = processorType;

            ReportingInterval = ProcessorType.MaxPointsPerRequest() == int.MaxValue
                ? 500
                : ProcessorType.MaxPointsPerRequest() * 5;

            Logger = logger;
            Logger?.SetLoggedType(GetType());
        }
        public CollectionChangedHandler(
            ObservableCollection <ISelectableNode <TKey, TEntity> > obsColl,
            IJ4JLogger?logger,
            string collName = ""
            )
        {
            _obsColl = obsColl;

            _collName = string.IsNullOrWhiteSpace(collName) ? "target collection" : collName;
            _nodeName = $"{typeof(TEntity).Name}(s)";

            _allNodes = obsColl.SelectMany(x => x.DescendantsAndSelf)
                        .ToDictionary(x => x.Key, x => x);

            _logger = logger;
            _logger?.SetLoggedType(GetType());
        }
Exemplo n.º 16
0
        public OptionCollection(StringComparison textComparison,
                                ITextConverters converters,
                                IJ4JLogger?logger = null)
        {
            _textComparison = textComparison;
            _converters     = converters;

            _logger = logger;
            _logger?.SetLoggedType(GetType());

            _bindingTests = new List <Func <BindingInfo, bool> >
            {
                BindingSupported,
                CanConvert,
                HasParameterlessConstructor,
                HasAccessibleGetter,
                HasAccessibleSetter
            };
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            ConfigureServices();

            _logger = _svcProvider.GetService <IJ4JLogger>() !;
            _logger.SetLoggedType <Program>();

            var retriever = _svcProvider.GetService <DataRetriever>();

            var priceData = retriever !.GetPrices()
                            .OrderBy(d => d.MoneydanceAccount)
                            .ToList();

            var config = _svcProvider.GetService <Configuration>();

            if (File.Exists(config !.OutputFilePath))
            {
                File.Delete(config.OutputFilePath);
            }

            File.WriteAllText(config.OutputFilePath, priceData.ToCsv());
        }
Exemplo n.º 18
0
        public Tokenizer(ILexicalElements tokens,
                         IJ4JLogger?logger = null,
                         params ICleanupTokens[] cleanupProcessors)
        {
            TextComparison = tokens.TextComparison;
            _tokens        = tokens;

            _logger = logger;
            _logger?.SetLoggedType(GetType());

            if (cleanupProcessors.Length > 0)
            {
                _cleanupProcessors = cleanupProcessors;
            }
            else
            {
                _cleanupProcessors = new ICleanupTokens[]
                {
                    new ConsolidateQuotedText(TextComparison, _logger),
                    new MergeSequentialSeparators()
                }
            };
        }
 public NumericTickRange(IJ4JLogger?logger = null)
 {
     _logger = logger;
     _logger?.SetLoggedType(GetType());
 }
Exemplo n.º 20
0
 public MonthlyTickRange(IJ4JLogger?logger = null)
 {
     _logger = logger;
     _logger?.SetLoggedType(GetType());
 }
 protected PropertyUpdater(IJ4JLogger?logger)
 {
     Logger = logger;
     Logger?.SetLoggedType(GetType());
 }
Exemplo n.º 22
0
 protected TextToValue(IJ4JLogger?logger)
 {
     Logger = logger;
     Logger?.SetLoggedType(GetType());
 }
Exemplo n.º 23
0
 protected TopoAction(IJ4JLogger logger)
 {
     Logger = logger;
     Logger.SetLoggedType(GetType());
 }
 public TopologicalSortFactory(IJ4JLogger?logger)
 {
     _logger = logger;
     _logger?.SetLoggedType(GetType());
 }