-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ab13ea
commit 7de5784
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Microsoft.AspNetCore.Html; | ||
using OrchardCore.DisplayManagement; | ||
using OrchardCore.DisplayManagement.Html; | ||
using OrchardCore.DisplayManagement.Shapes; | ||
using System.Collections.Frozen; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.IO; | ||
using System.Text.Encodings.Web; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement; | ||
|
||
// Based on OrchardCore.DisplayManagement.PositionWrapper. | ||
public class HtmlShape : IHtmlContent, IPositioned, IShape | ||
{ | ||
private static readonly IDictionary<string, string> _dummyAttributes = new Dictionary<string, string>().ToFrozenDictionary(); | ||
private static readonly IDictionary<string, object> _dummyProperties = new Dictionary<string, object>().ToFrozenDictionary(); | ||
|
||
private readonly IHtmlContent _value; | ||
|
||
public string Position { get; set; } | ||
|
||
public ShapeMetadata Metadata { get; set; } = new(); | ||
|
||
public string Id { get; set; } | ||
|
||
public string TagName { get; set; } | ||
|
||
public IList<string> Classes => []; | ||
|
||
public IDictionary<string, string> Attributes => _dummyAttributes; | ||
|
||
public IDictionary<string, object> Properties => _dummyProperties; | ||
|
||
public IReadOnlyList<IPositioned> Items => []; | ||
|
||
public HtmlShape(IHtmlContent value, string position) | ||
{ | ||
_value = value; | ||
Position = position; | ||
} | ||
|
||
public HtmlShape(string value, string position) | ||
: this(new HtmlContentString(value), position) | ||
{ | ||
} | ||
|
||
public void WriteTo(TextWriter writer, HtmlEncoder encoder) => _value.WriteTo(writer, encoder); | ||
|
||
public ValueTask<IShape> AddAsync(object item, string position) => throw new ReadOnlyException(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters