#17202: Fixing incorrect stylesheet import. Adding null condition checker to avoid null point exception.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2011-01-31 15:24:39 -08:00
parent c2e5fc7b28
commit 4f922640e7
8 changed files with 67 additions and 64 deletions

View File

@@ -93,6 +93,15 @@ namespace Orchard.Tests.Mvc {
Assert.That(((ReplacementFooController) controller).Disposals, Is.EqualTo(4));
}
[Test]
public void NullServiceKeyReturnsDefault() {
OrchardControllerFactoryAccessor orchardControllerFactory = new OrchardControllerFactoryAccessor();
ReplacementFooController fooController;
Assert.That(orchardControllerFactory.TryResolveAccessor(_workContextAccessor.GetContext(), null, out fooController), Is.False);
Assert.That(fooController, Is.Null);
}
private static RequestContext GetRequestContext(IWorkContextAccessor workContextAccessor)
{
var handler = new MvcRouteHandler();
@@ -120,6 +129,12 @@ namespace Orchard.Tests.Mvc {
public int Disposals { get; set; }
}
internal class OrchardControllerFactoryAccessor : OrchardControllerFactory {
public bool TryResolveAccessor<T>(WorkContext workContext, object serviceKey, out T instance) {
return TryResolve(workContext, serviceKey, out instance);
}
}
private static void InjectKnownControllerTypes(DefaultControllerFactory controllerFactory,
params Type[] controllerTypes) {
// D'oh!!! Hey MVC people, how is this testable? ;)
@@ -144,6 +159,4 @@ namespace Orchard.Tests.Mvc {
cache);
}
}
}

View File

@@ -120,11 +120,6 @@
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Styles\Web.config">
<SubType>Designer</SubType>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<!-- iis6 - for any request in this location, return via managed static file handler -->
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>

View File

@@ -46,4 +46,4 @@
.screenshotThumbnail .thumbnail {
width: 171px;
height: 128px;
}
}

View File

@@ -1,6 +1,5 @@
@model Orchard.Packaging.ViewModels.PackagingAddSourceViewModel
<h1>
@Html.TitleForPage(T("Add a Feed").ToString())</h1>
<h1>@Html.TitleForPage(T("Add a Feed").ToString())</h1>
@using ( Html.BeginFormAntiForgeryPost(Url.Action("AddSource")) ) {
@Html.ValidationSummary()

View File

@@ -1,31 +1,30 @@
@model Orchard.Packaging.ViewModels.PackagingSourcesViewModel
<h1>
@Html.TitleForPage(T("Gallery Feeds").ToString())</h1>
<h1>@Html.TitleForPage(T("Gallery Feeds").ToString())</h1>
<div class="manage">
@Html.ActionLink(T("Add Feed").Text, "AddSource", new { }, new { @class = "button primaryAction" })
</div>
<fieldset>
<table class="items" summary="@T("This is a table of the gallery feeds in your application")">
<colgroup>
<col id="Col1" />
<col id="Col2" />
<col id="Col3" />
</colgroup>
<thead>
<tr>
<th scope="col">@T("Title")</th>
<th scope="col">@T("Url")</th>
<th scope="col"></th>
</tr>
</thead>
@foreach ( var item in Model.Sources ) {
<fieldset>
<table class="items" summary="@T("This is a table of the gallery feeds in your application")">
<colgroup>
<col id="Col1" />
<col id="Col2" />
<col id="Col3" />
</colgroup>
<thead>
<tr>
<td>@item.FeedTitle</td>
<td>@Html.Link(item.FeedUrl, item.FeedUrl)</td>
<td>@Html.ActionLink(T("Remove").ToString(), "Remove", new { id = item.Id })</td>
<th scope="col">@T("Title")</th>
<th scope="col">@T("Url")</th>
<th scope="col"></th>
</tr>
}
</table>
</fieldset>
</thead>
@foreach ( var item in Model.Sources ) {
<tr>
<td>@item.FeedTitle</td>
<td>@Html.Link(item.FeedUrl, item.FeedUrl)</td>
<td>@Html.ActionLink(T("Remove").ToString(), "Remove", new { id = item.Id })</td>
</tr>
}
</table>
</fieldset>

View File

@@ -10,8 +10,8 @@
Script.Require("jQuery");
Script.Require("ShapesBase");
Script.Include("admin.js");
RegisterLink(new LinkEntry { Condition = "lte IE 8", Rel = "stylesheet", Type = "text/css", Href = Url.Content("../Styles/ie.css") }.AddAttribute("media", "screen, projection"));
RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type = "text/css", Href = Url.Content("../Styles/ie6.css") }.AddAttribute("media", "screen, projection"));
RegisterLink(new LinkEntry { Condition = "lte IE 8", Rel = "stylesheet", Type = "text/css", Href = Url.Content("~/Themes/TheAdmin/Styles/ie.css") }.AddAttribute("media", "screen, projection"));
RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type = "text/css", Href = Url.Content("~/Themes/TheAdmin/Styles/ie6.css") }.AddAttribute("media", "screen, projection"));
// these are just hacked together to fire existing partials... can change
Model.Header.Add(Display.Header());

View File

@@ -7,14 +7,20 @@ using Autofac.Features.Metadata;
using Orchard.Mvc.Extensions;
namespace Orchard.Mvc {
public interface IControllerType {
Type ControllerType { get; }
}
/// <summary>
/// Overrides the default controller factory to resolve controllers using LoC, based their areas and names.
/// </summary>
public class OrchardControllerFactory : DefaultControllerFactory {
bool TryResolve<T>(WorkContext workContext, object serviceKey, out T instance ) {
if (workContext != null) {
/// <summary>
/// Tries to resolve an instance for the controller associated with a given service key for the work context scope.
/// </summary>
/// <typeparam name="T">The type of the controller.</typeparam>
/// <param name="workContext">The work context.</param>
/// <param name="serviceKey">The service key for the controller.</param>
/// <param name="instance">The controller instance.</param>
/// <returns>True if the controller was resolved; false otherwise.</returns>
protected bool TryResolve<T>(WorkContext workContext, object serviceKey, out T instance) {
if (workContext != null && serviceKey != null) {
var key = new KeyedService(serviceKey, typeof (T));
object value;
if (workContext.Resolve<ILifetimeScope>().TryResolve(key, out value)) {
@@ -27,6 +33,13 @@ namespace Orchard.Mvc {
return false;
}
/// <summary>
/// Returns the controller type based on the name of both the controller and area.
/// </summary>
/// <param name="requestContext">The request context from where to fetch the route data containing the area.</param>
/// <param name="controllerName">The controller name.</param>
/// <returns>The controller type.</returns>
/// <example>ControllerName: Item, Area: Containers would return the type for the ItemController class.</example>
protected override Type GetControllerType(RequestContext requestContext, string controllerName) {
var routeData = requestContext.RouteData;
@@ -47,6 +60,12 @@ namespace Orchard.Mvc {
return null;
}
/// <summary>
/// Returns an instance of the controller.
/// </summary>
/// <param name="requestContext">The request context from where to fetch the route data containing the area.</param>
/// <param name="controllerType">The controller type.</param>
/// <returns>An instance of the controller if it's type is registered; null if otherwise.</returns>
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) {
IController controller;
var workContext = requestContext.GetWorkContext();
@@ -57,6 +76,5 @@ namespace Orchard.Mvc {
// fail as appropriate for MVC's expectations
return null;
}
}
}