Documenting the (object) cast to avoid dynamic invocation.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-11-19 17:42:30 -08:00
parent 1838c131c3
commit a987f02af6
12 changed files with 35 additions and 5 deletions

View File

@@ -67,6 +67,7 @@ namespace Orchard.Core.Containers.Controllers {
.Pager(pagerShape) .Pager(pagerShape)
.ShowPager(container.As<ContainerPart>().Record.Paginated); .ShowPager(container.As<ContainerPart>().Record.Paginated);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel); return View((object)viewModel);
} }
} }

View File

@@ -97,6 +97,7 @@ namespace Orchard.Core.Contents.Controllers {
.Options(model.Options) .Options(model.Options)
.TypeDisplayName(model.TypeDisplayName ?? ""); .TypeDisplayName(model.TypeDisplayName ?? "");
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel); return View((object)viewModel);
} }
@@ -176,6 +177,7 @@ namespace Orchard.Core.Contents.Controllers {
ActionResult CreatableTypeList() { ActionResult CreatableTypeList() {
dynamic viewModel = Shape.ViewModel(ContentTypes: GetCreatableTypes()); dynamic viewModel = Shape.ViewModel(ContentTypes: GetCreatableTypes());
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View("CreatableTypeList", (object)viewModel); return View("CreatableTypeList", (object)viewModel);
} }
@@ -189,6 +191,7 @@ namespace Orchard.Core.Contents.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
dynamic model = _contentManager.BuildEditor(contentItem); dynamic model = _contentManager.BuildEditor(contentItem);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -218,6 +221,7 @@ namespace Orchard.Core.Contents.Controllers {
dynamic model = _contentManager.UpdateEditor(contentItem, this); dynamic model = _contentManager.UpdateEditor(contentItem, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_transactionManager.Cancel(); _transactionManager.Cancel();
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -239,6 +243,7 @@ namespace Orchard.Core.Contents.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
dynamic model = _contentManager.BuildEditor(contentItem); dynamic model = _contentManager.BuildEditor(contentItem);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -269,6 +274,7 @@ namespace Orchard.Core.Contents.Controllers {
dynamic model = _contentManager.UpdateEditor(contentItem, this); dynamic model = _contentManager.UpdateEditor(contentItem, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_transactionManager.Cancel(); _transactionManager.Cancel();
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View("Edit", (object)model); return View("Edit", (object)model);
} }

View File

@@ -19,6 +19,7 @@ namespace Orchard.Core.Contents.Controllers {
public ActionResult Display(int id) { public ActionResult Display(int id) {
var contentItem = _contentManager.Get(id, VersionOptions.Published); var contentItem = _contentManager.Get(id, VersionOptions.Published);
dynamic model = _contentManager.BuildDisplay(contentItem); dynamic model = _contentManager.BuildDisplay(contentItem);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -31,6 +32,7 @@ namespace Orchard.Core.Contents.Controllers {
var contentItem = _contentManager.Get(id, versionOptions); var contentItem = _contentManager.Get(id, versionOptions);
dynamic model = _contentManager.BuildDisplay(contentItem); dynamic model = _contentManager.BuildDisplay(contentItem);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View("Display", (object)model); return View("Display", (object)model);
} }
} }

View File

@@ -49,6 +49,7 @@ namespace Orchard.Core.Routable.Controllers {
} }
dynamic model = _contentManager.BuildDisplay(hits.Single()); dynamic model = _contentManager.BuildDisplay(hits.Single());
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }

View File

@@ -35,7 +35,7 @@ namespace Orchard.Core.Settings.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
dynamic model = Services.ContentManager.BuildEditor(_siteService.GetSiteSettings()); dynamic model = Services.ContentManager.BuildEditor(_siteService.GetSiteSettings());
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -49,6 +49,7 @@ namespace Orchard.Core.Settings.Controllers {
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }

View File

@@ -55,6 +55,7 @@ namespace Orchard.Blogs.Controllers {
return HttpNotFound(); return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(blog); dynamic model = Services.ContentManager.BuildEditor(blog);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -70,6 +71,7 @@ namespace Orchard.Blogs.Controllers {
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
_transactionManager.Cancel(); _transactionManager.Cancel();
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -88,6 +90,7 @@ namespace Orchard.Blogs.Controllers {
return HttpNotFound(); return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(blog); dynamic model = Services.ContentManager.BuildEditor(blog);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -103,6 +106,7 @@ namespace Orchard.Blogs.Controllers {
dynamic model = Services.ContentManager.UpdateEditor(blog, this); dynamic model = Services.ContentManager.UpdateEditor(blog, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -140,7 +144,7 @@ namespace Orchard.Blogs.Controllers {
dynamic viewModel = Services.New.ViewModel() dynamic viewModel = Services.New.ViewModel()
.ContentItems(list); .ContentItems(list);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel); return View((object)viewModel);
} }
@@ -161,7 +165,8 @@ namespace Orchard.Blogs.Controllers {
var totalItemCount = _blogPostService.PostCount(blogPart, VersionOptions.Latest); var totalItemCount = _blogPostService.PostCount(blogPart, VersionOptions.Latest);
blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)blog); return View((object)blog);
} }

View File

@@ -46,6 +46,7 @@ namespace Orchard.Blogs.Controllers {
dynamic viewModel = Shape.ViewModel() dynamic viewModel = Shape.ViewModel()
.ContentItems(list); .ContentItems(list);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel); return View((object)viewModel);
} }
@@ -70,6 +71,7 @@ namespace Orchard.Blogs.Controllers {
var totalItemCount = _blogPostService.PostCount(blogPart); var totalItemCount = _blogPostService.PostCount(blogPart);
blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)blog); return View((object)blog);
} }
} }

View File

@@ -37,6 +37,7 @@ namespace Orchard.Blogs.Controllers {
return HttpNotFound(); return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(blogPost); dynamic model = Services.ContentManager.BuildEditor(blogPost);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -92,6 +93,7 @@ namespace Orchard.Blogs.Controllers {
return HttpNotFound(); return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(post); dynamic model = Services.ContentManager.BuildEditor(post);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }

View File

@@ -51,7 +51,7 @@ namespace Orchard.Blogs.Controllers {
return HttpNotFound(); return HttpNotFound();
dynamic model = _services.ContentManager.BuildDisplay(postPart); dynamic model = _services.ContentManager.BuildDisplay(postPart);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -77,6 +77,7 @@ namespace Orchard.Blogs.Controllers {
//todo: (heskew) add back //todo: (heskew) add back
//.ArchiveData(archive) <-- ?? //.ArchiveData(archive) <-- ??
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)viewModel); return View((object)viewModel);
} }
} }

View File

@@ -60,6 +60,7 @@ namespace Orchard.Users.Controllers {
dynamic model = Services.ContentManager.BuildEditor(user); dynamic model = Services.ContentManager.BuildEditor(user);
model.Content.Add(editor); model.Content.Add(editor);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -97,6 +98,7 @@ namespace Orchard.Users.Controllers {
editor.Metadata.Position = "2"; editor.Metadata.Position = "2";
model.Content.Add(editor); model.Content.Add(editor);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -114,6 +116,7 @@ namespace Orchard.Users.Controllers {
dynamic model = Services.ContentManager.BuildEditor(user); dynamic model = Services.ContentManager.BuildEditor(user);
model.Content.Add(editor); model.Content.Add(editor);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
@@ -144,6 +147,7 @@ namespace Orchard.Users.Controllers {
editor.Metadata.Position = "2"; editor.Metadata.Position = "2";
model.Content.Add(editor); model.Content.Add(editor);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }

View File

@@ -112,6 +112,7 @@ namespace Orchard.Widgets.Controllers {
widgetPart.LayerPart = _widgetsService.GetLayer(layerId); widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
dynamic model = Services.ContentManager.BuildEditor(widgetPart); dynamic model = Services.ContentManager.BuildEditor(widgetPart);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
catch (Exception exception) { catch (Exception exception) {
@@ -155,6 +156,7 @@ namespace Orchard.Widgets.Controllers {
return HttpNotFound(); return HttpNotFound();
dynamic model = Services.ContentManager.BuildEditor(layerPart); dynamic model = Services.ContentManager.BuildEditor(layerPart);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
catch (Exception exception) { catch (Exception exception) {
@@ -200,6 +202,7 @@ namespace Orchard.Widgets.Controllers {
} }
dynamic model = Services.ContentManager.BuildEditor(layerPart); dynamic model = Services.ContentManager.BuildEditor(layerPart);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
catch (Exception exception) { catch (Exception exception) {
@@ -265,6 +268,7 @@ namespace Orchard.Widgets.Controllers {
} }
dynamic model = Services.ContentManager.BuildEditor(widgetPart); dynamic model = Services.ContentManager.BuildEditor(widgetPart);
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
return View((object)model); return View((object)model);
} }
catch (Exception exception) { catch (Exception exception) {

View File

@@ -66,6 +66,7 @@ namespace Orchard.Environment {
} }
IEnumerable<object> IDependencyResolver.GetServices(Type serviceType) { IEnumerable<object> IDependencyResolver.GetServices(Type serviceType) {
return Resolve<IEnumerable>(typeof(IEnumerable<>).MakeGenericType(serviceType), Enumerable.Empty<object>()).Cast<object>(); return Resolve<IEnumerable>(typeof(IEnumerable<>).MakeGenericType(serviceType), Enumerable.Empty<object>()).Cast<object>();
}
} }
} }