Skip to content

Commit

Permalink
Code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
BenedekFarkas committed Apr 9, 2024
1 parent a751764 commit d95f812
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 37 deletions.
26 changes: 10 additions & 16 deletions src/Orchard.Web/Modules/Orchard.Tags/Feeds/TagFeedQuery.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
using System;
using System.Web.Mvc;
using System.Web.Routing;
using System.Xml.Linq;
using Orchard.ContentManagement;
using Orchard.Core.Feeds;
using Orchard.Core.Feeds.Models;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.Mvc.Extensions;
using Orchard.Core.Feeds;
using Orchard.Tags.Services;
using Orchard.Localization;
using System.Web.Routing;
using Orchard.Environment.Extensions;

namespace Orchard.Tags.Feeds
{
namespace Orchard.Tags.Feeds {
[OrchardFeature("Orchard.Tags.Feeds")]
public class TagFeedQuery : IFeedQueryProvider, IFeedQuery {
private readonly IContentManager _contentManager;
private readonly ITagService _tagService;

public TagFeedQuery(
IContentManager contentManager,
ITagService tagService) {
_contentManager = contentManager;
public TagFeedQuery(ITagService tagService) {
_tagService = tagService;

T = NullLocalizer.Instance;
Expand All @@ -35,11 +29,11 @@ public FeedQueryMatch Match(FeedContext context) {

var tagName = (string)tagIdValue.ConvertTo(typeof(string));
var tag = _tagService.GetTagByName(tagName);

if (tag == null) {
return null;
}

return new FeedQueryMatch { FeedQuery = this, Priority = -5 };
}

Expand All @@ -50,10 +44,10 @@ public void Execute(FeedContext context) {

var limitValue = context.ValueProvider.GetValue("limit");
var limit = 20;
if (limitValue != null) {
if (limitValue != null) {
Int32.TryParse(Convert.ToString(limitValue), out limit);
}

limit = Math.Min(limit, 100);

var tagName = (string)tagIdValue.ConvertTo(typeof(string));
Expand Down
2 changes: 1 addition & 1 deletion src/Orchard/Services/HtmlFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
public abstract class HtmlFilter : Component, IHtmlFilter {
public abstract string ProcessContent(string text, HtmlFilterContext context);
}
}
}
11 changes: 3 additions & 8 deletions src/Orchard/Services/HtmlFilterContext.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System.Collections.Generic;

namespace Orchard.Services
{
namespace Orchard.Services {
public class HtmlFilterContext {
public HtmlFilterContext() {
Data = new Dictionary<string, object>();
}

public string Flavor { get; set; }
public IDictionary<string, object> Data { get; set; }
public IDictionary<string, object> Data { get; set; } = new Dictionary<string, object>();
}
}
}
3 changes: 2 additions & 1 deletion src/Orchard/Services/HtmlFilterProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Orchard.Services {
public class HtmlFilterProcessor : IHtmlFilterProcessor {
private readonly IEnumerable<IHtmlFilter> _filters;

public HtmlFilterProcessor(IEnumerable<IHtmlFilter> filters) {
_filters = filters;
}
Expand All @@ -12,4 +13,4 @@ public string ProcessFilters(string text, HtmlFilterContext context) {
return _filters.Aggregate(text, (current, htmlFilter) => htmlFilter.ProcessContent(current, context));
}
}
}
}
2 changes: 1 addition & 1 deletion src/Orchard/Services/IHtmlFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ namespace Orchard.Services {
public interface IHtmlFilter : IDependency {
string ProcessContent(string text, HtmlFilterContext context);
}
}
}
26 changes: 16 additions & 10 deletions src/Orchard/Services/IHtmlFilterProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ public interface IHtmlFilterProcessor : IDependency {
}

public static class HtmlFilterProcessorExtensions {
public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor, IDictionary<string, object> data) {
return processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor, Data = data });
}
public static string ProcessFilters(
this IHtmlFilterProcessor processor,
string text,
string flavor,
IDictionary<string, object> data) =>
processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor, Data = data });

public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor) {
return processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor });
}
public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor) =>
processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor });

public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor, IContent content) {
return processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor, Data = new Dictionary<string, object> { { "Content", content.ContentItem } } });
}
public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor, IContent content) =>
processor.ProcessFilters(
text,
new HtmlFilterContext {
Flavor = flavor,
Data = new Dictionary<string, object> { { "Content", content.ContentItem } }
});
}
}
}

0 comments on commit d95f812

Please sign in to comment.