Tags provider rework.
Extend PipelineMessagePublisher directly
This commit is contained in:
parent
47d91041d9
commit
0ed3dd52f1
|
@ -3,7 +3,7 @@
|
|||
<metadata>
|
||||
<id>ProSol.Html.TagsProvider</id>
|
||||
<title>ProSol.Html.TagsProvider</title>
|
||||
<version>2.0.0-rc1.4</version>
|
||||
<version>2.0.0-rc2.0</version>
|
||||
<authors>Alex Kozachenko</authors>
|
||||
<owners>Alex Kozachenko</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
|
@ -15,7 +15,7 @@
|
|||
</description>
|
||||
<dependencies>
|
||||
<group targetFramework="net8.0" >
|
||||
<dependency id="ProSol.Messaging" version="4.0.0-rc.6.*" />
|
||||
<dependency id="ProSol.Messaging" version="4.0.0-rc.9.0" />
|
||||
</group>
|
||||
</dependencies>
|
||||
<tags> tool extraction web html observer observer-pattern design-patterns </tags>
|
||||
|
|
|
@ -6,13 +6,13 @@ namespace ProSol.Html.Messaging;
|
|||
|
||||
public static class IPublisherExtensions
|
||||
{
|
||||
public static IPublisher Filter(
|
||||
this IPublisher publisher,
|
||||
public static IPublisher<TagsProviderMessage> Filter(
|
||||
this IPublisher<TagsProviderMessage> publisher,
|
||||
string tagName)
|
||||
=> publisher.Filter([tagName]);
|
||||
|
||||
public static IPublisher Filter(
|
||||
this IPublisher publisher,
|
||||
public static IPublisher<TagsProviderMessage> Filter(
|
||||
this IPublisher<TagsProviderMessage> publisher,
|
||||
params string[] tagNames)
|
||||
=> publisher.Filter<TagsProviderMessage>(x => tagNames.Contains(x.CurrentTag.TagInfo.Name));
|
||||
=> publisher.Filter(x => tagNames.Contains(x.CurrentTag.TagInfo.Name));
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ProSol.Messaging" Version="4.0.0-rc.7.4" />
|
||||
<PackageReference Include="ProSol.Messaging" Version="4.0.0-rc.9.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -10,10 +10,9 @@ namespace ProSol.Html;
|
|||
/// <remarks>
|
||||
/// Push-notification happens only when the closing tag met, so it contains the full data on tag.
|
||||
/// </remarks>
|
||||
public class TagsProvider : IPublisher
|
||||
public class TagsProvider : PipelineMessagePublisher<TagsProviderMessage>
|
||||
{
|
||||
readonly HistoryTracker historyTracker = new();
|
||||
readonly PipelineMessagePublisher<TagsProviderMessage> publisher = new();
|
||||
|
||||
public void Process(ReadOnlySpan<char> html)
|
||||
{
|
||||
|
@ -26,12 +25,9 @@ public class TagsProvider : IPublisher
|
|||
charsProcessed += Proceed(currentHtml);
|
||||
} while (charsProcessed < html.Length);
|
||||
|
||||
publisher.Complete();
|
||||
base.Complete();
|
||||
}
|
||||
|
||||
public IDisposable Subscribe(ISubscriber observer)
|
||||
=> publisher.Subscribe(observer);
|
||||
|
||||
void Process(ReadOnlySpan<char> currentHtml, int charsProcessed)
|
||||
{
|
||||
if (TagDetector.Detect(currentHtml) != TagKind.Closing)
|
||||
|
@ -69,7 +65,7 @@ public class TagsProvider : IPublisher
|
|||
[..history],
|
||||
value);
|
||||
|
||||
publisher.Publish(message);
|
||||
base.Publish(message);
|
||||
}
|
||||
|
||||
static int Proceed(ReadOnlySpan<char> currentHtml)
|
||||
|
|
Loading…
Reference in a new issue