merge branch '6.2.0' into '7.0.0'
This commit is contained in:
@@ -58,14 +58,14 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var converted = (T) input;
|
||||
return new Attempt<T>(true, converted);
|
||||
return Attempt<T>.Succeed(converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<T>(e);
|
||||
return Attempt<T>.Fail(e);
|
||||
}
|
||||
}
|
||||
return !result.Success ? Attempt<T>.False : new Attempt<T>(true, (T)result.Result);
|
||||
return !result.Success ? Attempt<T>.Fail() : Attempt<T>.Succeed((T)result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,15 +80,18 @@ namespace Umbraco.Core
|
||||
//if it is null and it is nullable, then return success with null
|
||||
if (input == null && destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof (Nullable<>))
|
||||
{
|
||||
return new Attempt<object>(true, null);
|
||||
return Attempt<object>.Succeed(null);
|
||||
}
|
||||
|
||||
//if its not nullable then return false
|
||||
if (input == null) return Attempt<object>.False;
|
||||
if (input == null) return Attempt<object>.Fail();
|
||||
|
||||
if (destinationType == typeof(object)) return new Attempt<object>(true, input);
|
||||
if (destinationType == typeof(object)) return Attempt.Succeed(input);
|
||||
|
||||
if (input.GetType() == destinationType) return new Attempt<object>(true, input);
|
||||
if (input.GetType() == destinationType) return Attempt.Succeed(input);
|
||||
|
||||
//check for string so that overloaders of ToString() can take advantage of the conversion.
|
||||
if (destinationType == typeof(string)) return Attempt<object>.Succeed(input.ToString());
|
||||
|
||||
if (!destinationType.IsGenericType || destinationType.GetGenericTypeDefinition() != typeof(Nullable<>))
|
||||
{
|
||||
@@ -101,11 +104,11 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var casted = Convert.ChangeType(input, destinationType);
|
||||
return new Attempt<object>(true, casted);
|
||||
return Attempt.Succeed(casted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
return Attempt<object>.Fail(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,11 +119,11 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var converted = inputConverter.ConvertTo(input, destinationType);
|
||||
return new Attempt<object>(true, converted);
|
||||
return Attempt.Succeed(converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
return Attempt<object>.Fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +135,11 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var converted = boolConverter.ConvertFrom(input);
|
||||
return new Attempt<object>(true, converted);
|
||||
return Attempt.Succeed(converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
return Attempt<object>.Fail(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,11 +150,11 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var converted = outputConverter.ConvertFrom(input);
|
||||
return new Attempt<object>(true, converted);
|
||||
return Attempt.Succeed(converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
return Attempt<object>.Fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,15 +164,15 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var casted = Convert.ChangeType(input, destinationType);
|
||||
return new Attempt<object>(true, casted);
|
||||
return Attempt.Succeed(casted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
return Attempt<object>.Fail(e);
|
||||
}
|
||||
}
|
||||
|
||||
return Attempt<object>.False;
|
||||
return Attempt<object>.Fail();
|
||||
}
|
||||
|
||||
internal static void CheckThrowObjectDisposed(this IDisposable disposable, bool isDisposed, string objectname)
|
||||
@@ -358,11 +361,11 @@ namespace Umbraco.Core
|
||||
try
|
||||
{
|
||||
var output = value.ToXmlString(type);
|
||||
return new Attempt<string>(true, output);
|
||||
return Attempt.Succeed(output);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
return new Attempt<string>(ex);
|
||||
return Attempt<string>.Fail(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user