mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Refactoring
--HG-- branch : dev
This commit is contained in:
@@ -13,7 +13,6 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
private readonly IAuthenticationService _authenticationService;
|
private readonly IAuthenticationService _authenticationService;
|
||||||
private readonly IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
private readonly IMembershipService _membershipService;
|
private readonly IMembershipService _membershipService;
|
||||||
private readonly IClock _clock;
|
|
||||||
|
|
||||||
public CommonPartDriver(
|
public CommonPartDriver(
|
||||||
IOrchardServices services,
|
IOrchardServices services,
|
||||||
@@ -26,7 +25,6 @@ namespace Orchard.Core.Common.Drivers {
|
|||||||
_authenticationService = authenticationService;
|
_authenticationService = authenticationService;
|
||||||
_authorizationService = authorizationService;
|
_authorizationService = authorizationService;
|
||||||
_membershipService = membershipService;
|
_membershipService = membershipService;
|
||||||
_clock = clock;
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Services = services;
|
Services = services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,11 @@ namespace Orchard.Core.Settings.Drivers {
|
|||||||
private readonly ISiteService _siteService;
|
private readonly ISiteService _siteService;
|
||||||
private readonly ICultureManager _cultureManager;
|
private readonly ICultureManager _cultureManager;
|
||||||
private readonly IMembershipService _membershipService;
|
private readonly IMembershipService _membershipService;
|
||||||
private readonly INotifier _notifier;
|
|
||||||
|
|
||||||
public SiteSettingsPartDriver(ISiteService siteService, ICultureManager cultureManager, IMembershipService membershipService, INotifier notifier) {
|
public SiteSettingsPartDriver(ISiteService siteService, ICultureManager cultureManager, IMembershipService membershipService, INotifier notifier) {
|
||||||
_siteService = siteService;
|
_siteService = siteService;
|
||||||
_cultureManager = cultureManager;
|
_cultureManager = cultureManager;
|
||||||
_membershipService = membershipService;
|
_membershipService = membershipService;
|
||||||
_notifier = notifier;
|
|
||||||
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Lucene.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ISearchBuilder Parse(string defaultField, string query) {
|
public ISearchBuilder Parse(string defaultField, string query) {
|
||||||
return Parse(new string[] {defaultField}, query);
|
return Parse(new[] {defaultField}, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISearchBuilder Parse(string[] defaultFields, string query) {
|
public ISearchBuilder Parse(string[] defaultFields, string query) {
|
||||||
|
|||||||
@@ -106,18 +106,20 @@ namespace Orchard.Blogs.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ( var item in doc.Descendants("item") ) {
|
foreach ( var item in doc.Descendants("item") ) {
|
||||||
string postName = item.Element("title").Value;
|
if (item != null) {
|
||||||
|
string postName = item.Element("title").Value;
|
||||||
|
|
||||||
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
|
||||||
var post = _contentManager.New("BlogPost");
|
var post = _contentManager.New("BlogPost");
|
||||||
post.As<ICommonPart>().Owner = owner;
|
post.As<ICommonPart>().Owner = owner;
|
||||||
post.As<ICommonPart>().Container = blog;
|
post.As<ICommonPart>().Container = blog;
|
||||||
var slug = Slugify(postName);
|
var slug = Slugify(postName);
|
||||||
post.As<RoutePart>().Slug = slug;
|
post.As<RoutePart>().Slug = slug;
|
||||||
post.As<RoutePart>().Path = post.As<RoutePart>().GetPathWithSlug(slug);
|
post.As<RoutePart>().Path = post.As<RoutePart>().GetPathWithSlug(slug);
|
||||||
post.As<RoutePart>().Title = postName;
|
post.As<RoutePart>().Title = postName;
|
||||||
post.As<BodyPart>().Text = item.Element("description").Value;
|
post.As<BodyPart>().Text = item.Element("description").Value;
|
||||||
_contentManager.Create(post);
|
_contentManager.Create(post);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ namespace Orchard.ContentTypes.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
Services.TransactionManager.Cancel(); ;
|
Services.TransactionManager.Cancel();
|
||||||
return AddPartsTo(id);
|
return AddPartsTo(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Orchard.Indexing.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string _contentTypeName;
|
private string _contentTypeName;
|
||||||
private bool _tasksCreated = false;
|
private bool _tasksCreated;
|
||||||
|
|
||||||
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
|
public override IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition) {
|
||||||
var model = definition.Settings.GetModel<TypeIndexing>();
|
var model = definition.Settings.GetModel<TypeIndexing>();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Orchard.Packaging.Services {
|
|||||||
public virtual FrameworkName TargetFramework {
|
public virtual FrameworkName TargetFramework {
|
||||||
get {
|
get {
|
||||||
if (_targetFramework == null) {
|
if (_targetFramework == null) {
|
||||||
_targetFramework = new FrameworkName(NetFrameworkIdentifier, typeof(string).Assembly.GetNameSafe().Version);;
|
_targetFramework = new FrameworkName(NetFrameworkIdentifier, typeof(string).Assembly.GetNameSafe().Version);
|
||||||
}
|
}
|
||||||
return _targetFramework;
|
return _targetFramework;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ using System.Globalization;
|
|||||||
namespace Orchard.PublishLater.Drivers {
|
namespace Orchard.PublishLater.Drivers {
|
||||||
public class PublishLaterPartDriver : ContentPartDriver<PublishLaterPart> {
|
public class PublishLaterPartDriver : ContentPartDriver<PublishLaterPart> {
|
||||||
private const string TemplateName = "Parts/PublishLater";
|
private const string TemplateName = "Parts/PublishLater";
|
||||||
private readonly ICommonService _commonService;
|
|
||||||
private readonly IPublishLaterService _publishLaterService;
|
private readonly IPublishLaterService _publishLaterService;
|
||||||
private const string DatePattern = "M/d/yyyy";
|
private const string DatePattern = "M/d/yyyy";
|
||||||
private const string TimePattern = "h:mm tt";
|
private const string TimePattern = "h:mm tt";
|
||||||
@@ -20,7 +19,6 @@ namespace Orchard.PublishLater.Drivers {
|
|||||||
IOrchardServices services,
|
IOrchardServices services,
|
||||||
ICommonService commonService,
|
ICommonService commonService,
|
||||||
IPublishLaterService publishLaterService) {
|
IPublishLaterService publishLaterService) {
|
||||||
_commonService = commonService;
|
|
||||||
_publishLaterService = publishLaterService;
|
_publishLaterService = publishLaterService;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Services = services;
|
Services = services;
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ namespace Orchard.Tags.Services {
|
|||||||
var taggedContentItems = GetTaggedContentItems(tagRecord.Id);
|
var taggedContentItems = GetTaggedContentItems(tagRecord.Id);
|
||||||
|
|
||||||
foreach (var tagContentItem in tagsContentItems) {
|
foreach (var tagContentItem in tagsContentItems) {
|
||||||
if (!taggedContentItems.Any(c => c.ContentItem.Id == tagContentItem.TagsPartRecord.Id)) {
|
ContentTagRecord item = tagContentItem;
|
||||||
|
if (!taggedContentItems.Any(c => c.ContentItem.Id == item.TagsPartRecord.Id)) {
|
||||||
TagContentItem(tagContentItem.TagsPartRecord, tagName);
|
TagContentItem(tagContentItem.TagsPartRecord, tagName);
|
||||||
}
|
}
|
||||||
_contentTagRepository.Delete(tagContentItem);
|
_contentTagRepository.Delete(tagContentItem);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Orchard.Users.Services;
|
|||||||
|
|
||||||
namespace Orchard.Users.Commands {
|
namespace Orchard.Users.Commands {
|
||||||
public class UserCommands : DefaultOrchardCommandHandler {
|
public class UserCommands : DefaultOrchardCommandHandler {
|
||||||
private readonly IContentManager _contentManager;
|
|
||||||
private readonly IMembershipService _membershipService;
|
private readonly IMembershipService _membershipService;
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
|
|
||||||
@@ -13,7 +12,6 @@ namespace Orchard.Users.Commands {
|
|||||||
IContentManager contentManager,
|
IContentManager contentManager,
|
||||||
IMembershipService membershipService,
|
IMembershipService membershipService,
|
||||||
IUserService userService) {
|
IUserService userService) {
|
||||||
_contentManager = contentManager;
|
|
||||||
_membershipService = membershipService;
|
_membershipService = membershipService;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ namespace Orchard.Users.Services {
|
|||||||
private readonly IOrchardServices _orchardServices;
|
private readonly IOrchardServices _orchardServices;
|
||||||
private readonly IMessageManager _messageManager;
|
private readonly IMessageManager _messageManager;
|
||||||
private readonly IEnumerable<IUserEventHandler> _userEventHandlers;
|
private readonly IEnumerable<IUserEventHandler> _userEventHandlers;
|
||||||
private readonly IClock _clock;
|
|
||||||
|
|
||||||
public MembershipService(IOrchardServices orchardServices, IMessageManager messageManager, IEnumerable<IUserEventHandler> userEventHandlers, IClock clock) {
|
public MembershipService(IOrchardServices orchardServices, IMessageManager messageManager, IEnumerable<IUserEventHandler> userEventHandlers, IClock clock) {
|
||||||
_orchardServices = orchardServices;
|
_orchardServices = orchardServices;
|
||||||
_messageManager = messageManager;
|
_messageManager = messageManager;
|
||||||
_userEventHandlers = userEventHandlers;
|
_userEventHandlers = userEventHandlers;
|
||||||
_clock = clock;
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace Orchard.Users.Services {
|
|||||||
private readonly IMembershipService _membershipService;
|
private readonly IMembershipService _membershipService;
|
||||||
private readonly IClock _clock;
|
private readonly IClock _clock;
|
||||||
private readonly IMessageManager _messageManager;
|
private readonly IMessageManager _messageManager;
|
||||||
private readonly ShellSettings _shellSettings;
|
|
||||||
private readonly IEncryptionService _encryptionService;
|
private readonly IEncryptionService _encryptionService;
|
||||||
|
|
||||||
public UserService(IContentManager contentManager, IMembershipService membershipService, IClock clock, IMessageManager messageManager, ShellSettings shellSettings, IEncryptionService encryptionService) {
|
public UserService(IContentManager contentManager, IMembershipService membershipService, IClock clock, IMessageManager messageManager, ShellSettings shellSettings, IEncryptionService encryptionService) {
|
||||||
@@ -31,7 +30,6 @@ namespace Orchard.Users.Services {
|
|||||||
_membershipService = membershipService;
|
_membershipService = membershipService;
|
||||||
_clock = clock;
|
_clock = clock;
|
||||||
_messageManager = messageManager;
|
_messageManager = messageManager;
|
||||||
_shellSettings = shellSettings;
|
|
||||||
_encryptionService = encryptionService;
|
_encryptionService = encryptionService;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,14 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
public ShellDescriptor Fetch(string name) {
|
public ShellDescriptor Fetch(string name) {
|
||||||
VerifyCacheFile();
|
VerifyCacheFile();
|
||||||
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
|
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
|
||||||
XmlDocument xmlDocument = new XmlDocument();
|
var xmlDocument = new XmlDocument();
|
||||||
xmlDocument.LoadXml(text);
|
xmlDocument.LoadXml(text);
|
||||||
XmlNode rootNode = xmlDocument.DocumentElement;
|
XmlNode rootNode = xmlDocument.DocumentElement;
|
||||||
foreach (XmlNode tenantNode in rootNode.ChildNodes) {
|
if (rootNode != null) {
|
||||||
if (String.Equals(tenantNode.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
foreach (XmlNode tenantNode in rootNode.ChildNodes) {
|
||||||
return GetShellDecriptorForCacheText(tenantNode.InnerText);
|
if (String.Equals(tenantNode.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
return GetShellDecriptorForCacheText(tenantNode.InnerText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,20 +69,22 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
|
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
|
||||||
bool tenantCacheUpdated = false;
|
bool tenantCacheUpdated = false;
|
||||||
var saveWriter = new StringWriter();
|
var saveWriter = new StringWriter();
|
||||||
XmlDocument xmlDocument = new XmlDocument();
|
var xmlDocument = new XmlDocument();
|
||||||
xmlDocument.LoadXml(text);
|
xmlDocument.LoadXml(text);
|
||||||
XmlNode rootNode = xmlDocument.DocumentElement;
|
XmlNode rootNode = xmlDocument.DocumentElement;
|
||||||
foreach (XmlNode tenantNode in rootNode.ChildNodes) {
|
if (rootNode != null) {
|
||||||
if (String.Equals(tenantNode.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
foreach (XmlNode tenantNode in rootNode.ChildNodes) {
|
||||||
tenantNode.InnerText = GetCacheTextForShellDescriptor(descriptor);
|
if (String.Equals(tenantNode.Name, name, StringComparison.OrdinalIgnoreCase)) {
|
||||||
tenantCacheUpdated = true;
|
tenantNode.InnerText = GetCacheTextForShellDescriptor(descriptor);
|
||||||
break;
|
tenantCacheUpdated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tenantCacheUpdated) {
|
||||||
|
XmlElement newTenant = xmlDocument.CreateElement(name);
|
||||||
|
newTenant.InnerText = GetCacheTextForShellDescriptor(descriptor);
|
||||||
|
rootNode.AppendChild(newTenant);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!tenantCacheUpdated) {
|
|
||||||
XmlElement newTenant = xmlDocument.CreateElement(name);
|
|
||||||
newTenant.InnerText = GetCacheTextForShellDescriptor(descriptor);
|
|
||||||
rootNode.AppendChild(newTenant);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlDocument.Save(saveWriter);
|
xmlDocument.Save(saveWriter);
|
||||||
@@ -90,7 +94,7 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static string GetCacheTextForShellDescriptor(ShellDescriptor descriptor) {
|
private static string GetCacheTextForShellDescriptor(ShellDescriptor descriptor) {
|
||||||
StringBuilder sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.Append(descriptor.SerialNumber + "|");
|
sb.Append(descriptor.SerialNumber + "|");
|
||||||
foreach (var feature in descriptor.Features) {
|
foreach (var feature in descriptor.Features) {
|
||||||
sb.Append(feature.Name + ";");
|
sb.Append(feature.Name + ";");
|
||||||
@@ -106,7 +110,7 @@ namespace Orchard.Environment.Descriptor {
|
|||||||
|
|
||||||
private static ShellDescriptor GetShellDecriptorForCacheText(string p) {
|
private static ShellDescriptor GetShellDecriptorForCacheText(string p) {
|
||||||
string[] fields = p.Trim().Split(new[] { "|" }, StringSplitOptions.None);
|
string[] fields = p.Trim().Split(new[] { "|" }, StringSplitOptions.None);
|
||||||
ShellDescriptor shellDescriptor = new ShellDescriptor {SerialNumber = Convert.ToInt32(fields[0])};
|
var shellDescriptor = new ShellDescriptor {SerialNumber = Convert.ToInt32(fields[0])};
|
||||||
string[] features = fields[1].Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string[] features = fields[1].Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
shellDescriptor.Features = features.Select(feature => new ShellFeature { Name = feature }).ToList();
|
shellDescriptor.Features = features.Select(feature => new ShellFeature { Name = feature }).ToList();
|
||||||
string[] parameters = fields[2].Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string[] parameters = fields[2].Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Orchard.Mvc.ViewEngines.ThemeAwareness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ConfiguredEnginesCache : IConfiguredEnginesCache {
|
public class ConfiguredEnginesCache : IConfiguredEnginesCache {
|
||||||
IViewEngine _bare = null;
|
IViewEngine _bare;
|
||||||
readonly ConcurrentDictionary<string, IViewEngine> _shallow = new ConcurrentDictionary<string, IViewEngine>();
|
readonly ConcurrentDictionary<string, IViewEngine> _shallow = new ConcurrentDictionary<string, IViewEngine>();
|
||||||
readonly ConcurrentDictionary<string, IViewEngine> _deep = new ConcurrentDictionary<string, IViewEngine>();
|
readonly ConcurrentDictionary<string, IViewEngine> _deep = new ConcurrentDictionary<string, IViewEngine>();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Reflection;
|
|||||||
using Orchard.Validation;
|
using Orchard.Validation;
|
||||||
|
|
||||||
namespace Orchard.Utility {
|
namespace Orchard.Utility {
|
||||||
|
/// <summary>
|
||||||
/// Allows static reflection on members (methods, fields, properties).
|
/// Allows static reflection on members (methods, fields, properties).
|
||||||
/// This code has been adapted from the following blog post:
|
/// This code has been adapted from the following blog post:
|
||||||
/// http://wekempf.spaces.live.com/blog/cns!D18C3EC06EA971CF!694.entry
|
/// http://wekempf.spaces.live.com/blog/cns!D18C3EC06EA971CF!694.entry
|
||||||
|
|||||||
Reference in New Issue
Block a user