private static void ComposeObjects() { var reader = new ServiceReader(); var viewModel = new PeopleViewModel(reader); Application.Current.MainWindow = new PeopleViewerWindow(viewModel); }
private static void ComposeObjects() { var wrappedReader = new ServiceReader(); var reader = new CachingReader(wrappedReader); var viewModel = new PeopleViewModel(reader); Current.MainWindow = new PeopleViewerWindow(viewModel); }
private static void ComposeCachedService() { var baseReader = new ServiceReader(); var cacheReader = new CachingReader(baseReader); var viewModel = new PetsViewModel(cacheReader); Application.Current.MainWindow = new PetViewerWindow(viewModel); }
static void Main(string[] args) { // dependency on the ServiceReader class IUserReader _IUserReader = new ServiceReader(); Program _program = new Program(_IUserReader); // Constructor injection in console application // https://stackoverflow.com/questions/53902234/constructor-injection-in-console-application _program.Invoke(); }
private static void ComposeObjects() // Assemble the loosely coupled pieces together... { //var reader = new ServiceReader(); //var reader = new CSVReader(); //var reader = new SQLReader(); var wrappedReader = new ServiceReader(); var reader = new CachingReader(wrappedReader); var viewModel = new PeopleViewModel(reader); Application.Current.MainWindow = new PeopleViewerWindow(viewModel); }
private static void ComposeObjects() { //With dependency injection we can switch to another service easily //var reader = new ServiceReader(); //var reader = new CSVReader(); //Adding cache functionality with dependency injection var wrappedReader = new ServiceReader(); var reader = new CachingReader(wrappedReader); var viewModel = new PeopleViewModel(reader); Application.Current.MainWindow = new PeopleViewerWindow(viewModel); }
private static void ComposeObjects() { var reader = new ServiceReader(); var delay = new TimeSpan(0, 0, 3); var retryReader = new RetryReader(reader, delay); var logger = new FileLogger(); var loggingReader = new ExceptionLoggingReader(retryReader, logger); var duration = new TimeSpan(0, 0, 10); var cachingReader = new CachingReader(loggingReader, duration); var viewModel = new PeopleReaderViewModel(cachingReader); Application.Current.MainWindow = new MainWindow(viewModel); }
private static void ComposeObjects() { //ServiceReader reader = new ServiceReader(); //CSVReader reader = new CSVReader(); //SQLReader reader = new SQLReader(); ServiceReader wrapperReader = new ServiceReader(); CachingReader reader = new CachingReader(wrapperReader); PeopleViewModel viewModel = new PeopleViewModel(reader); Current.MainWindow = new PeopleViewerWindow(viewModel); }
private static void ComposeObjects() { var reader = new ServiceReader(); var delay = new TimeSpan(0, 0, 3); var retryReader = new RetryReader(reader, delay); var logFilePath = AppDomain.CurrentDomain.BaseDirectory + "ExceptionLog.txt"; var logger = new FileLogger(logFilePath); var loggingReader = new ExceptionLoggingReader(retryReader, logger); var cachingReader = new CachingReader(loggingReader); var viewModel = new PeopleViewModel(cachingReader); Application.Current.MainWindow = new MainWindow(viewModel); }
private void ServiceFetchButton_Click(object sender, RoutedEventArgs e) { ClearListBox(); IPersonReader reader = new ServiceReader(); var people = reader.GetPeople(); foreach (var person in people) { PersonListBox.Items.Add(person); } ShowReaderType(reader); }
private static void ComposeObjectsForViewer() { // var reader = new ServiceReader(); //First Data Reader //var reader = new CSVReader(); //Second Data Reader var sqlReader = new SQLReader(); var serviceReader = new ServiceReader(); var reader = new CachingReader(sqlReader); var mainviewModel = new PeopleViewModel(reader); Application.Current.MainWindow = new PeopleViewerWindow(mainviewModel); Application.Current.MainWindow.Title = "Saja Makes the Dependency Injection Happen in WPFPlusASPNetCore 2020"; Application.Current.MainWindow.Show(); }
public static IPersonReader GetReader(string readerType) { IPersonReader reader; switch (readerType) { case "Service": reader = new ServiceReader(); break; case "CSV": reader = new CSVReader(); break; case "SQL": reader = new SQLReader(); break; default: throw new ArgumentException("Invalid reader type"); } return(reader); }
private static void ComposeObjects() { // Data Reader var readerUri = new ServiceReaderUri("http://localhost:9874"); var reader = new ServiceReader(readerUri); // Retry Function var delay = new TimeSpan(0, 0, 3); var retryReader = new RetryReader(reader, delay); // Exception Logging Function var logFilePath = AppDomain.CurrentDomain.BaseDirectory + "ExceptionLog.txt"; var logger = new FileLogger(logFilePath); var loggingReader = new ExceptionLoggingReader(retryReader, logger); // Caching Function var cachingReader = new CachingReader(loggingReader); var viewModel = new PeopleViewModel(retryReader); Application.Current.MainWindow = new MainWindow(viewModel); }
public void Setup() { //Arrange _serviceReader = new ServiceReader(); _fakeData = new FakeData(); }
public CountryDataController() { var serviceReader = new ServiceReader(); _countryRepository = new CachingReader(serviceReader); }
public PeopleViewModel() { Reader = new ServiceReader(); }
static void Main(string[] args) { //int choice = 0; //string file_path = @"F:\PProject\Advanced\MatrixLib\Matrix.txt"; //CsvReader reader = new CsvReader(file_path); //var assets = reader.GetAssetsFromFile(); //try //{ // Console.WriteLine("Enter Your Choice :"); // Console.WriteLine("1 : See Machine Type\n2 : See Asset Name\n3 : See latest series"); // choice = Int32.Parse(Console.ReadLine()); //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} //switch (choice) //{ // case 1: // Console.WriteLine("Enter Machine Name :"); // string m_name = Console.ReadLine().ToLower(); // var matches = assets.Where(x => x.MachineName.ToLower() == m_name).ToList<Assets>(); // foreach (var item in matches) // { // Console.WriteLine($"{item.MachineName},{item.AssetName},{item.SeriesName}"); // } // break; // case 2: // Console.WriteLine("Enter Asset Name : "); // string a_name = Console.ReadLine().ToLower(); // var Lines = assets.Where(x => x.AssetName.ToLower() == a_name).ToList<Assets>(); // foreach (var lines in Lines) // { // Console.WriteLine($"{lines.MachineName},{lines.AssetName},{lines.SeriesName}"); // } // break; // // case 3: // //var query = from s in assets // // group s by s.SeriesName into srgrp // // select new // // { // // machine = srgrp.Key, // // topseries=srgrp.Max(x=>x.SeriesName), // // }; // // var query = assets.Max(x => x.SeriesName); // //foreach (var item in query) // //{ // // Console.WriteLine($"{item.MachineName},{item.AssetName},{item.SeriesName}"); // //} // //break; // default: // break; //} int choice = 0; ServiceReader obj = new ServiceReader(); while (true) { try { Console.WriteLine("Enter Your Choice :"); Console.WriteLine("1 : See Machine Type\n2 : See Asset Name\n3 : See latest series\n4 : Exit"); choice = Int32.Parse(Console.ReadLine()); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (choice == 4) { break; } switch (choice) { case 1: Console.WriteLine("Enter Machine Name : "); string m_name = Console.ReadLine(); var data = obj.GetMachineType(m_name); foreach (var item in data) { Console.WriteLine($"{item.MachineName},{item.AssetName},{item.SeriesName}"); } break; case 2: Console.WriteLine("Enter Asset Name : "); string a_name = Console.ReadLine(); var data1 = obj.GetAssetType(a_name); foreach (var item in data1) { Console.WriteLine($"{item.MachineName},{item.AssetName},{item.SeriesName}"); } break; case 3: Console.WriteLine("Asset with Latest series is : "); var data3 = obj.UpdatedSeries(); foreach (var item in data3) { Console.WriteLine(item); } break; default: Console.WriteLine("Invalid choice..."); break; } } }