public Form2(IImagePathRepository imagePathRepository, IDayWeatherRepository dayWeatherRepository) { InitializeComponent(); _imagePathRepository = imagePathRepository; _dayWeatherRepository = dayWeatherRepository; Import(); tabControl1.TabPages.Clear(); foreach (UserControl uc in _controls) { TabPage tp = new TabPage(); var displayNameAttribute = uc.GetType().GetCustomAttribute(typeof(DisplayNameAttribute)) as DisplayNameAttribute; if (displayNameAttribute != null) { tp.Text = displayNameAttribute.DisplayName; } if (uc is AddDayWeather addDayWeather) { addDayWeather.InitAll(_imagePathRepository, _dayWeatherRepository); } if (uc is WeatherView weatherView) { var weatherService = new WeatherService(_imagePathRepository, _dayWeatherRepository); weatherView.ResourcesPath = weatherService.GetImagePathList(); weatherView.Items = weatherService.GetDayWeatherList(); } uc.Dock = DockStyle.Fill; tp.Controls.Add(uc); tabControl1.TabPages.Add(tp); } }
public WeatherService(IImagePathRepository imagePathRepository, IDayWeatherRepository dayWeatherRepository) { try { //_imagePathRepository = new ImagePathRepository("weatherConnStr"); //_dayWeatherRepository = new DayWeatherRepository("weatherConnStr"); //_imagePathRepository = new ImagePathEfRepository(); //_dayWeatherRepository = new DayWeatherEfRepository(); _imagePathRepository = imagePathRepository; _dayWeatherRepository = dayWeatherRepository; } catch (Exception ex) { throw new Exception(MyStrings.ConnError + ex.Message, ex); } var config = new MapperConfiguration(cfg => { cfg.CreateMap <ImagePath, CustomWeather.ImagePath>(); cfg.CreateMap <DayWeather, CustomWeather.DayWeather>() .ForMember(dest => dest.Weather, opts => opts.MapFrom(src => GetWeatherType(_imagePathRepository.Get(src.IdImagePath)))); }); _mapper = config.CreateMapper(); }
static void Main(string[] args) { //try //{ IUnityContainer container = BuildContainer(); IDayWeatherRepository dayWeatherRepository = (IDayWeatherRepository)container.Resolve <IDayWeatherRepository>(); IImagePathRepository imagePathRepository = (IImagePathRepository)container.Resolve <IImagePathRepository>(); var weatherService = new WeatherService(imagePathRepository, dayWeatherRepository); var dayWeatherList = weatherService.GetDayWeatherList(); WeatherForecast.DayWeather dayWeather; for (int i = 0; i < 500000; i++) { dayWeather = new WeatherForecast.DayWeather() { Day = new DateTime(i + 1, i % 12 + 1, i % 25 + 1), Weather = WeatherForecast.Weather.Cloudy, DayTemperature = i % 60 - 10, NightTemperature = i % 60 - 29 }; //Console.WriteLine($"{dayWeather.Day.ToString()}, {dayWeather.Weather}, {dayWeather.DayTemperature}"); weatherService.AddDayWeather(dayWeather); } //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} Console.WriteLine("End"); Console.ReadKey(); }
static void Main() { IUnityContainer container = BuildContainer(); IDayWeatherRepository dayWeatherRepository = (IDayWeatherRepository)container.Resolve <IDayWeatherRepository>(); IImagePathRepository imagePathRepository = (IImagePathRepository)container.Resolve <IImagePathRepository>(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); form1 = new Form1(imagePathRepository, dayWeatherRepository); Application.Run(form1); }
public void InitAll(IImagePathRepository imagePathRepository, IDayWeatherRepository dayWeatherRepository) { try { _weatherService = new WeatherService(imagePathRepository, dayWeatherRepository); imagePathList = _weatherService.GetImagePathList(); dayWeatherList = _weatherService.GetDayWeatherList(); InitListBox(); LoadUserConfig(); } catch (Exception ex) { throw new Exception(MyStrings.OpenException + ex.Message, ex); } }
public Form1(IImagePathRepository imagePathRepository, IDayWeatherRepository dayWeatherRepository) { if (!String.IsNullOrEmpty(Properties.Settings.Default.Language)) { System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language); } InitializeComponent(); _imagePathRepository = imagePathRepository; _dayWeatherRepository = dayWeatherRepository; AddDayWeather(); LoadData(); }
public AddDayWeather(IImagePathRepository imagePathRepository, IDayWeatherRepository dayWeatherRepository) { InitializeComponent(); InitAll(imagePathRepository, dayWeatherRepository); }