mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Refining extension methods. Adding a streamlined content manager creation method.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041639
This commit is contained in:
@@ -4,7 +4,7 @@ using Orchard.Models;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class CommonPart : ContentPartForRecord<CommonRecord> {
|
||||
public class CommonPart : ContentPart<CommonRecord> {
|
||||
private readonly Lazy<IUser> _owner = new Lazy<IUser>();
|
||||
private readonly Lazy<IContent> _container = new Lazy<IContent>();
|
||||
|
||||
|
@@ -22,7 +22,7 @@ namespace Orchard.Core.Common.Models {
|
||||
_contentManager = contentManager;
|
||||
|
||||
AddOnCreating<CommonPart>(SetCreateTimesAndAuthor);
|
||||
Filters.Add(new StorageFilterForRecord<CommonRecord>(repository));
|
||||
Filters.Add(new StorageFilter<CommonRecord>(repository));
|
||||
AddOnLoaded<CommonPart>(LoadOwnerModel);
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,6 @@ using Orchard.Core.Common.Records;
|
||||
using Orchard.Models;
|
||||
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class RoutablePart : ContentPartForRecord<RoutableRecord> {
|
||||
public class RoutablePart : ContentPart<RoutableRecord> {
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ using Orchard.Models.Driver;
|
||||
namespace Orchard.Core.Common.Models {
|
||||
public class RoutablePartProvider : ContentProvider {
|
||||
public RoutablePartProvider(IRepository<RoutableRecord> repository) {
|
||||
Filters.Add(new StorageFilterForRecord<RoutableRecord>(repository));
|
||||
Filters.Add(new StorageFilter<RoutableRecord>(repository));
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ using Orchard.Models;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Settings.Models {
|
||||
public sealed class SiteSettings : ContentPartForRecord<SiteSettingsRecord>, ISite {
|
||||
public sealed class SiteSettings : ContentPart<SiteSettingsRecord>, ISite {
|
||||
public string SiteName {
|
||||
get { return Record.SiteName; }
|
||||
set { Record.SiteName = value; }
|
||||
|
@@ -6,7 +6,7 @@ namespace Orchard.Core.Settings.Models {
|
||||
public class SiteSettingsProvider : ContentProvider {
|
||||
public SiteSettingsProvider(IRepository<SiteSettingsRecord> repository){
|
||||
Filters.Add(new ActivatingFilter<SiteSettings>("site"));
|
||||
Filters.Add(new StorageFilterForRecord<SiteSettingsRecord>(repository));
|
||||
Filters.Add(new StorageFilter<SiteSettingsRecord>(repository));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,12 +25,12 @@ namespace Orchard.Core.Settings.Services {
|
||||
string applicationName = HttpContext.Current.Request.ApplicationPath;
|
||||
SiteSettingsRecord record = _siteSettingsRepository.Get(x => x.SiteUrl == applicationName);
|
||||
if (record == null) {
|
||||
SiteSettings site = _contentManager.New("site").As<SiteSettings>();
|
||||
site.Record.SiteUrl = applicationName;
|
||||
_contentManager.Create(site);
|
||||
ISite site = _contentManager.Create<SiteSettings>("site", item => {
|
||||
item.Record.SiteUrl = applicationName;
|
||||
});
|
||||
return site;
|
||||
}
|
||||
return _contentManager.Get(record.Id).As<ISite>();
|
||||
return _contentManager.Get<ISite>(record.Id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user