mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Refactoring
--HG-- branch : dev
This commit is contained in:
@@ -358,7 +358,7 @@ namespace Orchard.CodeGeneration.Commands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CreateProjectItemGroup(string relativeFromPath, HashSet<string> content, HashSet<string> folders) {
|
private static string CreateProjectItemGroup(string relativeFromPath, HashSet<string> content, HashSet<string> folders) {
|
||||||
var contentInclude = "";
|
var contentInclude = "";
|
||||||
if (relativeFromPath != null && !relativeFromPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) {
|
if (relativeFromPath != null && !relativeFromPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) {
|
||||||
relativeFromPath += "\\";
|
relativeFromPath += "\\";
|
||||||
|
@@ -132,10 +132,7 @@ namespace Orchard.Experimental {
|
|||||||
public void AddTime(long time) { _time += time; }
|
public void AddTime(long time) { _time += time; }
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
if (_component == null)
|
return _component == null ? "root" : _component.ToString();
|
||||||
return "root";
|
|
||||||
|
|
||||||
return _component.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -232,7 +229,7 @@ namespace Orchard.Experimental {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class TotalVisitor {
|
private class TotalVisitor {
|
||||||
public Node _totals = new Node(null);
|
public readonly Node _totals = new Node(null);
|
||||||
|
|
||||||
public void Visit(Node source) {
|
public void Visit(Node source) {
|
||||||
foreach (var child in source._children) {
|
foreach (var child in source._children) {
|
||||||
@@ -272,7 +269,7 @@ namespace Orchard.Experimental {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private XElement Write(Node node) {
|
private static XElement Write(Node node) {
|
||||||
var elt = new XElement(
|
var elt = new XElement(
|
||||||
"Component",
|
"Component",
|
||||||
new XAttribute("services", node._component != null ? string.Join(",", node._component.Services) : "root"),
|
new XAttribute("services", node._component != null ? string.Join(",", node._component.Services) : "root"),
|
||||||
|
@@ -16,7 +16,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetAssemblyName(XDocument document) {
|
private static string GetAssemblyName(XDocument document) {
|
||||||
return document
|
return document
|
||||||
.Elements(ns("Project"))
|
.Elements(ns("Project"))
|
||||||
.Elements(ns("PropertyGroup"))
|
.Elements(ns("PropertyGroup"))
|
||||||
@@ -25,7 +25,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
.Value;
|
.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetSourceFilenames(XDocument document) {
|
private static IEnumerable<string> GetSourceFilenames(XDocument document) {
|
||||||
return document
|
return document
|
||||||
.Elements(ns("Project"))
|
.Elements(ns("Project"))
|
||||||
.Elements(ns("ItemGroup"))
|
.Elements(ns("ItemGroup"))
|
||||||
@@ -34,7 +34,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
.Select(c => c.Value);
|
.Select(c => c.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<ReferenceDescriptor> GetReferences(XDocument document) {
|
private static IEnumerable<ReferenceDescriptor> GetReferences(XDocument document) {
|
||||||
var assemblyReferences = document
|
var assemblyReferences = document
|
||||||
.Elements(ns("Project"))
|
.Elements(ns("Project"))
|
||||||
.Elements(ns("ItemGroup"))
|
.Elements(ns("ItemGroup"))
|
||||||
@@ -54,9 +54,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
|
|
||||||
private static string ExtractAssemblyName(string value) {
|
private static string ExtractAssemblyName(string value) {
|
||||||
int index = value.IndexOf(',');
|
int index = value.IndexOf(',');
|
||||||
if (index < 0)
|
return index < 0 ? value : value.Substring(0, index);
|
||||||
return value;
|
|
||||||
return value.Substring(0, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static XName ns(string name) {
|
private static XName ns(string name) {
|
||||||
|
@@ -9,7 +9,7 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
/// Load an extension by looking into specific namespaces of the "Orchard.Core" assembly
|
/// Load an extension by looking into specific namespaces of the "Orchard.Core" assembly
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CoreExtensionLoader : ExtensionLoaderBase {
|
public class CoreExtensionLoader : ExtensionLoaderBase {
|
||||||
private readonly string _coreAssemblyName = "Orchard.Core";
|
private const string CoreAssemblyName = "Orchard.Core";
|
||||||
private readonly IAssemblyLoader _assemblyLoader;
|
private readonly IAssemblyLoader _assemblyLoader;
|
||||||
|
|
||||||
public CoreExtensionLoader(IDependenciesFolder dependenciesFolder, IAssemblyLoader assemblyLoader)
|
public CoreExtensionLoader(IDependenciesFolder dependenciesFolder, IAssemblyLoader assemblyLoader)
|
||||||
@@ -38,9 +38,9 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
protected override ExtensionEntry LoadWorker(ExtensionDescriptor descriptor) {
|
protected override ExtensionEntry LoadWorker(ExtensionDescriptor descriptor) {
|
||||||
//Logger.Information("Loading extension \"{0}\"", descriptor.Name);
|
//Logger.Information("Loading extension \"{0}\"", descriptor.Name);
|
||||||
|
|
||||||
var assembly = _assemblyLoader.Load(_coreAssemblyName);
|
var assembly = _assemblyLoader.Load(CoreAssemblyName);
|
||||||
if (assembly == null) {
|
if (assembly == null) {
|
||||||
Logger.Error("Core modules cannot be activated because assembly '{0}' could not be loaded", _coreAssemblyName);
|
Logger.Error("Core modules cannot be activated because assembly '{0}' could not be loaded", CoreAssemblyName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsTypeFromModule(Type type, ExtensionDescriptor descriptor) {
|
private static bool IsTypeFromModule(Type type, ExtensionDescriptor descriptor) {
|
||||||
return (type.Namespace + ".").StartsWith(_coreAssemblyName + "." + descriptor.Id + ".");
|
return (type.Namespace + ".").StartsWith(CoreAssemblyName + "." + descriptor.Id + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -48,7 +48,7 @@ namespace Orchard.Environment {
|
|||||||
return Assembly.Load(fullName);
|
return Assembly.Load(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Assembly LookupFusion(string fullName) {
|
private static Assembly LookupFusion(string fullName) {
|
||||||
try {
|
try {
|
||||||
return Assembly.Load(fullName);
|
return Assembly.Load(fullName);
|
||||||
}
|
}
|
||||||
|
@@ -152,7 +152,7 @@ namespace Orchard.Environment {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetViewDirectories(IVirtualPathProvider vpp, string directory, IEnumerable<string> extensions, ICollection<string> files) {
|
private static void GetViewDirectories(IVirtualPathProvider vpp, string directory, IEnumerable<string> extensions, ICollection<string> files) {
|
||||||
if (vpp.ListFiles(directory).Where(f => extensions.Any(e => f.EndsWith(e, StringComparison.OrdinalIgnoreCase))).Any()) {
|
if (vpp.ListFiles(directory).Where(f => extensions.Any(e => f.EndsWith(e, StringComparison.OrdinalIgnoreCase))).Any()) {
|
||||||
files.Add(directory);
|
files.Add(directory);
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
return _dependenciesFolder.GetDescriptor(moduleName);
|
return _dependenciesFolder.GetDescriptor(moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ModuleMatch(string virtualPath, string prefix) {
|
private static string ModuleMatch(string virtualPath, string prefix) {
|
||||||
var index = virtualPath.IndexOf('/', prefix.Length, virtualPath.Length - prefix.Length);
|
var index = virtualPath.IndexOf('/', prefix.Length, virtualPath.Length - prefix.Length);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return null;
|
return null;
|
||||||
@@ -92,7 +92,7 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
return (string.IsNullOrEmpty(moduleName) ? null : moduleName);
|
return (string.IsNullOrEmpty(moduleName) ? null : moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PrefixMatch(string virtualPath, params string[] prefixes) {
|
private static string PrefixMatch(string virtualPath, params string[] prefixes) {
|
||||||
return prefixes
|
return prefixes
|
||||||
.FirstOrDefault(p => virtualPath.StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(p => virtualPath.StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
@@ -160,7 +160,7 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ModuleMatch(string virtualPath, string prefix) {
|
private static string ModuleMatch(string virtualPath, string prefix) {
|
||||||
var index = virtualPath.IndexOf('/', prefix.Length, virtualPath.Length - prefix.Length);
|
var index = virtualPath.IndexOf('/', prefix.Length, virtualPath.Length - prefix.Length);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
return null;
|
return null;
|
||||||
@@ -169,12 +169,12 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
return (string.IsNullOrEmpty(moduleName) ? null : moduleName);
|
return (string.IsNullOrEmpty(moduleName) ? null : moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ExtensionMatch(string virtualPath, params string[] extensions) {
|
private static string ExtensionMatch(string virtualPath, params string[] extensions) {
|
||||||
return extensions
|
return extensions
|
||||||
.FirstOrDefault(e => virtualPath.EndsWith(e, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(e => virtualPath.EndsWith(e, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PrefixMatch(string virtualPath, params string[] prefixes) {
|
private static string PrefixMatch(string virtualPath, params string[] prefixes) {
|
||||||
return prefixes
|
return prefixes
|
||||||
.FirstOrDefault(p => virtualPath.StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(p => virtualPath.StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
@@ -53,11 +53,8 @@ namespace Orchard.UI.Navigation {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<MenuItem> Crop(IEnumerable<MenuItem> items) {
|
private static IEnumerable<MenuItem> Crop(IEnumerable<MenuItem> items) {
|
||||||
foreach(var item in items) {
|
return items.Where(item => item.Items.Any() || item.RouteValues != null);
|
||||||
if (item.Items.Any() || item.RouteValues != null)
|
|
||||||
yield return item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<MenuItem> Reduce(IEnumerable<MenuItem> items) {
|
private IEnumerable<MenuItem> Reduce(IEnumerable<MenuItem> items) {
|
||||||
|
Reference in New Issue
Block a user