Skip to content

Commit

Permalink
Merge pull request #30 from zxbmmmmmmmmm/refactor/perf
Browse files Browse the repository at this point in the history
Refactor/perf
  • Loading branch information
zxbmmmmmmmmm authored Feb 3, 2024
2 parents 8283e02 + e86126b commit 4a7572f
Show file tree
Hide file tree
Showing 71 changed files with 282 additions and 557 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FluentWeather.OpenMeteoProvider.Models;

public class OpenMeteoAirCondition : AirConditionBase
public sealed class OpenMeteoAirCondition : AirConditionBase
{
public override string? AqiCategory => UnitConverter.GetAqiCategoryUS(Aqi);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

namespace FluentWeather.OpenMeteoProvider.Models;

public class OpenMeteoDailyForecast : WeatherDailyBase
public sealed class OpenMeteoDailyForecast : WeatherDailyBase
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace FluentWeather.OpenMeteoProvider.Models;

public class OpenMeteoHourlyForecast : WeatherHourlyBase, ICloudAmount
public sealed class OpenMeteoHourlyForecast : WeatherHourlyBase, ICloudAmount
{
public int? CloudAmount { get ; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace FluentWeather.OpenMeteoProvider.Models;

public class OpenMeteoWeatherNow : WeatherNowBase
public sealed class OpenMeteoWeatherNow : WeatherNowBase
{
}
2 changes: 1 addition & 1 deletion FluentWeather.OpenMeteoProvider/OpenMeteoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace FluentWeather.OpenMeteoProvider;

public class OpenMeteoProvider : ProviderBase, ICurrentWeatherProvider, IAirConditionProvider, IDailyForecastProvider, IHourlyForecastProvider
public sealed class OpenMeteoProvider : ProviderBase, ICurrentWeatherProvider, IAirConditionProvider, IDailyForecastProvider, IHourlyForecastProvider
{
public override string Name => "OpenMeteo";
public override string Id => "open-meteo";
Expand Down
3 changes: 2 additions & 1 deletion FluentWeather.QGeoApi/ApiContracts/GeolocationApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using FluentWeather.QGeoApi.Bases;
using System;

namespace FluentWeather.QGeoApi.ApiContracts
{
Expand All @@ -27,7 +28,7 @@ public Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHandlerOption opt
{
query = $"?key={option.Token}&location={byName.Name}";
}
if(option.Language is not null)
if (option.Language is not null)
query += $"&lang={option.Language}";
var requestMessage = new HttpRequestMessage(Method, Url + query);

Expand Down
2 changes: 1 addition & 1 deletion FluentWeather.QGeoProvider/Models/QGeolocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FluentWeather.QGeoProvider.Models
{
public class QGeolocation : GeolocationBase
public sealed class QGeolocation : GeolocationBase
{
public QGeolocation(string name,double lon, double lat):base(name,lon,lat)
{
Expand Down
2 changes: 1 addition & 1 deletion FluentWeather.QGeoProvider/QGeoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void GetSettings()
Option.Token = settingsHelper?.ReadLocalSetting(Id + "." + QGeoSettings.Token, "");
var language = settingsHelper?.ReadLocalSetting<string>(QGeoSettings.Language.ToString(), null);
if (language is null) return;
if (language.Contains("-") && !language.Contains("zh"))
if (language.Contains("-") && !language.Contains("zh-hant"))
{
Option.Language = language.Remove(language.IndexOf("-", StringComparison.Ordinal));
}
Expand Down
4 changes: 2 additions & 2 deletions FluentWeather.QWeatherApi/ApiContracts/AirConditionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace FluentWeather.QWeatherApi.ApiContracts
{
public class AirConditionApi : QApiContractBase<AirConditionResponse>
public sealed class AirConditionApi : QApiContractBase<AirConditionResponse>
{
public override HttpMethod Method => HttpMethod.Get;

public override string Path => ApiConstants.Weather.AirCondition;
}
public class AirConditionResponse:QWeatherResponseBase
public sealed class AirConditionResponse:QWeatherResponseBase
{
[JsonPropertyName("now")]
public AirConditionItem AirConditionNow { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions FluentWeather.QWeatherApi/ApiContracts/PrecipitationApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace FluentWeather.QWeatherApi.ApiContracts
{
public class PrecipitationApi : QApiContractBase<PrecipitationResponse>
public sealed class PrecipitationApi : QApiContractBase<PrecipitationResponse>
{
public override HttpMethod Method => HttpMethod.Get;

public override string Path => ApiConstants.Weather.MinutelyPrecipitation;
}
public class PrecipitationResponse:QWeatherResponseBase
public sealed class PrecipitationResponse:QWeatherResponseBase
{
[JsonPropertyName("minutely")]
public List<PrecipitationItem> MinutelyPrecipitations { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions FluentWeather.QWeatherApi/ApiContracts/TyphoonForecastApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FluentWeather.QWeatherApi.ApiContracts
{
public class TyphoonForecastApi : QApiContractBase<TyphoonForecastRequest, TyphoonForecastResponse>
public sealed class TyphoonForecastApi : QApiContractBase<TyphoonForecastRequest, TyphoonForecastResponse>
{
public override HttpMethod Method => HttpMethod.Get;

Expand All @@ -19,11 +19,11 @@ public async override Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHa
return (await base.GenerateRequestMessageAsync(option)).AddQuery($"&stormid={Request.TyphoonId}");
}
}
public class TyphoonForecastRequest : RequestBase
public sealed class TyphoonForecastRequest : RequestBase
{
public string TyphoonId { get; set; }
}
public class TyphoonForecastResponse
public sealed class TyphoonForecastResponse
{
[JsonPropertyName("forecast")]
public List<TyphoonForecastItem> Forecasts { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions FluentWeather.QWeatherApi/ApiContracts/TyphoonListApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace FluentWeather.QWeatherApi.ApiContracts;

public class TyphoonListApi : QApiContractBase<RequestBase,TyphoonListResponse>
public sealed class TyphoonListApi : QApiContractBase<RequestBase,TyphoonListResponse>
{
public override HttpMethod Method => HttpMethod.Get;

Expand All @@ -22,7 +22,7 @@ public async override Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHa
return res;
}
}
public class TyphoonListResponse
public sealed class TyphoonListResponse
{
[JsonPropertyName("storm")]
public List<TyphoonListItem> Typhoons { get; set; }
Expand Down
10 changes: 5 additions & 5 deletions FluentWeather.QWeatherApi/ApiContracts/TyphoonTrackApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace FluentWeather.QWeatherApi.ApiContracts;
/// <summary>
/// 台风当前情况和历史
/// </summary>
public class TyphoonTrackApi : QApiContractBase<TyphoonTrackRequest, TyphoonTrackResponse>
public sealed class TyphoonTrackApi : QApiContractBase<TyphoonTrackRequest, TyphoonTrackResponse>
{
public override HttpMethod Method => HttpMethod.Get;

Expand All @@ -23,11 +23,11 @@ public async override Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHa
return (await base.GenerateRequestMessageAsync(option)).AddQuery($"&stormid={Request.TyphoonId}");
}
}
public class TyphoonTrackRequest:RequestBase
public sealed class TyphoonTrackRequest:RequestBase
{
public string TyphoonId { get; set; }
}
public class TyphoonTrackResponse
public sealed class TyphoonTrackResponse
{
[JsonPropertyName("isActive")]
public string IsActive { get;set; }
Expand All @@ -38,7 +38,7 @@ public class TyphoonTrackResponse
[JsonPropertyName("track")]
public List<TyphoonTrackItem> Tracks { get; set; }
}
public class TyphoonTrackItem
public sealed class TyphoonTrackItem
{
[JsonPropertyName("pubTime")]
private string _pubTime
Expand Down Expand Up @@ -83,7 +83,7 @@ private string _pubTime
public WindRadiusItem WindRadius12 { get; set; }


public class WindRadiusItem
public sealed class WindRadiusItem
{
[JsonPropertyName("neRadius")]
public string NeRadius { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions FluentWeather.QWeatherApi/ApiContracts/WeatherDailyApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace FluentWeather.QWeatherApi.ApiContracts;

public class WeatherDailyApi:QApiContractBase<WeatherDailyResponse>
public sealed class WeatherDailyApi:QApiContractBase<WeatherDailyResponse>
{
public override HttpMethod Method => HttpMethod.Get;
public override string Path => ApiConstants.Weather.DailyForecast7D;
Expand All @@ -23,7 +23,7 @@ public async override Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHa
}
}

public class WeatherDailyResponse : QWeatherResponseBase
public sealed class WeatherDailyResponse : QWeatherResponseBase
{
[JsonPropertyName("daily")]
public List<DailyForecastItem> DailyForecasts { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions FluentWeather.QWeatherApi/ApiContracts/WeatherHourlyApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace FluentWeather.QWeatherApi.ApiContracts;

public class WeatherHourlyApi: QApiContractBase<WeatherHourlyResponse>
public sealed class WeatherHourlyApi: QApiContractBase<WeatherHourlyResponse>
{
public override HttpMethod Method => HttpMethod.Get;
public override string Path => ApiConstants.Weather.HourlyForecast24H;
Expand All @@ -21,10 +21,10 @@ public async override Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHa
return res;
}
}
public class WeatherHourlyResponse : QWeatherResponseBase
public sealed class WeatherHourlyResponse : QWeatherResponseBase
{
[JsonPropertyName("hourly")] public List<HourlyForecastItem> HourlyForecasts { get; set; }
public class HourlyForecastItem
public sealed class HourlyForecastItem
{
[JsonPropertyName("fxTime")]
public string FxTime { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions FluentWeather.QWeatherApi/ApiContracts/WeatherIndicesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace FluentWeather.QWeatherApi.ApiContracts;

public class WeatherIndicesApi : QApiContractBase<WeatherIndicesResponse>
public sealed class WeatherIndicesApi : QApiContractBase<WeatherIndicesResponse>
{
public override HttpMethod Method => HttpMethod.Get;
public override string Path => ApiConstants.Weather.WeatherIndices1D;
Expand All @@ -19,7 +19,7 @@ public override async Task<HttpRequestMessage> GenerateRequestMessageAsync(ApiHa
return res;
}
}
public class WeatherIndicesResponse : QWeatherResponseBase
public sealed class WeatherIndicesResponse : QWeatherResponseBase
{
[JsonPropertyName("daily")] public List<IndicesItem> Indices { get; set; }
public class IndicesItem
Expand Down
6 changes: 3 additions & 3 deletions FluentWeather.QWeatherApi/ApiContracts/WeatherNowApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace FluentWeather.QWeatherApi.ApiContracts;

public class WeatherNowApi: QApiContractBase<WeatherNowResponse>
public sealed class WeatherNowApi: QApiContractBase<WeatherNowResponse>
{
public override HttpMethod Method => HttpMethod.Get;
public override string Path => ApiConstants.Weather.Now;
}
public class WeatherNowResponse : QWeatherResponseBase
public sealed class WeatherNowResponse : QWeatherResponseBase
{
[JsonPropertyName("now")]
public WeatherNowItem WeatherNow { get; set; }
public class WeatherNowItem
public sealed class WeatherNowItem
{
[JsonPropertyName("obsTime")]
public string ObsTime { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions FluentWeather.QWeatherApi/ApiContracts/WeatherWarningApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

namespace FluentWeather.QWeatherApi.ApiContracts;

public class WeatherWarningApi: QApiContractBase<WeatherWarningResponse>
public sealed class WeatherWarningApi: QApiContractBase<WeatherWarningResponse>
{
public override HttpMethod Method => HttpMethod.Get;
public override string Path => ApiConstants.Weather.WarningNow;
}
public class WeatherWarningResponse : QWeatherResponseBase
public sealed class WeatherWarningResponse : QWeatherResponseBase
{
[JsonPropertyName("warning")]
public List<WeatherWarningItem> Warnings { get; set; }
public class WeatherWarningItem
public sealed class WeatherWarningItem
{
[JsonPropertyName("id")]
public string Id { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion FluentWeather.QWeatherProvider/Models/QAirCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace FluentWeather.QWeatherProvider.Models
{
public class QAirCondition:AirConditionBase,IAirPollutants
public sealed class QAirCondition:AirConditionBase,IAirPollutants
{
public string Link{ get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions FluentWeather.QWeatherProvider/Models/QTyphoon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

namespace FluentWeather.QWeatherProvider.Models
{
public class QTyphoon:TyphoonBase
public sealed class QTyphoon:TyphoonBase
{
}
public class QTyphoonTrack : TyphoonTrackBase, IWindRadius
public sealed class QTyphoonTrack : TyphoonTrackBase, IWindRadius
{
public WindRadius WindRadius7 { get ; set ; }
public WindRadius WindRadius10 { get ; set ; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using FluentWeather.QWeatherProvider.Helpers;

namespace FluentWeather.QWeatherProvider.Models;
public class QWeatherDailyForecast : WeatherDailyBase
public sealed class QWeatherDailyForecast : WeatherDailyBase
{
public override WeatherCode WeatherType => WeatherTypeConverter.GetWeatherTypeByDescription(Description);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace FluentWeather.QWeatherProvider.Models;

public class QWeatherHourlyForecast :WeatherHourlyBase, ICloudAmount
public sealed class QWeatherHourlyForecast :WeatherHourlyBase, ICloudAmount
{
public override WeatherCode WeatherType => WeatherTypeConverter.GetWeatherTypeByDescription(Description);
public int? CloudAmount { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion FluentWeather.QWeatherProvider/Models/QWeatherIndices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace FluentWeather.QWeatherProvider.Models;

public class QWeatherIndices : IndicesBase
public sealed class QWeatherIndices : IndicesBase
{
public DateTime Date { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion FluentWeather.QWeatherProvider/Models/QWeatherNight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FluentWeather.QWeatherProvider.Models;

public class QWeatherNight : WeatherBase, IWind
public sealed class QWeatherNight : WeatherBase, IWind
{
public override WeatherCode WeatherType => WeatherTypeConverter.GetWeatherTypeByDescription(Description);
public string WindDirectionDescription { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion FluentWeather.QWeatherProvider/Models/QWeatherNow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FluentWeather.QWeatherProvider.Models;

public class QWeatherNow : WeatherNowBase
public sealed class QWeatherNow : WeatherNowBase
{
public override WeatherCode WeatherType => WeatherTypeConverter.GetWeatherTypeByDescription(Description);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

namespace FluentWeather.QWeatherProvider.Models
{
public class QWeatherPrecipitation : PrecipitationBase
public sealed class QWeatherPrecipitation : PrecipitationBase
{
}

public class QWeatherPrecipitationItem:PrecipitationItemBase
public sealed class QWeatherPrecipitationItem:PrecipitationItemBase
{
}
}
2 changes: 1 addition & 1 deletion FluentWeather.QWeatherProvider/Models/QWeatherWarning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace FluentWeather.QWeatherProvider.Models;

public class QWeatherWarning:WeatherWarningBase
public sealed class QWeatherWarning:WeatherWarningBase
{

}
Loading

0 comments on commit 4a7572f

Please sign in to comment.