public WeatherHourlyViewModel(ApplicationViewModel applicationViewModel, IWeatherDataProvider weatherProvider) { application = applicationViewModel; weather = weatherProvider; BackCommand = new RelayCommand(Back); DailyCommand = new RelayCommand(GotoDaily); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IWeatherDataProvider weatherDataProvider) { _weatherDataProvider = weatherDataProvider; Cities = new ObservableCollection <CityViewModel>(); _dispatcher = Dispatcher.CurrentDispatcher; SelectCityCommand = new RelayCommand <CityViewModel>(OnSelectCity); LoadCitiesCommand = new RelayCommand(OnLoadCities, () => _isLoadingEnabled); OnLoadCities(); }
public WeatherPanel(IWeatherDataProvider weatherDataProvider) { InitializeComponent(); DataContextChanged += (sender, args) => MainWindow.UpdateTaskbarIconCommand.Execute(DataContext, this); CommandBindings.Add(new CommandBinding(MainWindow.Switch7DayForecastCommand, Switch7DayForecastCommandHandler)); Loaded += async (s, e) => { _timer.Interval = TimeSpan.FromMinutes(10); _timer.Tick += async (o, eventArgs) => DataContext = await weatherDataProvider.GetWeather() ?? DataContext; _timer.Start(); DataContext = await weatherDataProvider.GetWeather() ?? new WeatherData(); }; Unloaded += (s, e) => _timer.Stop(); }
public WeatherPanel(IWeatherDataProvider weatherDataProvider) { InitializeComponent(); DataContextChanged += (sender, args) => MainWindow.UpdateTaskbarIconCommand.Execute(DataContext, this); CommandBindings.Add(new CommandBinding(MainWindow.Switch7DayForecastCommand, Switch7DayForecastCommandHandler)); Loaded += async(s, e) => { _timer.Interval = TimeSpan.FromMinutes(10); _timer.Tick += async(o, eventArgs) => DataContext = await weatherDataProvider.GetWeather() ?? DataContext; _timer.Start(); DataContext = await weatherDataProvider.GetWeather() ?? new WeatherData(); }; Unloaded += (s, e) => _timer.Stop(); }
public Weather(IWeatherDataProvider weatherDataProvider) { InitializeComponent(); _weatherDataProvider = weatherDataProvider; Loaded += (sender, args) => { var weather = Observable.Interval(TimeSpan.FromMinutes(15)) .SelectMany(_ => weatherDataProvider.GetWeather().ToObservable()) .ObserveOnDispatcher() .Subscribe(data => DataContext = data); disposables.Add(weather); }; Unloaded += (sender, args) => disposables.Dispose(); }
public SollarBatteryEstimator(IWeatherDataProvider weatherProvider, ILogger logger) { if (weatherProvider == null) { throw new ArgumentNullException(nameof(weatherProvider), "weatherProvider is null, can't create SollarBatteryEstimator"); } if (logger == null) { throw new ArgumentNullException(nameof(logger), "logger is null"); } this.weatherProvider = weatherProvider; this.logger = logger; logger.Info($"Weather provider for SollarBatteryEstimator is - {weatherProvider}"); }
public DayCoursePresentViewModel(ApplicationViewModel applicationViewModel, IDataProvider dataProvider, IWeatherDataProvider weatherProvider) { application = applicationViewModel; data = dataProvider; weather = weatherProvider; InitializeListener(); GoToWeatherPageCommand = new RelayCommand(GoToWeatherPage); //TODO: 仅在窗口打开后才执行下面语句 InitTime(); if (data.WeatherForecastEnabled) { InitWeather(); } }
static void Main(string[] args) { IKernel kernel = new StandardKernel(new CustomerModule()); // Easy way to create factory. No class created, only interface. IAutomobileFactory factory = kernel.Get <IAutomobileFactory>(); // Instead of NEW keyword IAutomobile instance = factory.CreateAutomobile("Honda", "Civic", 500); IAutomobile instance2 = factory.CreateAutomobile("Honda", "Jazz", 200); Console.WriteLine(instance.Price); Console.WriteLine(instance2.Price); // Inject dependency IInputOutputProvider into IWheaterDataProvider IWeatherDataProvider weather = kernel.Get <IWeatherDataProvider>(); weather.DisplayWeatherInformation("Wonderful wheater"); }
async Task GenerateData() { #if true pbiClient = new PBIClient(); #else pbiClient = new MockupPBIClient(); #endif this.statusValue.Text = "Waiting for authentication token..."; AuthData authData = await pbiClient.AcquireDeviceCodeAsync(); this.passcode.Text = string.Format("Navigate to {0} and enter {1}", authData.VerificationUrl, authData.UserCode); await pbiClient.CompleteAuthentication(); this.statusValue.Text = "Token received, connecting to PBI..."; this.passcode.Visibility = Windows.UI.Xaml.Visibility.Collapsed; await pbiClient.ConnectAsync(); this.statusValue.Text = "Connection to PBI established. Creating dataset..."; await pbiClient.CreateDatasetAsync(datasetName); this.statusValue.Text = "Dataset created"; await ClearData(); #if true dataProvider = await SensorWeatherDataProvider.Create(); #else dataProvider = new SimulatedWeatherDataProvider(); #endif this.resetButton.Visibility = Windows.UI.Xaml.Visibility.Visible; await GenerateWeatherData(); this.statusValue.Text = "All data pushed to Power BI"; }
public WeatherService(IWeatherDataProvider weatherDataProvider, IOptions <MyConf> key) { _weatherDataProvider = weatherDataProvider; MyConf = key.Value; }
public WeatherService(IWeatherDataProvider weatherDataProvider, IBackupService backupService) { _weatherDataProvider = weatherDataProvider; _backupService = backupService; }
public WeatherAuditor(ILogger logger, IWeatherDataProvider weatherdatapprovider, SollarBatteryEstimator battery) { this.logger = logger; this.weatherdatapprovider = weatherdatapprovider; this.battery = battery; }
// True IOC constuctor public WeatherRepository(IWeatherDataProvider provider) { weatherDataProvider = provider; }
public WeatherApp() { _weatherDataProvider = new WeatherReportDataProvider(); }
// For this project, since I do not have an IoC container, I have decided to use an extraordinarily basic factory to act as my IOC :) public WeatherRepository() { weatherDataProvider = FakeIOCContainerFactory.CreateWeatherDataProvider(); }
public HomeController(IWeatherDataProvider weather) { this.weather = weather; }
public void Initialize() { webClient = new WebClients.CurrentConditionsValidWebClient(); service = new WeatherDataService(webClient); }
public SampleDataController(IWeatherDataProvider dataProvider) { _dataProvider = dataProvider; }