Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General cleanup. #87

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions src/SteamWebAPI2/AutoMapperConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ internal static class AutoMapperConfiguration
{
private static bool isInitialized = false;
private static MapperConfiguration config;
private static IMapper mapper;

public static IMapper Mapper { get { return mapper; } }
public static IMapper Mapper { get; private set; }

private static SteamWebResponse<TDestination> ConstructSteamWebResponse<TSource, TDestination>(ISteamWebResponse<TSource> response)
{
Expand Down Expand Up @@ -180,7 +178,7 @@ public static void Initialize()

x.CreateMap<PrizePoolResultContainer, uint>().ConvertUsing(src => src.Result != null ? src.Result.PrizePool : default(uint));

#endregion
#endregion Endpoint: DOTA2Econ

#region Endpoint: DOTA2Fantasy

Expand All @@ -193,7 +191,7 @@ public static void Initialize()
x.CreateMap<ProPlayerLeaderboard, ProPlayerLeaderboardModel>();
x.CreateMap<ProPlayerListResult, ProPlayerDetailModel>();

#endregion
#endregion Endpoint: DOTA2Fantasy

#region Endpoint: DOTA2Match

Expand Down Expand Up @@ -253,7 +251,7 @@ public static void Initialize()
src => Mapper.Map<IList<TeamInfo>, IReadOnlyCollection<TeamInfoModel>>(src.Result != null ? src.Result.Teams : null)
);

#endregion
#endregion Endpoint: DOTA2Match

#region Endpoint: EconService

Expand Down Expand Up @@ -284,7 +282,7 @@ public static void Initialize()
src => Mapper.Map<TradeOffersResult, TradeOffersResultModel>(src.Result)
);

#endregion
#endregion Endpoint: EconService

#region Endpoint: GCVersion

Expand All @@ -293,7 +291,7 @@ public static void Initialize()
src => Mapper.Map<GameClientResult, GameClientResultModel>(src.Result)
);

#endregion
#endregion Endpoint: GCVersion

#region Endpoint: PlayerService

Expand Down Expand Up @@ -347,7 +345,7 @@ public static void Initialize()
src => Mapper.Map<RecentlyPlayedGameResult, RecentlyPlayedGamesResultModel>(src.Result)
);

#endregion
#endregion Endpoint: PlayerService

#region Endpoint: SteamApps

Expand All @@ -361,7 +359,7 @@ public static void Initialize()
src => Mapper.Map<SteamAppUpToDateCheckResult, SteamAppUpToDateCheckModel>(src.Result)
);

#endregion
#endregion Endpoint: SteamApps

#region Endpoint: SteamNews

Expand All @@ -371,7 +369,7 @@ public static void Initialize()
src => Mapper.Map<SteamNewsResult, SteamNewsResultModel>(src.Result)
);

#endregion
#endregion Endpoint: SteamNews

#region Endpoint: SteamRemoteStorage

Expand Down Expand Up @@ -399,7 +397,7 @@ public static void Initialize()
src => Mapper.Map<UGCFileDetails, UGCFileDetailsModel>(src.Result)
);

#endregion
#endregion Endpoint: SteamRemoteStorage

#region Endpoint: SteamUser

Expand Down Expand Up @@ -429,7 +427,7 @@ public static void Initialize()

x.CreateMap<ResolveVanityUrlResultContainer, ulong>().ConvertUsing(src => src.Result != null ? src.Result.SteamId : default(ulong));

#endregion
#endregion Endpoint: SteamUser

#region Endpoint: SteamUserStats

Expand Down Expand Up @@ -465,7 +463,7 @@ public static void Initialize()
src => Mapper.Map<UserStatsForGameResult, UserStatsForGameResultModel>(src.Result)
);

#endregion
#endregion Endpoint: SteamUserStats

#region Endpoint: SteamWebAPIUtil

Expand All @@ -478,7 +476,7 @@ public static void Initialize()
src => Mapper.Map<IList<SteamInterface>, IReadOnlyCollection<SteamInterfaceModel>>(src.Result != null ? src.Result.Interfaces : null)
);

#endregion
#endregion Endpoint: SteamWebAPIUtil

#region Endpoint: TFItems

Expand All @@ -487,7 +485,7 @@ public static void Initialize()
src => Mapper.Map<IList<GoldenWrench>, IReadOnlyCollection<GoldenWrenchModel>>(src.Result != null ? src.Result.GoldenWrenches : null)
);

#endregion
#endregion Endpoint: TFItems

#region Endpoint: SteamEconomy

Expand All @@ -513,7 +511,7 @@ public static void Initialize()
src => Mapper.Map<AssetPriceResult, AssetPriceResultModel>(src.Result)
);

#endregion
#endregion Endpoint: SteamEconomy

x.CreateMap<SchemaUrlResultContainer, string>().ConvertUsing(src => src.Result != null ? src.Result.ItemsGameUrl : null);

Expand Down Expand Up @@ -592,7 +590,7 @@ public static void Initialize()
x.CreateMap<FeaturedWin, StoreFeaturedWinModel>();
x.CreateMap<LargeCapsule, StoreLargeCapsuleModel>();

#endregion
#endregion Endpoint: SteamStore

x.CreateMap<ProfileInGameInfo, InGameInfoModel>()
.ForMember(dest => dest.GameIcon, opts => opts.MapFrom(source => source.GameIcon))
Expand All @@ -607,7 +605,7 @@ public static void Initialize()
.ForMember(dest => dest.Logo, opts => opts.MapFrom(source => new Uri(source.GameLogo)))
.ForMember(dest => dest.LogoSmall, opts => opts.MapFrom(source => new Uri(source.GameLogoSmall)))
.ForMember(dest => dest.Name, opts => opts.MapFrom(source => source.GameName))
.ForMember(dest => dest.HoursOnRecord, opts => opts.MapFrom(source => !String.IsNullOrEmpty(source.HoursOnRecord) ? double.Parse(source.HoursOnRecord) : 0d))
.ForMember(dest => dest.HoursOnRecord, opts => opts.MapFrom(source => !string.IsNullOrEmpty(source.HoursOnRecord) ? double.Parse(source.HoursOnRecord) : 0d))
.ForMember(dest => dest.HoursPlayed, opts => opts.MapFrom(source => (double)source.HoursPlayed))
.ForMember(dest => dest.StatsName, opts => opts.MapFrom(source => source.StatsName));

Expand All @@ -625,20 +623,19 @@ public static void Initialize()
.ForMember(dest => dest.State, opts => opts.MapFrom(source => source.OnlineState))
.ForMember(dest => dest.StateMessage, opts => opts.MapFrom(source => source.StateMessage))
.ForMember(dest => dest.SteamID, opts => opts.MapFrom(source => source.SteamID64))
.ForMember(dest => dest.SteamRating, opts => opts.MapFrom(source => !String.IsNullOrEmpty(source.SteamRating) ? double.Parse(source.SteamRating) : 0d))
.ForMember(dest => dest.SteamRating, opts => opts.MapFrom(source => !string.IsNullOrEmpty(source.SteamRating) ? double.Parse(source.SteamRating) : 0d))
.ForMember(dest => dest.Summary, opts => opts.MapFrom(source => source.Summary))
.ForMember(dest => dest.TradeBanState, opts => opts.MapFrom(source => source.TradeBanState))
.ForMember(dest => dest.IsVacBanned, opts => opts.MapFrom(source => source.VacBanned == 1 ? true : false))
.ForMember(dest => dest.VisibilityState, opts => opts.MapFrom(source => source.VisibilityState))
.ForMember(dest => dest.InGameServerIP, opts => opts.MapFrom(source => source.InGameServerIP))
.ForMember(dest => dest.InGameInfo, opts => opts.MapFrom(source => source.InGameInfo));
});

}

if (mapper == null)
if (Mapper == null)
{
mapper = config.CreateMapper();
Mapper = config.CreateMapper();
}

isInitialized = true;
Expand All @@ -651,7 +648,7 @@ public static void Initialize()
public static void Reset()
{
config = null;
mapper = null;
Mapper = null;
}
}
}
}
3 changes: 1 addition & 2 deletions src/SteamWebAPI2/Interfaces/DOTA2Econ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using SteamWebAPI2.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SteamWebAPI2.Interfaces
Expand Down Expand Up @@ -74,7 +73,7 @@ public async Task<ISteamWebResponse<IReadOnlyCollection<HeroModel>>> GetHeroesAs
/// <returns></returns>
public async Task<ISteamWebResponse<string>> GetItemIconPathAsync(string iconName, string iconType = "")
{
if (String.IsNullOrEmpty(iconName))
if (string.IsNullOrEmpty(iconName))
{
throw new ArgumentNullException("iconName");
}
Expand Down
2 changes: 0 additions & 2 deletions src/SteamWebAPI2/Interfaces/DOTA2Match.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using SteamWebAPI2.Models.DOTA2;
using SteamWebAPI2.Utilities;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;

namespace SteamWebAPI2.Interfaces
Expand Down
16 changes: 8 additions & 8 deletions src/SteamWebAPI2/Interfaces/EconItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public async Task<ISteamWebResponse<EconItemResultModel>> GetPlayerItemsAsync(ul
/// <returns></returns>
public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us")
{
if (this.appId != (int)EconItemsAppId.TeamFortress2)
if (appId != (int)EconItemsAppId.TeamFortress2)
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId));
}

List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
Expand All @@ -106,16 +106,16 @@ public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsF
return steamWebResponse;
}

/// <summary>
/// <summary>
/// Returns the schema overview for TF2 specifically.
/// </summary>
/// <param name="language"></param>
/// <returns></returns>
public async Task<ISteamWebResponse<SchemaOverviewResultContainer>> GetSchemaOverviewForTF2Async(string language = "en_us")
{
if (this.appId != (int)EconItemsAppId.TeamFortress2)
if (appId != (int)EconItemsAppId.TeamFortress2)
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId));
}

List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
Expand All @@ -135,7 +135,7 @@ public async Task<ISteamWebResponse<string>> GetSchemaUrlAsync()
{
if (!validSchemaUrlAppIds.Contains(appId))
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaUrl method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaUrl method.", appId));
}

var steamWebResponse = await steamWebInterface.GetAsync<SchemaUrlResultContainer>("GetSchemaURL", 1);
Expand All @@ -154,7 +154,7 @@ public async Task<ISteamWebResponse<StoreMetaDataModel>> GetStoreMetaDataAsync(s
{
if (!validStoreMetaDataAppIds.Contains(appId))
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetStoreMetaData method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetStoreMetaData method.", appId));
}

List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
Expand All @@ -176,7 +176,7 @@ public async Task<ISteamWebResponse<uint>> GetStoreStatusAsync()
{
if (!validStoreStatusAppIds.Contains(appId))
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetStoreStatus method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetStoreStatus method.", appId));
}

var steamWebResponse = await steamWebInterface.GetAsync<StoreStatusResultContainer>("GetStoreStatus", 1);
Expand Down
6 changes: 3 additions & 3 deletions src/SteamWebAPI2/Interfaces/EconService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public EconService(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWeb
var steamWebResponse = await steamWebInterface.GetAsync<TradeHistoryResultContainer>("GetTradeHistory", 1, parameters);

var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map<
ISteamWebResponse<TradeHistoryResultContainer>,
ISteamWebResponse<TradeHistoryResultContainer>,
ISteamWebResponse<Steam.Models.SteamEconomy.TradeHistoryModel>>(steamWebResponse);

return steamWebResponseModel;
Expand Down Expand Up @@ -83,7 +83,7 @@ public EconService(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWeb
var steamWebResponse = await steamWebInterface.GetAsync<TradeOffersResultContainer>("GetTradeOffers", 1, parameters);

var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map<
ISteamWebResponse<TradeOffersResultContainer>,
ISteamWebResponse<TradeOffersResultContainer>,
ISteamWebResponse<Steam.Models.SteamEconomy.TradeOffersResultModel>>(steamWebResponse);

return steamWebResponseModel;
Expand All @@ -105,7 +105,7 @@ public EconService(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWeb
var steamWebResponse = await steamWebInterface.GetAsync<TradeOfferResultContainer>("GetTradeOffer", 1, parameters);

var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map<
ISteamWebResponse<TradeOfferResultContainer>,
ISteamWebResponse<TradeOfferResultContainer>,
ISteamWebResponse<Steam.Models.SteamEconomy.TradeOfferResultModel>>(steamWebResponse);

return steamWebResponseModel;
Expand Down
4 changes: 2 additions & 2 deletions src/SteamWebAPI2/Interfaces/GCVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<ISteamWebResponse<GameClientResultModel>> GetClientVersionAsyn
{
if (!validClientVersionAppIds.Contains(appId))
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetClientVersion method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetClientVersion method.", appId));
}

var steamWebResponse = await steamWebInterface.GetAsync<GameClientResultContainer>("GetClientVersion", 1);
Expand All @@ -77,7 +77,7 @@ public async Task<ISteamWebResponse<GameClientResultModel>> GetServerVersionAsyn
{
if (!validServerVersionAppIds.Contains(appId))
{
throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetServerVersion method.", appId));
throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetServerVersion method.", appId));
}

var steamWebResponse = await steamWebInterface.GetAsync<GameClientResultContainer>("GetServerVersion", 1);
Expand Down
7 changes: 3 additions & 4 deletions src/SteamWebAPI2/Interfaces/IEconItems.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Steam.Models.DOTA2;
using Steam.Models.GameEconomy;
using Steam.Models.GameEconomy;
using SteamWebAPI2.Utilities;
using System.Threading.Tasks;

Expand All @@ -10,7 +9,7 @@ public interface IEconItems
Task<ISteamWebResponse<EconItemResultModel>> GetPlayerItemsAsync(ulong steamId);

Task<ISteamWebResponse<SteamWebAPI2.Models.GameEconomy.SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us");

Task<ISteamWebResponse<SteamWebAPI2.Models.GameEconomy.SchemaOverviewResultContainer>> GetSchemaOverviewForTF2Async(string language = "en_us");

Task<ISteamWebResponse<string>> GetSchemaUrlAsync();
Expand All @@ -19,4 +18,4 @@ public interface IEconItems

Task<ISteamWebResponse<uint>> GetStoreStatusAsync();
}
}
}
3 changes: 1 addition & 2 deletions src/SteamWebAPI2/Interfaces/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using SteamWebAPI2.Models.SteamCommunity;
using SteamWebAPI2.Models.SteamPlayer;
using SteamWebAPI2.Utilities;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
Expand Down Expand Up @@ -173,7 +172,7 @@ public async Task<ISteamWebResponse<OwnedGamesResultModel>> GetOwnedGamesAsync(u
{
foreach (var ownedGame in steamWebResponse.Data.Result.OwnedGames)
{
if (!String.IsNullOrWhiteSpace(ownedGame.Name))
if (!string.IsNullOrWhiteSpace(ownedGame.Name))
{
ownedGame.Name = ownedGame.Name.Trim();
}
Expand Down
3 changes: 1 addition & 2 deletions src/SteamWebAPI2/Interfaces/SteamApps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using SteamWebAPI2.Models;
using SteamWebAPI2.Utilities;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;

namespace SteamWebAPI2.Interfaces
Expand Down Expand Up @@ -53,7 +52,7 @@ public async Task<ISteamWebResponse<SteamAppUpToDateCheckModel>> UpToDateCheckAs
var steamWebResponse = await steamWebInterface.GetAsync<SteamAppUpToDateCheckResultContainer>("UpToDateCheck", 1, parameters);

var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map<
ISteamWebResponse<SteamAppUpToDateCheckResultContainer>,
ISteamWebResponse<SteamAppUpToDateCheckResultContainer>,
ISteamWebResponse<SteamAppUpToDateCheckModel>>(steamWebResponse);

return steamWebResponseModel;
Expand Down
Loading