private void SetValuesW(IWeatherDto dto) { lblCity.Text = dto.name; lblWeatherDesc.Text = $"Desc: {dto.weather.First().description}"; lblTemp.Text = $"Temp: {(dto.main.temp - 273.15).ToString()}°C"; pcbWeather.Image = Image.FromStream(CustomServiceContainer.GetService <IWeatherApi>().GetWeatherIcon(dto.weather.First().icon)); }
public Statistics_form(int fSize, bool labelStyle) { InitializeComponent(); _files = CustomServiceContainer.GetService <IFileManager>().GetAllFiles(resources.targetPath); ChartStyle(fSize, labelStyle); Initialize(); }
public Downloads_form() { InitializeComponent(); _files = new List <SavedFileModel>(); _files = CustomServiceContainer.GetService <IFileManager>().GetAllFiles(resources.targetPath); _files = _files.OrderBy(x => x.FileName); btnNameSort.Image = resources.up_arrow_sort_8px; alphOrder = 1; Initialize(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); CustomServiceContainer.AddService <IFileManager, FileManager>(new FileManager()); CustomServiceContainer.AddService <IWeatherApi, WeatherApi>(new WeatherApi()); MyFileWatcher fw = new MyFileWatcher(); var frm = new Form1(fw); Application.Run(frm); }
private async void SetWeather() { try { var data = await CustomServiceContainer.GetService <IWeatherApi>().GetWeatherData(resources.city, resources.weatherApiKey); var dto = CustomServiceContainer.GetService <IWeatherApi>().GetWeatherDto(data); SetValuesW(dto); } catch (Exception) { SetDefValuesW(); } }
//private async void _fileWatcher_Created(object sender, FileSystemEventArgs e) { } private async void _fileWatcher_Changed(object sender, FileSystemEventArgs e) { var files = await CustomServiceContainer.GetService <IFileManager>().GetDirFiles(resources.sourcePath, resources.targetPath); foreach (var file in files) { var result = await CustomServiceContainer.GetService <IFileManager>().MoveFiles(file, resources.sourcePath, resources.targetPath); if (result) { Notification_form ntf = new Notification_form(file.TargetPath); var msg = file.FileName.Length > 10 ? file.FileName.Substring(0, 10) + "..." : file.FileName; ntf.showAlert(msg + " has downloaded", file.Creation.ToString("h:mm tt")); } } }
public void RemoveService_Promote_Success(Type serviceType) { var parentContainer = new CustomServiceContainer(); int removeServiceCallCount = 0; parentContainer.RemoveServiceAction = (callbackServiceType, callbackPromote) => { Assert.Same(serviceType, callbackServiceType); Assert.True(callbackPromote); removeServiceCallCount++; }; var parentProvider = new MockServiceProvider(); parentProvider.Setup(typeof(IServiceContainer), parentContainer); var container = new ServiceContainer(parentProvider); container.RemoveService(serviceType, promote: true); Assert.Equal(1, removeServiceCallCount); }
public void AddService_PromoteCallback_Success(Type serviceType, ServiceCreatorCallback callback) { var parentContainer = new CustomServiceContainer(); int addServiceCallCount = 0; parentContainer.AddServiceCallbackAction = (callbackServiceType, callbackCallback, callbackPromote) => { Assert.Same(serviceType, callbackServiceType); Assert.Same(callback, callbackCallback); Assert.True(callbackPromote); addServiceCallCount++; }; var parentProvider = new MockServiceProvider(); parentProvider.Setup(typeof(IServiceContainer), parentContainer); var container = new ServiceContainer(parentProvider); container.AddService(serviceType, callback, promote: true); Assert.Equal(1, addServiceCallCount); }
public void AddService_PromoteObject_Success(Type serviceType, object serviceInstance) { var parentContainer = new CustomServiceContainer(); int addServiceCallCount = 0; parentContainer.AddServiceObjectAction = (callbackServiceType, callbackServiceInstance, callbackPromote) => { Assert.Same(serviceType, callbackServiceType); Assert.Same(serviceInstance, callbackServiceInstance); Assert.True(callbackPromote); addServiceCallCount++; }; var parentProvider = new MockServiceProvider(); parentProvider.Setup(typeof(IServiceContainer), parentContainer); var container = new ServiceContainer(parentProvider); container.AddService(serviceType, serviceInstance, promote: true); Assert.Equal(1, addServiceCallCount); }