예제 #1
0
 public WeatherService(
     IWeatherClient weatherClient,
     IClientConfiguration configuration)
 {
     _weatherClient = weatherClient;
     _configuration = configuration;
 }
예제 #2
0
 public FrontEndLogic(IWeatherClient weatherClient, ICityDataAccess cityDataAccess, IConsoleWrapper consoleWrapper, int?loops = null)
 {
     _weatherClient  = weatherClient;
     _cityDataAccess = cityDataAccess;
     _consoleWrapper = consoleWrapper;
     _loops          = loops; // Avoid infinite loop for testing purposes. Yuck!
 }
예제 #3
0
 public void Remove(IWeatherClient client)
 {
     if (registeredClients.Contains<IWeatherClient>(client))
     {
         registeredClients.Remove(client);
     }
 }
예제 #4
0
 public void Register(IWeatherClient client)
 {
     if (!registeredClients.Contains <IWeatherClient>(client))
     {
         registeredClients.Add(client);
     }
 }
예제 #5
0
 public void Remove(IWeatherClient client)
 {
     if (registeredClients.Contains <IWeatherClient>(client))
     {
         registeredClients.Remove(client);
     }
 }
예제 #6
0
 public HomeController(ILogger <HomeController> logger, IConfiguration configuration,
                       IWeatherClient weatherClient, IWeatherData weatherData)
 {
     _logger        = logger;
     _configuration = configuration;
     _weatherClient = weatherClient;
     _weatherData   = weatherData;
 }
 public WeatherNowController(IWeatherClient <string> weatherClient,
                             ILogger <WeatherNowController> logger,
                             IConfiguration config,
                             IOptions <OpenWeatherMapSettings> openWeatherSettingsAccessor,
                             IMapper mapper)
 {
     _weatherClient       = weatherClient;
     _logger              = logger;
     _configuration       = config;
     _openWeatherSettings = openWeatherSettingsAccessor.Value;
     _mapper              = mapper;
 }
예제 #8
0
        public void Init()
        {
            _weatherClient  = Substitute.For <IWeatherClient>();
            _cityDataAccess = Substitute.For <ICityDataAccess>();
            _consoleWrapper = Substitute.For <IConsoleWrapper>();

            _weatherClient.CitySearch(Arg.Any <string>()).Returns(new List <SearchCityDto>());
            _weatherClient.GetWeather(Arg.Any <string>()).Returns(new CurrentWeatherDto());
            _cityDataAccess.GetAllCities().Returns(new List <SearchCityDto>());
            _consoleWrapper.WriteLine(Arg.Any <string>());
            _consoleWrapper.ReadLine().Returns(string.Empty);

            _sut = new FrontEndLogic(_weatherClient, _cityDataAccess, _consoleWrapper, 1);
        }
 public WeatherController(IWeatherClient weatherClient) => _weatherClient = weatherClient;
예제 #10
0
 public WeatherController(IWeatherClient weatherClient, IMapper mapper)
 {
     _weatherClient = weatherClient;
     _mapper        = mapper;
 }
 public WeatherClient(string url)
 {
     _internalClient = RestService.For <IWeatherClient>(url);
 }
예제 #12
0
 public void Register(IWeatherClient client)
 {
     if(!registeredClients.Contains<IWeatherClient>(client))
         registeredClients.Add(client);
 }
예제 #13
0
 public CachingDecorator(IWeatherClient client, IMemoryCache cache)
 {
     DecoratedWeatherClient = client;
     WeatherResultsCache    = cache;
 }
예제 #14
0
 public WeatherController(ILogger <WeatherController> logger, IWeatherClient weaterClient)
 {
     this.logger = logger;
     wClient     = weaterClient;
 }
예제 #15
0
 public WeatherService(IWeatherClient singleClient)
 {
     _singleClient = singleClient;
 }
예제 #16
0
 public WeatherCommands(IWeatherClient weatherClient, IHttpContextAccessor httpContextAccessor)
 {
     _weatherClient = weatherClient;
     _httpContextAccessor = httpContextAccessor;
 }
예제 #17
0
 public HomeController(IWeatherClient weatherClient)
 {
     WeatherClient = weatherClient;
 }
예제 #18
0
 public DashboardHandler(IStorageService storageService, IWeatherClient weatherClient, IStockClient stockClient)
 {
     this.storageService = storageService;
     this.weatherClient  = weatherClient;
     this.stockClient    = stockClient;
 }
예제 #19
0
 public ApixuWeatherServiceAdapter(IWeatherClient client)
 {
     _client = client;
 }
예제 #20
0
 /// <summary>
 /// Creates the weather client cache decorator object.  You pass in the the
 /// IWeatherClient object to be decorated (ie wrapped)
 /// </summary>
 /// <param name="weatherClient">Am IWeatherClient object of the object to be decorated</param>
 public WeatherClientCacheDecorator(IWeatherClient weatherClient)
 {
     this.wrappedWeatherClient = weatherClient;
 }
예제 #21
0
 /// <summary>
 /// Forecast
 /// </summary>
 /// <param name="weatherClient"></param>
 public ForecastController(IWeatherClient weatherClient)
 {
     _weatherClient = weatherClient;
 }
예제 #22
0
 public WeatherController(IWeatherClient weatherClient)
 {
     this.weatherClient = weatherClient;
 }
 /// <summary>
 /// Initialize new instance
 /// </summary>
 /// <param name="client">Http client</param>
 public WeatherRepository(IWeatherClient client)
 {
     _client = client ?? throw new ArgumentNullException(nameof(client));
 }
예제 #24
0
 public WeatherController(ILogger <WeatherController> logger, IWeatherClient weatherClient, IStationRepository stationRepository)
 {
     _logger            = logger;
     _weatherClient     = weatherClient;
     _stationRepository = stationRepository;
 }
        //private readonly IMapper _mapper;

        public ForecastController(IWeatherClient weatherClient, IConfiguration config)//, IMapper mapper)
        {
            _weatherClient = weatherClient;
            _config        = config;
            //_mapper = mapper;
        }
예제 #26
0
        public WeatherModule(IWeatherCommandParser parser, IWeatherClient client)
        {
            Post["/weather", true] = async (_, token) =>
            {
                var request = this.Bind<SlackRequest>();

                try
                {
                    Command c = null;
                    if (parser.TryParse(request, out c))
                    {
                        var postalCode = c.Arguments.First();
                        var units = c.Arguments.Count() == 2
                            ? (Units) Enum.Parse(typeof (Units), c.Arguments.ElementAt(1), true)
                            : Units.Imperial;

                        var responseType =
                            c.Arguments.Any(arg => arg.Equals(ShareArgument, StringComparison.OrdinalIgnoreCase))
                                ? ResponseType.InChannel
                                : ResponseType.Ephemeral;

                        var weatherData = await client.GetWeatherAsync(postalCode, units);
                        var currentCondition = weatherData.WeatcherCondition.FirstOrDefault();

                        var unitString = units == Units.Imperial ? "F" : "C";
                        var currentConditionIconUrl = string.Empty;
                        var currentConditionText = string.Empty;

                        if (currentCondition != null)
                        {
                            currentConditionIconUrl = string.Format(IconUrlFormat, currentCondition.IconId);
                            currentConditionText = $"{currentCondition.Main} - {currentCondition.Description}";
                        }

                        return
                            new SlackResponse()
                            {
                                ResponseType = ResponseType.Ephemeral,
                                Text = $"Here's the current weather for {weatherData.CityName}!",
                                Attachments = new[]
                                {
                                    new SlackResponseAttachment()
                                    {
                                        Title = "Current Conditions",
                                        ThumbUrl = currentConditionIconUrl,
                                        Text = currentConditionText,
                                        Fields = new []
                                        {
                                            new SlackField()
                                            {
                                                Title = "Temperature",
                                                Value = $"{Math.Round(weatherData.Weather.Temperature, 2)}° {unitString}",
                                                IsShort = true
                                            },
                                            new SlackField()
                                            {
                                                Title = "Humidity",
                                                Value = $"{weatherData.Weather.Humidity}%",
                                                IsShort = true
                                            }, 
                                            new SlackField()
                                            {
                                                Title = "Pressure",
                                                Value = $"{weatherData.Weather.Pressure} hPa",
                                                IsShort = true
                                            }, 
                                        }
                                    }
                                }
                            };
                    }
                }
                catch
                {
                    // TODO: don't filter critical exception types
                    return DefaultResponse();
                }

                return DefaultResponse();
            };
        }
예제 #27
0
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IWeatherClient client)
 {
     _logger     = logger;
     this.client = client;
 }
예제 #28
0
 public ForecastService(IWeatherClient weatherClient)
 {
     this.weatherClient = weatherClient;
 }
 public WeatherService(IWeatherClient weatherClient)
 {
     this._weatherClient = weatherClient;
 }
 public DependencyInjectionController(IWeatherClient weatherClient)
 {
     this.weatherClient = weatherClient;
 }
예제 #31
0
 public MetaWeatherServiceAdapter(IWeatherClient client)
 {
     _client = client;
 }