-
Notifications
You must be signed in to change notification settings - Fork 270
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
Showing
38 changed files
with
538 additions
and
95 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: "Publish" | |
|
||
on: | ||
push: | ||
branches: [ rel-8.3.4 ] | ||
branches: [ main ] | ||
env: | ||
DOTNET_VERSION: "8.0.200" | ||
|
||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: "Tagged Release" | |
|
||
on: | ||
push: | ||
branches: [ rel-8.3.4 ] | ||
branches: [ main ] | ||
|
||
jobs: | ||
tagged-release: | ||
|
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
3 changes: 3 additions & 0 deletions
3
...-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/FodyWeavers.xml
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,3 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<ConfigureAwait ContinueOnCapturedContext="false" /> | ||
</Weavers> |
30 changes: 30 additions & 0 deletions
30
...-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Templating/FodyWeavers.xsd
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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> | ||
<xs:element name="Weavers"> | ||
<xs:complexType> | ||
<xs:all> | ||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> | ||
<xs:complexType> | ||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:all> | ||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> | ||
<xs:annotation> | ||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
<xs:attribute name="GenerateXsd" type="xs:boolean"> | ||
<xs:annotation> | ||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> |
20 changes: 20 additions & 0 deletions
20
...ications/LINGYUN.Abp.Notifications.Templating/LINGYUN.Abp.Notifications.Templating.csproj
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="..\..\..\..\configureawait.props" /> | ||
<Import Project="..\..\..\..\common.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks> | ||
<AssemblyName>LINGYUN.Abp.Notifications.Templating</AssemblyName> | ||
<PackageId>LINGYUN.Abp.Notifications.Templating</PackageId> | ||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> | ||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> | ||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> | ||
<RootNamespace /> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\LINGYUN.Abp.Notifications.Core\LINGYUN.Abp.Notifications.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
17 changes: 17 additions & 0 deletions
17
...cations.Templating/LINGYUN/Abp/Notifications/Templating/AbpNotificationsResolveOptions.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,17 @@ | ||
using JetBrains.Annotations; | ||
using System.Collections.Generic; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public class AbpNotificationsResolveOptions | ||
{ | ||
/// <summary> | ||
/// 模板解析提供者列表 | ||
/// </summary> | ||
[NotNull] | ||
public List<INotificationTemplateResolveContributor> TemplateResolvers { get; } | ||
|
||
public AbpNotificationsResolveOptions() | ||
{ | ||
TemplateResolvers = new List<INotificationTemplateResolveContributor>(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...tions.Templating/LINGYUN/Abp/Notifications/Templating/AbpNotificationsTemplatingModule.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,9 @@ | ||
using Volo.Abp.Modularity; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
|
||
[DependsOn(typeof(AbpNotificationsCoreModule))] | ||
public class AbpNotificationsTemplatingModule : AbpModule | ||
{ | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...ns.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolveContext.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,11 @@ | ||
using Volo.Abp.DependencyInjection; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public interface INotificationTemplateResolveContext : IServiceProviderAccessor | ||
{ | ||
NotificationTemplate Template { get; } | ||
|
||
object Model { get; set; } | ||
|
||
bool Handled { get; set; } | ||
} |
9 changes: 9 additions & 0 deletions
9
...emplating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolveContributor.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,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public interface INotificationTemplateResolveContributor | ||
{ | ||
string Name { get; } | ||
|
||
Task ResolveAsync(INotificationTemplateResolveContext context); | ||
} |
17 changes: 17 additions & 0 deletions
17
...ications.Templating/LINGYUN/Abp/Notifications/Templating/INotificationTemplateResolver.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,17 @@ | ||
using JetBrains.Annotations; | ||
using System.Threading.Tasks; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
/// <summary> | ||
/// 通知模板模型解析接口 | ||
/// </summary> | ||
public interface INotificationTemplateResolver | ||
{ | ||
/// <summary> | ||
/// 解析模板数据 | ||
/// </summary> | ||
/// <param name="template"></param> | ||
/// <returns></returns> | ||
[NotNull] | ||
Task<NotificationTemplateResolveResult> ResolveAsync(NotificationTemplate template); | ||
} |
26 changes: 26 additions & 0 deletions
26
...ons.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveContext.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,26 @@ | ||
using System; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public class NotificationTemplateResolveContext : INotificationTemplateResolveContext | ||
{ | ||
public IServiceProvider ServiceProvider { get; } | ||
|
||
public NotificationTemplate Template { get; } | ||
|
||
public object Model { get; set; } | ||
|
||
public bool Handled { get; set; } | ||
|
||
public bool HasResolvedModel() | ||
{ | ||
return Handled || Model != null; | ||
} | ||
|
||
public NotificationTemplateResolveContext( | ||
NotificationTemplate template, | ||
IServiceProvider serviceProvider) | ||
{ | ||
Template = template; | ||
ServiceProvider = serviceProvider; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...lating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveContributorBase.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,13 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public abstract class NotificationTemplateResolveContributorBase : INotificationTemplateResolveContributor | ||
{ | ||
public abstract string Name { get; } | ||
/// <summary> | ||
/// 实现此接口处理模板数据 | ||
/// </summary> | ||
/// <param name="context"></param> | ||
/// <returns></returns> | ||
public abstract Task ResolveAsync(INotificationTemplateResolveContext context); | ||
} |
16 changes: 16 additions & 0 deletions
16
...ions.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolveResult.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,16 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public class NotificationTemplateResolveResult | ||
{ | ||
/// <summary> | ||
/// 模板数据 | ||
/// </summary> | ||
public object Model { get; set; } | ||
|
||
public List<string> AppliedResolvers { get; } | ||
public NotificationTemplateResolveResult() | ||
{ | ||
AppliedResolvers = new List<string>(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...fications.Templating/LINGYUN/Abp/Notifications/Templating/NotificationTemplateResolver.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,58 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Volo.Abp.DependencyInjection; | ||
|
||
namespace LINGYUN.Abp.Notifications.Templating; | ||
public class NotificationTemplateResolver : INotificationTemplateResolver, ITransientDependency | ||
{ | ||
private readonly IServiceProvider _serviceProvider; | ||
private readonly AbpNotificationsResolveOptions _options; | ||
|
||
public NotificationTemplateResolver( | ||
IOptions<AbpNotificationsResolveOptions> options, | ||
IServiceProvider serviceProvider) | ||
{ | ||
_serviceProvider = serviceProvider; | ||
_options = options.Value; | ||
} | ||
public async virtual Task<NotificationTemplateResolveResult> ResolveAsync(NotificationTemplate template) | ||
{ | ||
var result = new NotificationTemplateResolveResult(); | ||
|
||
using (var serviceScope = _serviceProvider.CreateScope()) | ||
{ | ||
var context = new NotificationTemplateResolveContext(template, serviceScope.ServiceProvider); | ||
|
||
foreach (var resolveContributor in _options.TemplateResolvers) | ||
{ | ||
// TODO: 设定为每一个通知都配置自己的解析提供者? | ||
/** | ||
if (resolveContributor.Name.Equals(template.Name)) | ||
{ | ||
await resolveContributor.ResolveAsync(context); | ||
} | ||
if (context.HasResolvedModel()) | ||
{ | ||
result.Model = context.Model; | ||
break; | ||
} | ||
**/ | ||
|
||
await resolveContributor.ResolveAsync(context); | ||
|
||
result.AppliedResolvers.Add(resolveContributor.Name); | ||
|
||
if (context.HasResolvedModel()) | ||
{ | ||
result.Model = context.Model; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} |
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
Oops, something went wrong.