public MainController(CostPriceMethodCalculator costPriceMethodCalculator, Func <IReadOnlyList <Asset> > assetService) { CostPriceMethodCalculator = costPriceMethodCalculator; const string sellDate = "2/3/2005"; MainViewModel = new MainViewModel { SellDate = sellDate, CalculateAction = () => Calculate(), Assets = assetService() }; }
protected override void OnStartup(StartupEventArgs e) { EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotFocusEvent, new RoutedEventHandler(TextBox_GotFocus)); base.OnStartup(e); Dictionary<string, ICostMethod> costMethods = new Dictionary<string, ICostMethod> { {"Fifo", new Fifo()}, {"Lifo", new Lifo()}, {"Highest Cost", new HighestCost()}, {"Lowest Cost", new LowestCost()}, {"Weighted Average", new WeightedAverage()} }; var calculator = new CostPriceMethodCalculator(costMethods); var mainController = new MainController(calculator, AssetService.GetAssets); var mainWindow = new MainWindow() { DataContext = mainController.GetViewModel() }; mainWindow.Show(); }