mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +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 = "";
|
||||
if (relativeFromPath != null && !relativeFromPath.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) {
|
||||
relativeFromPath += "\\";
|
||||
|
@@ -132,10 +132,7 @@ namespace Orchard.Experimental {
|
||||
public void AddTime(long time) { _time += time; }
|
||||
|
||||
public override string ToString() {
|
||||
if (_component == null)
|
||||
return "root";
|
||||
|
||||
return _component.ToString();
|
||||
return _component == null ? "root" : _component.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +229,7 @@ namespace Orchard.Experimental {
|
||||
}
|
||||
|
||||
private class TotalVisitor {
|
||||
public Node _totals = new Node(null);
|
||||
public readonly Node _totals = new Node(null);
|
||||
|
||||
public void Visit(Node source) {
|
||||
foreach (var child in source._children) {
|
||||
@@ -272,7 +269,7 @@ namespace Orchard.Experimental {
|
||||
return target;
|
||||
}
|
||||
|
||||
private XElement Write(Node node) {
|
||||
private static XElement Write(Node node) {
|
||||
var elt = new XElement(
|
||||
"Component",
|
||||
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
|
||||
.Elements(ns("Project"))
|
||||
.Elements(ns("PropertyGroup"))
|
||||
@@ -25,7 +25,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
||||
.Value;
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetSourceFilenames(XDocument document) {
|
||||
private static IEnumerable<string> GetSourceFilenames(XDocument document) {
|
||||
return document
|
||||
.Elements(ns("Project"))
|
||||
.Elements(ns("ItemGroup"))
|
||||
@@ -34,7 +34,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
||||
.Select(c => c.Value);
|
||||
}
|
||||
|
||||
private IEnumerable<ReferenceDescriptor> GetReferences(XDocument document) {
|
||||
private static IEnumerable<ReferenceDescriptor> GetReferences(XDocument document) {
|
||||
var assemblyReferences = document
|
||||
.Elements(ns("Project"))
|
||||
.Elements(ns("ItemGroup"))
|
||||
@@ -54,9 +54,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
||||
|
||||
private static string ExtractAssemblyName(string value) {
|
||||
int index = value.IndexOf(',');
|
||||
if (index < 0)
|
||||
return value;
|
||||
return value.Substring(0, index);
|
||||
return index < 0 ? value : value.Substring(0, index);
|
||||
}
|
||||
|
||||
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
|
||||
/// </summary>
|
||||
public class CoreExtensionLoader : ExtensionLoaderBase {
|
||||
private readonly string _coreAssemblyName = "Orchard.Core";
|
||||
private const string CoreAssemblyName = "Orchard.Core";
|
||||
private readonly IAssemblyLoader _assemblyLoader;
|
||||
|
||||
public CoreExtensionLoader(IDependenciesFolder dependenciesFolder, IAssemblyLoader assemblyLoader)
|
||||
@@ -38,9 +38,9 @@ namespace Orchard.Environment.Extensions.Loaders {
|
||||
protected override ExtensionEntry LoadWorker(ExtensionDescriptor descriptor) {
|
||||
//Logger.Information("Loading extension \"{0}\"", descriptor.Name);
|
||||
|
||||
var assembly = _assemblyLoader.Load(_coreAssemblyName);
|
||||
var assembly = _assemblyLoader.Load(CoreAssemblyName);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace Orchard.Environment.Extensions.Loaders {
|
||||
};
|
||||
}
|
||||
|
||||
private bool IsTypeFromModule(Type type, ExtensionDescriptor descriptor) {
|
||||
return (type.Namespace + ".").StartsWith(_coreAssemblyName + "." + descriptor.Id + ".");
|
||||
private static bool IsTypeFromModule(Type type, ExtensionDescriptor descriptor) {
|
||||
return (type.Namespace + ".").StartsWith(CoreAssemblyName + "." + descriptor.Id + ".");
|
||||
}
|
||||
}
|
||||
}
|
@@ -48,7 +48,7 @@ namespace Orchard.Environment {
|
||||
return Assembly.Load(fullName);
|
||||
}
|
||||
|
||||
private Assembly LookupFusion(string fullName) {
|
||||
private static Assembly LookupFusion(string fullName) {
|
||||
try {
|
||||
return Assembly.Load(fullName);
|
||||
}
|
||||
|
@@ -152,7 +152,7 @@ namespace Orchard.Environment {
|
||||
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()) {
|
||||
files.Add(directory);
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@ namespace Orchard.FileSystems.Dependencies {
|
||||
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);
|
||||
if (index < 0)
|
||||
return null;
|
||||
@@ -92,7 +92,7 @@ namespace Orchard.FileSystems.Dependencies {
|
||||
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
|
||||
.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);
|
||||
if (index < 0)
|
||||
return null;
|
||||
@@ -169,12 +169,12 @@ namespace Orchard.FileSystems.Dependencies {
|
||||
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
|
||||
.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
|
||||
.FirstOrDefault(p => virtualPath.StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
@@ -53,11 +53,8 @@ namespace Orchard.UI.Navigation {
|
||||
return url;
|
||||
}
|
||||
|
||||
private IEnumerable<MenuItem> Crop(IEnumerable<MenuItem> items) {
|
||||
foreach(var item in items) {
|
||||
if (item.Items.Any() || item.RouteValues != null)
|
||||
yield return item;
|
||||
}
|
||||
private static IEnumerable<MenuItem> Crop(IEnumerable<MenuItem> items) {
|
||||
return items.Where(item => item.Items.Any() || item.RouteValues != null);
|
||||
}
|
||||
|
||||
private IEnumerable<MenuItem> Reduce(IEnumerable<MenuItem> items) {
|
||||
|
Reference in New Issue
Block a user