Merge origin/dev-v7-deploy into dev-v8-zbwip (builds)
This commit is contained in:
@@ -678,31 +678,12 @@ namespace Umbraco.Core
|
||||
return s.LastIndexOf(value, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the string is a Guid
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <param name="withHyphens"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Use Guid.TryParse instead")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static bool IsGuid(this string str, bool withHyphens)
|
||||
{
|
||||
var isGuid = false;
|
||||
|
||||
if (!String.IsNullOrEmpty(str))
|
||||
{
|
||||
Regex guidRegEx;
|
||||
if (withHyphens)
|
||||
{
|
||||
guidRegEx = new Regex(@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$");
|
||||
}
|
||||
else
|
||||
{
|
||||
guidRegEx = new Regex(@"^(\{{0,1}([0-9a-fA-F]){8}([0-9a-fA-F]){4}([0-9a-fA-F]){4}([0-9a-fA-F]){4}([0-9a-fA-F]){12}\}{0,1})$");
|
||||
}
|
||||
isGuid = guidRegEx.IsMatch(str);
|
||||
}
|
||||
|
||||
return isGuid;
|
||||
Guid g;
|
||||
return Guid.TryParse(str, out g);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -724,7 +705,7 @@ namespace Umbraco.Core
|
||||
/// <returns></returns>
|
||||
public static object ParseInto(this string val, Type type)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(val))
|
||||
if (string.IsNullOrEmpty(val) == false)
|
||||
{
|
||||
TypeConverter tc = TypeDescriptor.GetConverter(type);
|
||||
return tc.ConvertFrom(val);
|
||||
@@ -762,6 +743,36 @@ namespace Umbraco.Core
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the string to SHA1
|
||||
/// </summary>
|
||||
/// <param name="stringToConvert">referrs to itself</param>
|
||||
/// <returns>the md5 hashed string</returns>
|
||||
public static string ToSHA1(this string stringToConvert)
|
||||
{
|
||||
//create an instance of the SHA1CryptoServiceProvider
|
||||
var md5Provider = new SHA1CryptoServiceProvider();
|
||||
|
||||
//convert our string into byte array
|
||||
var byteArray = Encoding.UTF8.GetBytes(stringToConvert);
|
||||
|
||||
//get the hashed values created by our SHA1CryptoServiceProvider
|
||||
var hashedByteArray = md5Provider.ComputeHash(byteArray);
|
||||
|
||||
//create a StringBuilder object
|
||||
var stringBuilder = new StringBuilder();
|
||||
|
||||
//loop to each each byte
|
||||
foreach (var b in hashedByteArray)
|
||||
{
|
||||
//append it to our StringBuilder
|
||||
stringBuilder.Append(b.ToString("x2").ToLower());
|
||||
}
|
||||
|
||||
//return the hashed value
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Decodes a string that was encoded with UrlTokenEncode
|
||||
|
||||
Reference in New Issue
Block a user