本文整理汇总了C#中System.Net.IPAddress.GetCountryCode方法的典型用法代码示例。如果您正苦于以下问题:C# IPAddress.GetCountryCode方法的具体用法?C# IPAddress.GetCountryCode怎么用?C# IPAddress.GetCountryCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.IPAddress
的用法示例。
在下文中一共展示了IPAddress.GetCountryCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Login
public Result<customer_account> Login(IDbConnection db, string userName, string pwd, IPAddress ip)
{
string userNameLC = userName.ToLower();
var loginInfo = db.Query<customer_login_password>("SELECT * FROM customer_login_password WHERE lower(username)[email protected] OR lower(email)[email protected] ", new { userName = userNameLC }).FirstOrDefault();
if (loginInfo == null || string.Compare(loginInfo.unhashed_password, pwd, StringComparison.OrdinalIgnoreCase) != 0)
{
return Result<customer_account>.Null(ErrorCodes.InvalidUserNameOrPassword);
}
var user = GetCustomerById(db, loginInfo.customer_account_id);
int id = user.Data.id;
// Change country code only IF the database has not store this value before //
if (string.IsNullOrEmpty(user.Data.country_code) || string.IsNullOrEmpty(user.Data.country_name))
{
ip.GetCountryCode(c => user.Data.country_code = c, n => user.Data.country_name = n);
}
// TODO: Update
user.Data.last_login_at = DateTime.UtcNow;
db.Execute("UPDATE customer_account SET [email protected]_login_at, [email protected]_code, [email protected]_name", user.Data);
return user;
}
示例2: getDownloadLinksForCurrentUser
public static JObject getDownloadLinksForCurrentUser(Game game, ApplicationUser currentUser, IPAddress ip)
{
var countryCode = String.Empty;
if (currentUser != null)
{
countryCode = currentUser.country_code;
}
else
{
string country_code = null;
string country_name = null;
if (ip.GetCountryCode(c => country_code = c, n => country_name = n))
{
countryCode = country_code;
}
}
var downloadLink = JObject.Parse(game.download_links);
var jsonLink = JObject.Parse(game.download_links);
if (Local.NO_GAME_STORES_COUNTRY_CODES.Contains(countryCode.ToLower()))
{
if (jsonLink["google"] != null)
{
downloadLink.Remove("google");
}
}
else
{
if (game.id != 21 && game.id != 24)
{
if (jsonLink["apk"] != null)
{
downloadLink.Remove("apk");
}
}
}
return downloadLink;
}