예제 #1
0
 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));
 }
예제 #2
0
        public Statistics_form(int fSize, bool labelStyle)
        {
            InitializeComponent();

            _files = CustomServiceContainer.GetService <IFileManager>().GetAllFiles(resources.targetPath);

            ChartStyle(fSize, labelStyle);
            Initialize();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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);
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        //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"));
                }
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }