This commit is contained in:
2025-04-30 09:51:36 +08:00
parent 561881c9aa
commit 09afa239a6
848 changed files with 385870 additions and 205 deletions

View File

@@ -0,0 +1,39 @@

namespace Yes.Domain.Core.Extensions
{
public static class NameValueCollectionExtensions
{
public static int QueryInt(this NameValueCollection collection, string key, int defaultValue = 0)
{
key = key.ToUpper();
var value = collection.QueryString(key);
if (string.IsNullOrEmpty(value))
{
return defaultValue;
}
if (int.TryParse(value, out int result))
{
return result;
}
return defaultValue;
}
public static string QueryString(this NameValueCollection collection, string key)
{
key = key.ToUpper();
if (collection.AllKeys.Contains(key))
{
try
{
return collection[key]?.ToString() ?? "";
}
catch
{
return "";
}
}
return "";
}
}
}