示例#1
0
 public static IServiceCollection AddDataRepositories(this IServiceCollection services)
 {
     return(services
            .AddSingleton(_ =>
     {
         var repo = new AuthorsRepository();
         repo.Initialize().GetAwaiter().GetResult();
         return repo;
     })
            .AddSingleton(services =>
     {
         var authorRepo = services.GetRequiredService <AuthorsRepository>();
         var repo = new NotesRepository();
         repo.Initialize(authorRepo).GetAwaiter().GetResult();
         return repo;
     }));
 }
示例#2
0
        public async ValueTask Initialize(AuthorsRepository authors)
        {
            var author1 = (await authors[1]) !.Value;
            var author2 = (await authors[2]) !.Value;
            var author3 = (await authors[3]) !.Value;
            var author4 = (await authors[4]) !.Value;

            var notes = new Note[]
            {
                new Note(_idCounter++, "Einkaufsliste:", "- Milch\r\n- 10 Eier\r\n- Mehl 2x\r\n- Wildlachsfilet\r\n- Kartoffeln, festkochend, 1kg\r\n- Wasser naturell",
                         author1, UtcDateTime(2020, 03, 22),
                         new Author[] { author3, author4 },
                         new Keyword[] { "Supermarkt", "Einkaufen", "Essen", "Lecker" }),

                new Note(_idCounter++, "Telefonnummern", "- Birgit: 06304 881710\r\n- Martin: 04661 140372\r\n- Martina: 03946 133192\r\n- Frau Gärtner: 07361 839716\r\n- Herr Fiedler: 03473 556168\r\n- Mandy: 09171 868797\r\n- Stephan: 036453 42651",
                         author4, UtcDateTime(2020, 05, 22),
                         new Author[] { author1 },
                         new Keyword[] { "Kontakte" }),

                new Note(_idCounter++, "Zitate",
                         "\"Life is a banquet. And the tragedy is that most people are starving to death.\" (Anthony de Mello)\r\n" +
                         "\"Every great idea starts out as a blasphemy.\" (Bertrand Russel)",
                         author2, UtcDateTime(2020, 05, 23),
                         new Author[] { author3 },
                         new Keyword[] { "Weisheit", "Infinite Love" }),

                new Note(_idCounter++, "Pi", "3.141592653589793238462643383279502884197169399375105820974945",
                         author3, UtcDateTime(2020, 06, 05),
                         new Author[0],
                         new Keyword[] { "Mathematik", "Konstanten" }),

                new Note(_idCounter++, "Eulersche Zahl", "2.718281828459",
                         author3, UtcDateTime(2020, 06, 10),
                         new Author[0],
                         new Keyword[] { "Mathematik", "Konstanten" }),

                new Note(_idCounter++, "Eulersche Identität", "e ^ (i⋅π) + 1 = 0",
                         author3, UtcDateTime(2020, 07, 01),
                         new Author[] { author2, author4 },
                         new Keyword[] { "Mathematik", "Formeln", "Schönheit" }),

                new Note(_idCounter++, "Kosinussatz", "c^2 = a^2 + b^2 – 2ab * cos γ",
                         author2, UtcDateTime(2020, 07, 01),
                         new Author[] { author4 },
                         new Keyword[] { "Mathematik", "Formeln" }),

                new Note(_idCounter++, "Ausbreitungsgeschwindigkeit elektromagnetischer Wellen im Vakuum", "c = 1 / √(ε0 ·μ0)",
                         author2, UtcDateTime(2020, 07, 03),
                         new Author[0],
                         new Keyword[] { "Physik", "Formeln" }),

                new Note(_idCounter++, "Schönes Gedicht", "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
                         author4, UtcDateTime(2020, 08, 31),
                         new Author[] { author3 },
                         new Keyword[] { "Lorem", "Literatur", "#Latein muss sein" }),

                new Note(_idCounter++, "Leseliste", "• Stephen Covey: 7 Habits of Highly Effective People\r\n• John Yates: The Illuminated Mind\r\n• Stefan Baron: Die Chinesen\r\n•Harper Lee: Wer die Nachtigall stört\r\n• John C. Maxwell: Failing Forward\r\n• Greg McKeown: Essentialism: The Disciplined Pursuit of Less\r\n• Yuval Noah Harari: 21 Lektionen für das 21.Jahrhundert\r\n• Friedrich Dürrenmatt: Die Physiker\r\n• Sandi Metz: 99 Bottles of OOP",
                         author1, UtcDateTime(2020, 08, 31),
                         new Author[0],
                         new Keyword[] { "Bücher", "Lesen", "Leseratte", "Wissen", "Weiterbildung" })
            };

            _notes = notes.ToDictionary(note => note.Id);
        }