Merge pull request #5199 from vairam-svs/1.x

Remove Duplicate code that could be cleanedup for better maintenance.
This commit is contained in:
Sébastien Ros
2015-04-24 11:09:49 -07:00
4 changed files with 27 additions and 55 deletions

View File

@@ -127,24 +127,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
} }
public void SetMeta(string name = null, string content = null, string httpEquiv = null, string charset = null) { public void SetMeta(string name = null, string content = null, string httpEquiv = null, string charset = null) {
var metaEntry = new MetaEntry(); var metaEntry = new MetaEntry(name, content, httpEquiv, charset);
if (!String.IsNullOrEmpty(name)) {
metaEntry.Name = name;
}
if (!String.IsNullOrEmpty(content)) {
metaEntry.Content = content;
}
if (!String.IsNullOrEmpty(httpEquiv)) {
metaEntry.HttpEquiv = httpEquiv;
}
if (!String.IsNullOrEmpty(charset)) {
metaEntry.Charset = charset;
}
SetMeta(metaEntry); SetMeta(metaEntry);
} }

View File

@@ -78,24 +78,7 @@ namespace Orchard.Mvc {
} }
public void SetMeta(string name = null, string content = null, string httpEquiv = null, string charset = null) { public void SetMeta(string name = null, string content = null, string httpEquiv = null, string charset = null) {
var metaEntry = new MetaEntry(); var metaEntry = new MetaEntry(name, content, httpEquiv, charset);
if (!String.IsNullOrEmpty(name)) {
metaEntry.Name = name;
}
if (!String.IsNullOrEmpty(content)) {
metaEntry.Content = content;
}
if (!String.IsNullOrEmpty(httpEquiv)) {
metaEntry.HttpEquiv = httpEquiv;
}
if (!String.IsNullOrEmpty(charset)) {
metaEntry.Charset = charset;
}
SetMeta(metaEntry); SetMeta(metaEntry);
} }
@@ -182,4 +165,4 @@ namespace Orchard.Mvc {
public class ViewPage : ViewPage<dynamic> { public class ViewPage : ViewPage<dynamic> {
} }
} }

View File

@@ -67,24 +67,7 @@ namespace Orchard.Mvc {
} }
public void SetMeta(string name = null, string content = null, string httpEquiv = null, string charset = null) { public void SetMeta(string name = null, string content = null, string httpEquiv = null, string charset = null) {
var metaEntry = new MetaEntry(); var metaEntry = new MetaEntry(name, content, httpEquiv, charset);
if (!String.IsNullOrEmpty(name)) {
metaEntry.Name = name;
}
if (!String.IsNullOrEmpty(content)) {
metaEntry.Content = content;
}
if (!String.IsNullOrEmpty(httpEquiv)) {
metaEntry.HttpEquiv = httpEquiv;
}
if (!String.IsNullOrEmpty(charset)) {
metaEntry.Charset = charset;
}
SetMeta(metaEntry); SetMeta(metaEntry);
} }

View File

@@ -5,6 +5,29 @@ using System.Web.Mvc;
namespace Orchard.UI.Resources { namespace Orchard.UI.Resources {
public class MetaEntry { public class MetaEntry {
private readonly TagBuilder _builder = new TagBuilder("meta"); private readonly TagBuilder _builder = new TagBuilder("meta");
public MetaEntry() {
}
public MetaEntry(string name = null, string content = null, string httpEquiv = null, string charset = null) {
if (!String.IsNullOrEmpty(name)) {
Name = name;
}
if (!String.IsNullOrEmpty(content)) {
Content = content;
}
if (!String.IsNullOrEmpty(httpEquiv)) {
HttpEquiv = httpEquiv;
}
if (!String.IsNullOrEmpty(charset)) {
Charset = charset;
}
}
public static MetaEntry Combine(MetaEntry meta1, MetaEntry meta2, string contentSeparator) { public static MetaEntry Combine(MetaEntry meta1, MetaEntry meta2, string contentSeparator) {
var newMeta = new MetaEntry(); var newMeta = new MetaEntry();