private static void Initialize(TaxonStorage storage, int parentId, IEnumerable <Tree> elements) { foreach (var element in elements) { var entry = storage.Create(new Taxon(0, parentId, element.Name)); Initialize(storage, entry.Key, element.Elements); } }
private static void Initialize(TaxonStorage storage, int rootId, string filePath) { var yaml = new YamlStream(); using (var stream = File.OpenRead(filePath)) { yaml.Load(new StreamReader(stream)); var visitor = new TreeVisitor(); visitor.Visit(yaml); Initialize(storage, rootId, visitor.GetResult().Elements); } }
public static void Initialize(Func <FinancialPlannerContext> contextFactory, string directory) { using (var context = contextFactory()) { context.EnsureTableExists <CacheEntry>(); context.EnsureTableExists <TaxonDao>(); context.EnsureTableExists <FinancialJournalEntryDao>(); if (context.Taxons.Any()) { return; } } var taxonStorage = new TaxonStorage(contextFactory); Initialize(taxonStorage, BuiltInTaxonId.Expense, Path.Combine(directory, "Expenses.eyaml")); Initialize(taxonStorage, BuiltInTaxonId.Saving, Path.Combine(directory, "Savings.eyaml")); Initialize(taxonStorage, BuiltInTaxonId.Income, Path.Combine(directory, "Incomes.eyaml")); }