Changed Is404 on DocumentRequest to internal as only the DocumentRequestBuilder should set this, removed the Is404 being set in the
DefaultLastChanceLookup as lookups shouldn't set the 404. Cleaned up ObjectExtensions TryConvertValue method. Ensures that the routes are created before the CoreBootManager complete is called.
This commit is contained in:
@@ -99,11 +99,16 @@ namespace Umbraco.Core
|
||||
}
|
||||
|
||||
var inputConverter = TypeDescriptor.GetConverter(input);
|
||||
if (inputConverter != null)
|
||||
if (inputConverter.CanConvertTo(destinationType))
|
||||
{
|
||||
if (inputConverter.CanConvertTo(destinationType))
|
||||
try
|
||||
{
|
||||
return new Attempt<object>(true, inputConverter.ConvertTo(input, destinationType));
|
||||
var converted = inputConverter.ConvertTo(input, destinationType);
|
||||
return new Attempt<object>(true, converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,19 +116,10 @@ namespace Umbraco.Core
|
||||
{
|
||||
var boolConverter = new CustomBooleanTypeConverter();
|
||||
if (boolConverter.CanConvertFrom(input.GetType()))
|
||||
{
|
||||
return new Attempt<object>(true, boolConverter.ConvertFrom(input));
|
||||
}
|
||||
}
|
||||
|
||||
var outputConverter = TypeDescriptor.GetConverter(destinationType);
|
||||
if (outputConverter != null)
|
||||
{
|
||||
if (outputConverter.CanConvertFrom(input.GetType()))
|
||||
{
|
||||
try
|
||||
{
|
||||
var converted = outputConverter.ConvertFrom(input);
|
||||
var converted = boolConverter.ConvertFrom(input);
|
||||
return new Attempt<object>(true, converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -133,17 +129,32 @@ namespace Umbraco.Core
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
var outputConverter = TypeDescriptor.GetConverter(destinationType);
|
||||
if (outputConverter.CanConvertFrom(input.GetType()))
|
||||
{
|
||||
if (TypeHelper.IsTypeAssignableFrom<IConvertible>(input))
|
||||
try
|
||||
{
|
||||
var converted = outputConverter.ConvertFrom(input);
|
||||
return new Attempt<object>(true, converted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (TypeHelper.IsTypeAssignableFrom<IConvertible>(input))
|
||||
{
|
||||
try
|
||||
{
|
||||
var casted = Convert.ChangeType(input, destinationType);
|
||||
return new Attempt<object>(true, casted);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
/* Swallow */
|
||||
catch (Exception e)
|
||||
{
|
||||
return new Attempt<object>(e);
|
||||
}
|
||||
}
|
||||
|
||||
return Attempt<object>.False;
|
||||
@@ -161,7 +172,7 @@ namespace Umbraco.Core
|
||||
// CamelCase,
|
||||
// CaseInsensitive
|
||||
//}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// Convert an object to a JSON string with camelCase formatting
|
||||
///// </summary>
|
||||
@@ -220,7 +231,7 @@ namespace Umbraco.Core
|
||||
|
||||
// return JObject.FromObject(obj, serializer).ToString(Formatting.None, dateTimeConverter);
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Converts an object into a dictionary
|
||||
/// </summary>
|
||||
@@ -231,7 +242,7 @@ namespace Umbraco.Core
|
||||
/// <param name="ignoreProperties"></param>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<string, TVal> ToDictionary<T, TProperty, TVal>(this T o,
|
||||
params Expression<Func<T, TProperty>>[] ignoreProperties)
|
||||
params Expression<Func<T, TProperty>>[] ignoreProperties)
|
||||
{
|
||||
return o.ToDictionary<TVal>(ignoreProperties.Select(e => o.GetPropertyInfo(e)).Select(propInfo => propInfo.Name).ToArray());
|
||||
}
|
||||
@@ -285,8 +296,8 @@ namespace Umbraco.Core
|
||||
var items = (from object enumItem in enumerable let value = GetEnumPropertyDebugString(enumItem, levels) where value != null select value).Take(10).ToList();
|
||||
|
||||
return items.Count() > 0
|
||||
? "{{ {0} }}".InvariantFormat(String.Join(", ", items))
|
||||
: null;
|
||||
? "{{ {0} }}".InvariantFormat(String.Join(", ", items))
|
||||
: null;
|
||||
}
|
||||
|
||||
var props = obj.GetType().GetProperties();
|
||||
@@ -312,8 +323,8 @@ namespace Umbraco.Core
|
||||
select "{0}={1}".InvariantFormat(propertyInfo.Name, value);
|
||||
|
||||
return items.Count() > 0
|
||||
? "[{0}]:{{ {1} }}".InvariantFormat(obj.GetType().Name, String.Join(", ", items))
|
||||
: null;
|
||||
? "[{0}]:{{ {1} }}".InvariantFormat(obj.GetType().Name, String.Join(", ", items))
|
||||
: null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Web
|
||||
// and it needs to be manually registered - which we want to avoid, in order
|
||||
// to be as unobtrusive as possible
|
||||
|
||||
public class LegacyScheduledTasks : IApplicationEventHandler
|
||||
public sealed class LegacyScheduledTasks : IApplicationEventHandler
|
||||
{
|
||||
Timer pingTimer;
|
||||
Timer publishingTimer;
|
||||
|
||||
@@ -84,12 +84,6 @@ namespace Umbraco.Web.Routing
|
||||
}
|
||||
}
|
||||
|
||||
//SD: We are setting the Is404 to true here because these are 404 handlers.
|
||||
// if people in the future add their own last chance lookup resolver, they might not want things to be 404s
|
||||
// and instead do their own thing so we should leave it up to the last chance resolver to set the 404, not the
|
||||
// module.
|
||||
docRequest.Is404 = true;
|
||||
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,6 @@ using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
|
||||
internal enum RenderingEngine
|
||||
{
|
||||
Mvc,
|
||||
WebForms
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// represents a request for one specified Umbraco document to be rendered
|
||||
/// by one specified template, using one particular culture.
|
||||
@@ -154,9 +147,9 @@ namespace Umbraco.Web.Routing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the requested document could not be found.
|
||||
/// Gets or sets a value indicating whether the requested document could not be found. This is set in the DocumentRequestBuilder.
|
||||
/// </summary>
|
||||
public bool Is404 { get; internal set; }
|
||||
internal bool Is404 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the document request triggers a redirect.
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace Umbraco.Web.Routing
|
||||
else
|
||||
{
|
||||
LogHelper.Debug<DocumentRequest>("{0}Look for template alias=\"{1}\" (altTemplate)", () => tracePrefix, () => templateAlias);
|
||||
//TODO: Need to figure out if this is web forms or MVC based on template name somehow!!
|
||||
|
||||
var template = Template.GetByAlias(templateAlias);
|
||||
_documentRequest.Template = template;
|
||||
}
|
||||
|
||||
8
src/Umbraco.Web/Routing/RenderingEngine.cs
Normal file
8
src/Umbraco.Web/Routing/RenderingEngine.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Web.Routing
|
||||
{
|
||||
internal enum RenderingEngine
|
||||
{
|
||||
Mvc,
|
||||
WebForms
|
||||
}
|
||||
}
|
||||
@@ -300,6 +300,7 @@
|
||||
<Compile Include="Routing\LookupByPageIdQuery.cs" />
|
||||
<Compile Include="Routing\NoTemplateHandler.cs" />
|
||||
<Compile Include="Mvc\SurfaceControllerResolver.cs" />
|
||||
<Compile Include="Routing\RenderingEngine.cs" />
|
||||
<Compile Include="umbraco.presentation\Default.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Umbraco.Web
|
||||
// pass off to our handlers (mvc or webforms)
|
||||
|
||||
// assign the legacy page back to the docrequest
|
||||
// handlers like default.aspx will want it
|
||||
// handlers like default.aspx will want it and most macros currently need it
|
||||
docreq.UmbracoPage = new page(docreq);
|
||||
|
||||
// these two are used by many legacy objects
|
||||
@@ -360,7 +360,7 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="currentQuery"></param>
|
||||
/// <param name="isMvc"> </param>
|
||||
/// <param name="engine"> </param>
|
||||
private void RewriteToUmbracoHandler(HttpContext context, string currentQuery, RenderingEngine engine)
|
||||
{
|
||||
|
||||
|
||||
@@ -99,11 +99,11 @@ namespace Umbraco.Web
|
||||
/// <returns></returns>
|
||||
public override IBootManager Complete(Action<ApplicationContext> afterComplete)
|
||||
{
|
||||
base.Complete(afterComplete);
|
||||
|
||||
//set routes
|
||||
CreateRoutes();
|
||||
|
||||
base.Complete(afterComplete);
|
||||
|
||||
//call OnApplicationStarting of each application events handler
|
||||
ApplicationEventsResolver.Current.ApplicationEventHandlers
|
||||
.ForEach(x => x.OnApplicationStarted(_umbracoApplication, ApplicationContext));
|
||||
|
||||
Reference in New Issue
Block a user