mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
shorted method names... some strangeness on build server?
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043671
This commit is contained in:
@@ -50,13 +50,13 @@ namespace Orchard.Tests.Models {
|
||||
|
||||
[Test]
|
||||
public void TestDriverCanAddDisplay() {
|
||||
var driver = new StubDriver();
|
||||
var driver = new StubPartDriver();
|
||||
_container.Build(x => x.Register(driver).As<IPartDriver>());
|
||||
|
||||
var contentHandler = _container.Resolve<IContentHandler>();
|
||||
|
||||
var item = new ContentItem();
|
||||
item.Weld(new StubPart());
|
||||
item.Weld(new StubPart { Foo = new[] { "a", "b", "c" } });
|
||||
|
||||
var ctx = new BuildDisplayModelContext(new ItemDisplayModel(item), null, null);
|
||||
Assert.That(ctx.DisplayModel.Displays.Count(), Is.EqualTo(0));
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.Tests.Models {
|
||||
|
||||
}
|
||||
|
||||
private class StubDriver : PartDriver<StubPart> {
|
||||
public class StubPartDriver : PartDriver<StubPart> {
|
||||
protected override string Prefix {
|
||||
get { return "Stub"; }
|
||||
}
|
||||
@@ -84,15 +84,16 @@ namespace Orchard.Tests.Models {
|
||||
protected override DriverResult Editor(StubPart part, string groupName, IUpdateModel updater) {
|
||||
var viewModel = new StubViewModel { Foo = string.Join(",", part.Foo) };
|
||||
updater.TryUpdateModel(viewModel, Prefix, null, null);
|
||||
part.Foo = viewModel.Foo.Split(new[] {','}).Select(x => x.Trim()).ToArray();
|
||||
part.Foo = viewModel.Foo.Split(new[] { ',' }).Select(x => x.Trim()).ToArray();
|
||||
return PartialView(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private class StubPart : ContentPart {
|
||||
public class StubPart : ContentPart {
|
||||
public string[] Foo { get; set; }
|
||||
}
|
||||
private class StubViewModel {
|
||||
|
||||
public class StubViewModel {
|
||||
[Required]
|
||||
public string Foo { get; set; }
|
||||
}
|
||||
|
@@ -17,28 +17,28 @@ namespace Orchard.Models {
|
||||
public abstract class PartDriver<TPart> : IPartDriver where TPart : class, IContent {
|
||||
DriverResult IPartDriver.BuildDisplayModel(BuildDisplayModelContext context) {
|
||||
var part = context.ContentItem.As<TPart>();
|
||||
return part == null ? null : BuildDisplayModel(part, context.GroupName, context.DisplayType);
|
||||
return part == null ? null : Display(part, context.GroupName, context.DisplayType);
|
||||
}
|
||||
|
||||
DriverResult IPartDriver.BuildEditorModel(BuildEditorModelContext context) {
|
||||
var part = context.ContentItem.As<TPart>();
|
||||
return part == null ? null : BuildEditorModel(part, context.GroupName);
|
||||
return part == null ? null : Editor(part, context.GroupName);
|
||||
}
|
||||
|
||||
DriverResult IPartDriver.UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
var part = context.ContentItem.As<TPart>();
|
||||
return part == null ? null : UpdateEditorModel(part, context.GroupName, context.Updater);
|
||||
return part == null ? null : Editor(part, context.GroupName, context.Updater);
|
||||
}
|
||||
|
||||
protected virtual DriverResult BuildDisplayModel(TPart part, string groupName, string displayType) {
|
||||
protected virtual DriverResult Display(TPart part, string groupName, string displayType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual DriverResult BuildEditorModel(TPart part, string groupName) {
|
||||
protected virtual DriverResult Editor(TPart part, string groupName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual DriverResult UpdateEditorModel(TPart part, string groupName, IUpdateModel updater) {
|
||||
protected virtual DriverResult Editor(TPart part, string groupName, IUpdateModel updater) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user