Skip to content

Commit

Permalink
removed now obsolete .NET 4.0 polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisWillDoIt committed Sep 26, 2016
1 parent 0248320 commit b0d0613
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 30 deletions.
6 changes: 3 additions & 3 deletions BlogEngine/BlogEngine.Core/Data/RolesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public RoleItem Add(Data.Models.RoleItem role)
{
throw new System.UnauthorizedAccessException();
}
else if (Utils.StringIsNullOrWhitespace(role.RoleName))
else if (String.IsNullOrWhiteSpace(role.RoleName))
{
throw new ApplicationException("Role name is required");
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public bool Remove(string id)
if (!Security.IsAuthorizedTo(Rights.DeleteRoles))
throw new System.UnauthorizedAccessException();

if (Utils.StringIsNullOrWhitespace(id))
if (String.IsNullOrWhiteSpace(id))
throw new ApplicationException("Role name is required");

try
Expand Down Expand Up @@ -234,7 +234,7 @@ public bool SaveRights(List<Data.Models.Group> rights, string id)
{
throw new System.UnauthorizedAccessException();
}
else if (Utils.StringIsNullOrWhitespace(id))
else if (String.IsNullOrWhiteSpace(id))
{
throw new ApplicationException("Invalid role name");
}
Expand Down
2 changes: 1 addition & 1 deletion BlogEngine/BlogEngine.Core/Data/UsersRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public bool Remove(string id){

static Profile GetProfile(string id)
{
if (!Utils.StringIsNullOrWhitespace(id))
if (!String.IsNullOrWhiteSpace(id))
{
var pf = AuthorProfile.GetProfile(id);
if (pf == null)
Expand Down
14 changes: 2 additions & 12 deletions BlogEngine/BlogEngine.Core/Helpers/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public static Dictionary<Uri, XmlDocument> FindSemanticDocuments(Uri url, string
public static CultureInfo GetDefaultCulture()
{
var settingsCulture = BlogSettings.Instance.Culture;
if (Utils.StringIsNullOrWhitespace(settingsCulture) ||
if (String.IsNullOrWhiteSpace(settingsCulture) ||
settingsCulture.Equals("Auto", StringComparison.OrdinalIgnoreCase))
{
return CultureInfo.InstalledUICulture;
Expand Down Expand Up @@ -1232,16 +1232,6 @@ public static bool SetConditionalGetHeaders(DateTime date)
return false;
}

/// <summary>
/// Returns whether a string is null, empty, or whitespace. Same implementation as in String.IsNullOrWhitespace in .Net 4.0
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool StringIsNullOrWhitespace(string value)
{
return ((value == null) || (value.Trim().Length == 0));
}

/// <summary>
/// Strips all HTML tags from the specified string.
/// </summary>
Expand All @@ -1253,7 +1243,7 @@ public static bool StringIsNullOrWhitespace(string value)
/// </returns>
public static string StripHtml(string html)
{
return Utils.StringIsNullOrWhitespace(html) ? string.Empty : RegexStripHtml.Replace(html, string.Empty).Trim();
return String.IsNullOrWhiteSpace(html) ? string.Empty : RegexStripHtml.Replace(html, string.Empty).Trim();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames
/// </param>
public override bool RoleExists(string roleName)
{
if (Utils.StringIsNullOrWhitespace(roleName))
if (String.IsNullOrWhiteSpace(roleName))
{
throw new ArgumentNullException("roleName");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public CustomIdentity(string username, bool isAuthenticated)
/// <param name="password">The user's password.</param>
public CustomIdentity(string username, string password)
{
if (Utils.StringIsNullOrWhitespace(username))
if (String.IsNullOrWhiteSpace(username))
throw new ArgumentNullException("username");

if (Utils.StringIsNullOrWhitespace(password))
if (String.IsNullOrWhiteSpace(password))
throw new ArgumentNullException("password");

if (!Membership.ValidateUser(username, password)) { return; }
Expand Down
4 changes: 2 additions & 2 deletions BlogEngine/BlogEngine.Core/Services/Security/Right.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public static void OnRoleDeleting(string roleName)
/// <returns></returns>
private static string PrepareRoleName(string roleName)
{
if (Utils.StringIsNullOrWhitespace(roleName))
if (String.IsNullOrWhiteSpace(roleName))
{
throw new ArgumentNullException("roleName");
}
Expand All @@ -373,7 +373,7 @@ public static IEnumerable<Right> GetAllRights()
/// <returns></returns>
public static Right GetRightByName(string rightName)
{
if (Utils.StringIsNullOrWhitespace(rightName))
if (String.IsNullOrWhiteSpace(rightName))
{
throw new ArgumentNullException("rightName");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
}
}

if (!Utils.StringIsNullOrWhitespace(node["rights"]))
if (!String.IsNullOrWhiteSpace(node["rights"]))
{
// By default, all specified Rights must exist.
// We allow this to be overridden via the "rightsAuthorizationCheck"
// attribute.

AuthorizationCheck authCheck = AuthorizationCheck.HasAll;
if (!Utils.StringIsNullOrWhitespace(node["rightsAuthorizationCheck"]))
if (!String.IsNullOrWhiteSpace(node["rightsAuthorizationCheck"]))
{
authCheck = Utils.ParseEnum<AuthorizationCheck>(node["rightsAuthorizationCheck"], AuthorizationCheck.HasAll);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private Guid GetGuid(string type, string value)

// Value might be a GUID, or it could be a simple integer.

if (!Utils.StringIsNullOrWhitespace(value) &&
if (!String.IsNullOrWhiteSpace(value) &&
value.Length == 36)
{
return new Guid(value);
Expand Down Expand Up @@ -160,7 +160,7 @@ private DateTime GetDate(XmlAttribute attr)
DateTime defaultDate = DateTime.Now;

DateTime dt = defaultDate;
if (!Utils.StringIsNullOrWhitespace(value))
if (!String.IsNullOrWhiteSpace(value))
{
if (!DateTime.TryParseExact(value, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
dt = defaultDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static void PostCommentAdded(object sender, EventArgs e)
// If moderation is on, send the email if the comment hasn't been moderated (so
// the blog owner can determine if the comment should be approved/rejected).
if (BlogSettings.Instance.EnableCommentsModeration &&
!Utils.StringIsNullOrWhitespace(comment.ModeratedBy))
!String.IsNullOrWhiteSpace(comment.ModeratedBy))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void SendEmails(IPublishable publishable)
{
foreach (var email in emails)
{
if (!Utils.StringIsNullOrWhitespace(email) && Utils.IsEmailValid(email))
if (!String.IsNullOrWhiteSpace(email) && Utils.IsEmailValid(email))
{
MailMessage message = CreateEmail(publishable);
message.To.Add(email);
Expand Down
2 changes: 1 addition & 1 deletion BlogEngine/BlogEngine.NET/post.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void OnInit(EventArgs e)
var requestId = Request.QueryString["id"];
Guid id;

if ((!Utils.StringIsNullOrWhitespace(requestId)) && requestId.TryParse(out id))
if ((!String.IsNullOrWhiteSpace(requestId)) && requestId.TryParse(out id))
{

Post post = Post.ApplicablePosts.Find(p => p.Id == id);
Expand Down
4 changes: 2 additions & 2 deletions BlogEngine/BlogEngine.NET/search.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override void OnLoad(EventArgs e)
rep.ItemDataBound += new RepeaterItemEventHandler(rep_ItemDataBound);

var term = Request.QueryString["q"];
if (!Utils.StringIsNullOrWhitespace(term))
if (!String.IsNullOrWhiteSpace(term))
{
bool includeComments = (Request.QueryString["comment"] == "true");

Expand Down Expand Up @@ -150,7 +150,7 @@ private void BindSearchResult(List<IPublishable> list)
int page = 1;

string queryStringPage = Request.QueryString["page"];
if (!Utils.StringIsNullOrWhitespace(queryStringPage))
if (!String.IsNullOrWhiteSpace(queryStringPage))
{
int.TryParse(queryStringPage, out page);

Expand Down

0 comments on commit b0d0613

Please sign in to comment.