10 changed files with 41 additions and 143 deletions
@ -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> |
|||
@ -1,7 +0,0 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp; |
|||
|
|||
public class AbpCommonModule : AbpModule |
|||
{ |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp; |
|||
|
|||
public class DynamicOptionsProvider<TValue> : IOptionsProvider<TValue>, ITransientDependency |
|||
where TValue : class, new() |
|||
{ |
|||
public TValue Value => _lazyValueFactory.Value; |
|||
|
|||
private readonly Lazy<TValue> _lazyValueFactory; |
|||
private readonly OneTimeRunner _oneTimeRunner; |
|||
|
|||
public DynamicOptionsProvider(IOptions<TValue> options) |
|||
{ |
|||
_oneTimeRunner = new OneTimeRunner(); |
|||
_lazyValueFactory = new Lazy<TValue>(() => CreateOptions(options)); |
|||
} |
|||
|
|||
protected virtual TValue CreateOptions(IOptions<TValue> options) |
|||
{ |
|||
// 用于简化需要在使用配置前自行调用此接口的繁复步骤
|
|||
// await options.SetAsync();
|
|||
// _onTimeRunner.Run(async () => await options.SetAsync());
|
|||
return options.Value; |
|||
} |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
namespace LINGYUN.Abp; |
|||
|
|||
public interface IOptionsProvider<TValue> |
|||
where TValue: class, new() |
|||
{ |
|||
TValue Value { get; } |
|||
} |
|||
@ -1,46 +0,0 @@ |
|||
# LINGYUN.Abp.Core |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.Core` is a basic core module that provides some common functionalities and extensions. |
|||
|
|||
## Features |
|||
|
|||
* Dynamic Options Provider (`DynamicOptionsProvider<TValue>`) |
|||
* Simplifies the complex steps of calling interfaces before using configuration |
|||
* Supports lazy loading of configuration values |
|||
* Provides one-time running mechanism to ensure configuration is loaded only once |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Core |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Add `[DependsOn(typeof(AbpCommonModule))]` to your module class. |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpCommonModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Use Dynamic Options Provider: |
|||
|
|||
```csharp |
|||
public class YourOptionsProvider : DynamicOptionsProvider<YourOptions> |
|||
{ |
|||
public YourOptionsProvider(IOptions<YourOptions> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -1,46 +0,0 @@ |
|||
# LINGYUN.Abp.Core |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.Core` 是一个基础核心模块,提供了一些通用的功能和扩展。 |
|||
|
|||
## 功能 |
|||
|
|||
* 动态选项提供者 (`DynamicOptionsProvider<TValue>`) |
|||
* 简化需要在使用配置前自行调用接口的繁复步骤 |
|||
* 支持延迟加载配置值 |
|||
* 提供一次性运行机制,确保配置只被加载一次 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Core |
|||
``` |
|||
|
|||
## 使用 |
|||
|
|||
1. 添加 `[DependsOn(typeof(AbpCommonModule))]` 到你的模块类上。 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpCommonModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 使用动态选项提供者: |
|||
|
|||
```csharp |
|||
public class YourOptionsProvider : DynamicOptionsProvider<YourOptions> |
|||
{ |
|||
public YourOptionsProvider(IOptions<YourOptions> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 链接 |
|||
|
|||
* [English document](./README.EN.md) |
|||
Loading…
Reference in new issue