(options =>
{
- options.MinimumSameSitePolicy = Unspecified;
- options.OnAppendCookie = cookieContext =>
- CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
- options.OnDeleteCookie = cookieContext =>
- CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
+ options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
+ options.OnAppendCookie = cookieContext =>
+ CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
+ options.OnDeleteCookie = cookieContext =>
+ CheckSameSite(cookieContext.Context, cookieContext.CookieOptions);
});
return services;
}
-
+
private static void CheckSameSite(HttpContext httpContext, CookieOptions options)
{
if (options.SameSite == SameSiteMode.None)
{
var userAgent = httpContext.Request.Headers["User-Agent"].ToString();
-
- if (DisallowsSameSiteNone(userAgent))
+ if (!httpContext.Request.IsHttps || DisallowsSameSiteNone(userAgent))
{
- options.SameSite = Unspecified;
+ // For .NET Core < 3.1 set SameSite = (SameSiteMode)(-1)
+ options.SameSite = SameSiteMode.Unspecified;
}
}
}
- ///
- /// Checks if the UserAgent is known to interpret an unknown value as Strict.
- /// For those the property should be
- /// set to .
- ///
- ///
- /// This code is taken from Microsoft:
- /// https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/
- ///
- /// The user agent string to check.
- /// Whether the specified user agent (browser) accepts SameSite=None or not.
private static bool DisallowsSameSiteNone(string userAgent)
{
// Cover all iOS based browsers here. This includes:
- // - Safari on iOS 12 for iPhone, iPod Touch, iPad
- // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad
- // - Chrome on iOS 12 for iPhone, iPod Touch, iPad
- // All of which are broken by SameSite=None, because they use the
- // iOS networking stack.
- // Notes from Thinktecture:
- // Regarding https://caniuse.com/#search=samesite iOS versions lower
- // than 12 are not supporting SameSite at all. Starting with version 13
- // unknown values are NOT treated as strict anymore. Therefore we only
- // need to check version 12.
- if (userAgent.Contains("CPU iPhone OS 12")
- || userAgent.Contains("iPad; CPU OS 12"))
+ // - Safari on iOS 12 for iPhone, iPod Touch, iPad
+ // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad
+ // - Chrome on iOS 12 for iPhone, iPod Touch, iPad
+ // All of which are broken by SameSite=None, because they use the iOS networking stack
+ if (userAgent.Contains("CPU iPhone OS 12") || userAgent.Contains("iPad; CPU OS 12"))
{
return true;
}
- // Cover Mac OS X based browsers that use the Mac OS networking stack.
- // This includes:
- // - Safari on Mac OS X.
+ // Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:
+ // - Safari on Mac OS X.
// This does not include:
- // - Chrome on Mac OS X
- // because they do not use the Mac OS networking stack.
- // Notes from Thinktecture:
- // Regarding https://caniuse.com/#search=samesite MacOS X versions lower
- // than 10.14 are not supporting SameSite at all. Starting with version
- // 10.15 unknown values are NOT treated as strict anymore. Therefore we
- // only need to check version 10.14.
- if (userAgent.Contains("Safari")
- && userAgent.Contains("Macintosh; Intel Mac OS X 10_14")
- && userAgent.Contains("Version/"))
+ // - Chrome on Mac OS X
+ // Because they do not use the Mac OS networking stack.
+ if (userAgent.Contains("Macintosh; Intel Mac OS X 10_14") &&
+ userAgent.Contains("Version/") && userAgent.Contains("Safari"))
{
return true;
}
- // Cover Chrome 50-69, because some versions are broken by SameSite=None
+ // Cover Chrome 50-69, because some versions are broken by SameSite=None,
// and none in this range require it.
- // Note: this covers some pre-Chromium Edge versions,
+ // Note: this covers some pre-Chromium Edge versions,
// but pre-Chromium Edge does not require SameSite=None.
- // Notes from Thinktecture:
- // We can not validate this assumption, but we trust Microsofts
- // evaluation. And overall not sending a SameSite value equals to the same
- // behavior as SameSite=None for these old versions anyways.
if (userAgent.Contains("Chrome/5") || userAgent.Contains("Chrome/6"))
{
return true;
}
-
- if (GetChromeVersion(userAgent) >= 80)
- {
- return true;
- }
return false;
}
-
- private static int GetChromeVersion(string userAgent)
- {
- try
- {
- return Convert.ToInt32(userAgent.Split("Chrome/")[1].Split('.')[0]);
- }
- catch (Exception)
- {
- return 0;
- }
- }
}
}
```
@@ -173,7 +91,7 @@ Assume that your project name is *Acme.BookStore*. Then open `AcmeBookStoreWebMo
Add the following line to `ConfigureServices()` method.
```csharp
- context.Services.ConfigureNonBreakingSameSiteCookies();
+ context.Services.AddSameSiteCookiePolicy(); // cookie policy to deal with temporary browser incompatibilities
```
### Step-3
@@ -195,18 +113,14 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseHsts();
}
- app.UseCookiePolicy(); //<--- added this --->
+ app.UseCookiePolicy(); // added this, Before UseAuthentication or anything else that writes cookies.
//....
}
```
-
-
It's all! You are ready to go!
-
-
---
-Referenced from https://www.thinktecture.com/en/identity/samesite/prepare-your-identityserver/
+Referenced from https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/
diff --git a/docs/en/Community-Articles/2020-12-11-Using-Angular-Material-Components-With-ABP-Framework/POST.md b/docs/en/Community-Articles/2020-12-11-Using-Angular-Material-Components-With-ABP-Framework/POST.md
index 7b1ae846af..02cef11a2e 100644
--- a/docs/en/Community-Articles/2020-12-11-Using-Angular-Material-Components-With-ABP-Framework/POST.md
+++ b/docs/en/Community-Articles/2020-12-11-Using-Angular-Material-Components-With-ABP-Framework/POST.md
@@ -260,7 +260,7 @@ import { MatFormFieldModule } from "@angular/material/form-field";
import { MatInputModule } from "@angular/material/input";
import { MatSelectModule } from "@angular/material/select";
import { MatIconModule } from "@angular/material/icon";
-import { MatNativeDateModule } from '@angular/material/core';
+import { MatNativeDateModule } from "@angular/material/core";
@NgModule({
imports: [
@@ -1576,6 +1576,10 @@ Final UI looks as shown below:

+## The Source Code
+
+You can download the source code from [here](https://github.com/abpframework/abp-samples/tree/master/AcmeBookStoreAngularMaterial).
+
## Conclusion
We implemented Angular Material Components to our angular application which was created with ABP Framework. There is no blocker case of using angular libraries with the ABP framework.
diff --git a/docs/en/Modules/Index.md b/docs/en/Modules/Index.md
index 9d0199f4c3..8851f8b554 100644
--- a/docs/en/Modules/Index.md
+++ b/docs/en/Modules/Index.md
@@ -2,7 +2,7 @@
ABP is a **modular application framework** which consists of dozens of **NuGet & NPM packages**. It also provides a complete infrastructure to build your own application modules which may have entities, services, database integration, APIs, UI components and so on.
-There are **two types of modules.** They don't have any structural difference but categorized by functionality and purpose:
+There are **two types of modules.** They don't have any structural difference but are categorized by functionality and purpose:
* [**Framework modules**](https://github.com/abpframework/abp/tree/master/framework/src): These are **core modules of the framework** like caching, emailing, theming, security, serialization, validation, EF Core integration, MongoDB integration... etc. They do not have application/business functionalities but makes your daily development easier by providing common infrastructure, integration and abstractions.
* [**Application modules**](https://github.com/abpframework/abp/tree/master/modules): These modules implement specific application/business functionalities like blogging, document management, identity management, tenant management... etc. They generally have their own entities, services, APIs and UI components.
diff --git a/docs/en/Modules/Setting-Management.md b/docs/en/Modules/Setting-Management.md
index 134e24aed2..dff8da3f8e 100644
--- a/docs/en/Modules/Setting-Management.md
+++ b/docs/en/Modules/Setting-Management.md
@@ -75,7 +75,7 @@ Setting values are cached using the [distributed cache](../Caching.md) system. A
## Setting Management Providers
-Setting Management module is extensible, just like the [setting system](../Settings.md). You can extend it by defining setting management providers. There are 5 pre-built setting management providers registered by the order below:
+Setting Management module is extensible, just like the [setting system](../Settings.md). You can extend it by defining setting management providers. There are 5 pre-built setting management providers registered it the following order:
* `DefaultValueSettingManagementProvider`: Gets the value from the default value of the setting definition. It can not set the default value since default values are hard-coded on the setting definition.
* `ConfigurationSettingManagementProvider`: Gets the value from the [IConfiguration service](../Configuration.md). It can not set the configuration value because it is not possible to change the configuration values on runtime.
diff --git a/docs/en/Text-Templating.md b/docs/en/Text-Templating.md
index b080087ba8..bdea7cd00b 100644
--- a/docs/en/Text-Templating.md
+++ b/docs/en/Text-Templating.md
@@ -423,7 +423,7 @@ This example simply adds a header and footer to the template and renders the con
**3)** Configure the embedded resources in the `.csproj` file
* Add [Microsoft.Extensions.FileProviders.Embedded](https://www.nuget.org/packages/Microsoft.Extensions.FileProviders.Embedded) NuGet package to the project.
-* Add `true` into the `...` section of your `.csproj` file.
+* Add `true` into the `...` section of your `.csproj` file.
* Add the following code into your `.csproj` file:
````xml
diff --git a/docs/en/UI/Angular/Authorization.md b/docs/en/UI/Angular/Authorization.md
new file mode 100644
index 0000000000..75d6107341
--- /dev/null
+++ b/docs/en/UI/Angular/Authorization.md
@@ -0,0 +1,28 @@
+# Authorization in Angular UI
+
+OAuth is preconfigured in Angular application templates. So, when you start a project using the CLI (or Suite, for that matter), authorization already works. You can find **OAuth configuration** in the _environment.ts_ files.
+
+```js
+import { Config } from '@abp/ng.core';
+
+const baseUrl = 'http://localhost:4200';
+
+export const environment = {
+ // other options removed for sake of brevity
+
+ oAuthConfig: {
+ issuer: 'https://localhost:44305',
+ redirectUri: baseUrl,
+ clientId: 'MyProjectName_App',
+ responseType: 'code',
+ scope: 'offline_access MyProjectName',
+ },
+
+ // other options removed for sake of brevity
+} as Config.Environment;
+
+```
+
+This configuration results in an [OAuth authorization code flow with PKCE](https://tools.ietf.org/html/rfc7636) and we are using [angular-oauth2-oidc library](https://github.com/manfredsteyer/angular-oauth2-oidc#logging-in) for managing OAuth in the Angular client.
+
+According to this flow, the user is redirected to an external login page which is built with MVC. So, if you need **to customize the login page**, please follow [this community article](https://community.abp.io/articles/how-to-customize-the-login-page-for-mvc-razor-page-applications-9a40f3cd).
diff --git a/docs/en/UI/Angular/Multi-Tenancy.md b/docs/en/UI/Angular/Multi-Tenancy.md
index e7e284bb0d..7622db6de0 100644
--- a/docs/en/UI/Angular/Multi-Tenancy.md
+++ b/docs/en/UI/Angular/Multi-Tenancy.md
@@ -1,4 +1,4 @@
-# Multi Tenancy in Angular UI
+# Multi-Tenancy in Angular UI
ABP Angular UI supports the multi-tenancy. The following features related to multi-tenancy are available in the startup templates.
@@ -8,7 +8,7 @@ ABP Angular UI supports the multi-tenancy. The following features related to mul
On the page above, you can;
-- See the all tenants.
+- See all tenants.
- Create a new tenant.
- Edit an existing tenant.
- Delete a tenant.
@@ -17,9 +17,11 @@ On the page above, you can;
Tenant Switching Component
-You can switch between existing tenants by using the tenant switching component in the child pages of the `AccountLayoutComponent` (like Login page). Angular UI sends the selected tenant id to the backend as `__tenant` header on each request.
+You can switch between existing tenants by using the tenant switching box in the child pages of the MVC Account Public Module (like Login page). Angular UI gets selected tenant from `application-configuration` response and sends the tenant id to the backend as `__tenant` header on each request.
-## Domain Tenant Resolver
+## Domain/Subdomain Tenant Resolver
+
+> **Note:** If you are going to implement the steps below, you should also implement the domain/subdomain tenant resolver feature for the backend. See the [Domain/Subdomain Tenant Resolver section in Multi-Tenancy document](../../Multi-Tenancy#domain-subdomain-tenant-resolver) to learn the backend implementation.
Angular UI can get the tenant name from the app running URL. You can determine the current tenant by subdomain (like mytenant1.mydomain.com) or by the whole domain (like mytenant.com). To do this, you need to set the `application.baseUrl` property in the environment:
diff --git a/docs/en/UI/Angular/Page-Alerts.md b/docs/en/UI/Angular/Page-Alerts.md
new file mode 100644
index 0000000000..e59d620432
--- /dev/null
+++ b/docs/en/UI/Angular/Page-Alerts.md
@@ -0,0 +1,64 @@
+# Page Alerts
+
+A page alert is useful for displaying an important message to the user. The ABP Framework provides an easy way to show the following alert to the user.
+
+
+
+You can simply import `PageAlertService` from `@abp/ng.theme.shared` and utilize it as follows:
+
+```typescript
+import { PageAlertService } from '@abp/ng.theme.shared';
+
+@Component({
+ // ...
+})
+export class MyComponent {
+ constructor(private service: PageAlertService) {}
+
+ showWarning() {
+ this.service.show({
+ type: 'warning',
+ message:
+ 'We will have a service interruption between 02:00 AM and 04:00 AM at October 23, 2023!',
+ title: 'Service Interruption',
+ });
+ }
+}
+```
+
+## `SHOW`
+
+The method `show` accepts a single object that is type of `PageAlert`
+
+```typescript
+export interface PageAlert {
+ type: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark';
+ message: string;
+ title?: string;
+ dismissible?: boolean;
+ messageLocalizationParams?: string[];
+ titleLocalizationParams?: string[];
+}
+```
+
+* `type` (Required): Defines what type of alert will be shown
+* `message` (Required): The message who will be shown, also works with localization as well.
+* `title` (Optional): The title of the message. If it is not provided, the title will be hidden.
+* `dismissible` (Optional): Default is `true`. If enabled, a button on the top right corner will be shown to the users so that they can dismiss the message.
+* `messageLocalizationParams` and `titleLocalizationParams` (Optional): If the message and/or the title is a key for localization service and contains some parameters, these fields could be used to pass those parameters.
+
+### An example with Localization
+
+```typescript
+this.service.show({
+ type: 'danger',
+ message: 'AbpAccount::PagerInfo{0}{1}{2}',
+ messageLocalizationParams: ['10', '20', '30'],
+ title: 'AbpAccount::EntityNotFoundErrorMessage',
+ titleLocalizationParams: ['Test', 'id123'],
+});
+```
+
+
+
+
diff --git a/docs/en/UI/Angular/Testing.md b/docs/en/UI/Angular/Testing.md
index f24ae62982..7b93d48585 100644
--- a/docs/en/UI/Angular/Testing.md
+++ b/docs/en/UI/Angular/Testing.md
@@ -1,3 +1,376 @@
-# Angular UI: Testing
+# Unit Testing Angular UI
-TODO
\ No newline at end of file
+ABP Angular UI is tested like any other Angular application. So, [the guide here](https://angular.io/guide/testing) applies to ABP too. That said, we would like to point out some **unit testing topics specific to ABP Angular applications**.
+
+## Setup
+
+In Angular, unit tests use [Karma](https://karma-runner.github.io/) and [Jasmine](https://jasmine.github.io) by default. Although we like Jest more, we chose not to deviate from these defaults, so **the application template you download will have Karma and Jasmine preconfigured**. You can find the Karma configuration inside the _karma.conf.js_ file in the root folder. You don't have to do anything. Adding a spec file and running `npm test` will work.
+
+## Basics
+
+An over-simplified spec file looks like this:
+
+```ts
+import { CoreTestingModule } from "@abp/ng.core/testing";
+import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
+import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
+import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
+import { NgxValidateCoreModule } from "@ngx-validate/core";
+import { MyComponent } from "./my.component";
+
+describe("MyComponent", () => {
+ let fixture: ComponentFixture;
+
+ beforeEach(
+ waitForAsync(() => {
+ TestBed.configureTestingModule({
+ declarations: [MyComponent],
+ imports: [
+ CoreTestingModule.withConfig(),
+ ThemeSharedTestingModule.withConfig(),
+ ThemeBasicTestingModule.withConfig(),
+ NgxValidateCoreModule,
+ ],
+ providers: [
+ /* mock providers here */
+ ],
+ }).compileComponents();
+ })
+ );
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(MyComponent);
+ fixture.detectChanges();
+ });
+
+ it("should be initiated", () => {
+ expect(fixture.componentInstance).toBeTruthy();
+ });
+});
+```
+
+If you take a look at the imports, you will notice that we have prepared some testing modules to replace built-in ABP modules. This is necessary for providing mocks for some features which otherwise would break your tests. Please remember to **use testing modules** and **call their `withConfig` static method**.
+
+## Tips
+
+### Angular Testing Library
+
+Although you can test your code with Angular TestBed, you may find [Angular Testing Library](https://testing-library.com/docs/angular-testing-library/intro) a good alternative.
+
+The simple example above can be written with Angular Testing Library as follows:
+
+```ts
+import { CoreTestingModule } from "@abp/ng.core/testing";
+import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
+import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
+import { ComponentFixture } from "@angular/core/testing";
+import { NgxValidateCoreModule } from "@ngx-validate/core";
+import { render } from "@testing-library/angular";
+import { MyComponent } from "./my.component";
+
+describe("MyComponent", () => {
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ const result = await render(MyComponent, {
+ imports: [
+ CoreTestingModule.withConfig(),
+ ThemeSharedTestingModule.withConfig(),
+ ThemeBasicTestingModule.withConfig(),
+ NgxValidateCoreModule,
+ ],
+ providers: [
+ /* mock providers here */
+ ],
+ });
+
+ fixture = result.fixture;
+ });
+
+ it("should be initiated", () => {
+ expect(fixture.componentInstance).toBeTruthy();
+ });
+});
+```
+
+Very similar, as you can see. The real difference kicks in when we use queries and fire events.
+
+```ts
+// other imports
+import { getByLabelText, screen } from "@testing-library/angular";
+import userEvent from "@testing-library/user-event";
+
+describe("MyComponent", () => {
+ beforeEach(/* removed for sake of brevity */);
+
+ it("should display advanced filters", () => {
+ const filters = screen.getByTestId("author-filters");
+ const nameInput = getByLabelText(filters, /name/i) as HTMLInputElement;
+ expect(nameInput.offsetWidth).toBe(0);
+
+ const advancedFiltersBtn = screen.getByRole("link", { name: /advanced/i });
+ userEvent.click(advancedFiltersBtn);
+
+ expect(nameInput.offsetWidth).toBeGreaterThan(0);
+
+ userEvent.type(nameInput, "fooo{backspace}");
+ expect(nameInput.value).toBe("foo");
+ });
+});
+```
+
+The **queries in Angular Testing Library follow practices for maintainable tests**, the user event package provides a **human-like interaction** with the DOM, and the library in general has **a clear API** that simplifies component testing. Please find some useful links below:
+
+- [Queries](https://testing-library.com/docs/dom-testing-library/api-queries)
+- [User Event](https://testing-library.com/docs/ecosystem-user-event)
+- [Examples](https://github.com/testing-library/angular-testing-library/tree/master/apps/example-app/app/examples)
+
+### Clearing DOM After Each Spec
+
+One thing to remember is that Karma runs tests in real browser instances. That means, you will be able to see the result of your test code, but also have problems with components attached to the document body which may not get cleared after each test, even when you configure Karma to do so.
+
+We have prepared a simple function with which you can clear any leftover DOM elements after each test.
+
+```ts
+// other imports
+import { clearPage } from "@abp/ng.core/testing";
+
+describe("MyComponent", () => {
+ let fixture: ComponentFixture;
+
+ afterEach(() => clearPage(fixture));
+
+ beforeEach(async () => {
+ const result = await render(MyComponent, {
+ /* removed for sake of brevity */
+ });
+ fixture = result.fixture;
+ });
+
+ // specs here
+});
+```
+
+Please make sure you use it because Karma will fail to remove dialogs otherwise and you will have multiple copies of modals, confirmation boxes, and alike.
+
+### Waiting
+
+Some components, modals, in particular, work off-detection-cycle. In other words, you cannot reach DOM elements inserted by these components immediately after opening them. Similarly, inserted elements are not immediately destroyed upon closing them.
+
+For this purpose, we have prepared a `wait` function.
+
+```ts
+// other imports
+import { wait } from "@abp/ng.core/testing";
+
+describe("MyComponent", () => {
+ beforeEach(/* removed for sake of brevity */);
+
+ it("should open a modal", async () => {
+ const openModalBtn = screen.getByRole("button", { name: "Open Modal" });
+ userEvent.click(openModalBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+
+ expect(modal).toBeTruthy();
+
+ /* wait again after closing the modal */
+ });
+});
+```
+
+The `wait` function takes a second parameter, i.e. timeout (default: `0`). Try not to use it though. Using a timeout bigger than `0` is usually a signal that something is not quite right.
+
+## Testing Example
+
+Here is an example test suite. It doesn't cover all, but gives quite a good idea about what the testing experience will be like.
+
+```ts
+import { clearPage, CoreTestingModule, wait } from "@abp/ng.core/testing";
+import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
+import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
+import { ComponentFixture } from "@angular/core/testing";
+import {
+ NgbCollapseModule,
+ NgbDatepickerModule,
+ NgbDropdownModule,
+} from "@ng-bootstrap/ng-bootstrap";
+import { NgxValidateCoreModule } from "@ngx-validate/core";
+import { CountryService } from "@proxy/countries";
+import {
+ findByText,
+ getByLabelText,
+ getByRole,
+ getByText,
+ queryByRole,
+ render,
+ screen,
+} from "@testing-library/angular";
+import userEvent from "@testing-library/user-event";
+import { BehaviorSubject, of } from "rxjs";
+import { CountryComponent } from "./country.component";
+
+const list$ = new BehaviorSubject({
+ items: [{ id: "ID_US", name: "United States of America" }],
+ totalCount: 1,
+});
+
+describe("Country", () => {
+ let fixture: ComponentFixture;
+
+ afterEach(() => clearPage(fixture));
+
+ beforeEach(async () => {
+ const result = await render(CountryComponent, {
+ imports: [
+ CoreTestingModule.withConfig(),
+ ThemeSharedTestingModule.withConfig(),
+ ThemeBasicTestingModule.withConfig(),
+ NgxValidateCoreModule,
+ NgbCollapseModule,
+ NgbDatepickerModule,
+ NgbDropdownModule,
+ ],
+ providers: [
+ {
+ provide: CountryService,
+ useValue: {
+ getList: () => list$,
+ },
+ },
+ ],
+ });
+
+ fixture = result.fixture;
+ });
+
+ it("should display advanced filters", () => {
+ const filters = screen.getByTestId("country-filters");
+ const nameInput = getByLabelText(filters, /name/i) as HTMLInputElement;
+ expect(nameInput.offsetWidth).toBe(0);
+
+ const advancedFiltersBtn = screen.getByRole("link", { name: /advanced/i });
+ userEvent.click(advancedFiltersBtn);
+
+ expect(nameInput.offsetWidth).toBeGreaterThan(0);
+
+ userEvent.type(nameInput, "fooo{backspace}");
+ expect(nameInput.value).toBe("foo");
+
+ userEvent.click(advancedFiltersBtn);
+ expect(nameInput.offsetWidth).toBe(0);
+ });
+
+ it("should have a heading", () => {
+ const heading = screen.getByRole("heading", { name: "Countries" });
+ expect(heading).toBeTruthy();
+ });
+
+ it("should render list in table", async () => {
+ const table = await screen.findByTestId("country-table");
+
+ const name = getByText(table, "United States of America");
+ expect(name).toBeTruthy();
+ });
+
+ it("should display edit modal", async () => {
+ const actionsBtn = screen.queryByRole("button", { name: /actions/i });
+ userEvent.click(actionsBtn);
+
+ const editBtn = screen.getByRole("button", { name: /edit/i });
+ userEvent.click(editBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+ const modalHeading = queryByRole(modal, "heading", { name: /edit/i });
+ expect(modalHeading).toBeTruthy();
+
+ const closeBtn = getByText(modal, "×");
+ userEvent.click(closeBtn);
+
+ await wait(fixture);
+
+ expect(screen.queryByRole("dialog")).toBeFalsy();
+ });
+
+ it("should display create modal", async () => {
+ const newBtn = screen.getByRole("button", { name: /new/i });
+ userEvent.click(newBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+ const modalHeading = queryByRole(modal, "heading", { name: /new/i });
+
+ expect(modalHeading).toBeTruthy();
+ });
+
+ it("should validate required name field", async () => {
+ const newBtn = screen.getByRole("button", { name: /new/i });
+ userEvent.click(newBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+ const nameInput = getByRole(modal, "textbox", {
+ name: /^name/i,
+ }) as HTMLInputElement;
+
+ userEvent.type(nameInput, "x");
+ userEvent.type(nameInput, "{backspace}");
+
+ const nameError = await findByText(modal, /required/i);
+ expect(nameError).toBeTruthy();
+ });
+
+ it("should delete a country", () => {
+ const getSpy = spyOn(fixture.componentInstance.list, "get");
+ const deleteSpy = jasmine.createSpy().and.returnValue(of(null));
+ fixture.componentInstance.service.delete = deleteSpy;
+
+ const actionsBtn = screen.queryByRole("button", { name: /actions/i });
+ userEvent.click(actionsBtn);
+
+ const deleteBtn = screen.getByRole("button", { name: /delete/i });
+ userEvent.click(deleteBtn);
+
+ const confirmText = screen.getByText("AreYouSure");
+ expect(confirmText).toBeTruthy();
+
+ const confirmBtn = screen.getByRole("button", { name: "Yes" });
+ userEvent.click(confirmBtn);
+
+ expect(deleteSpy).toHaveBeenCalledWith(list$.value.items[0].id);
+ expect(getSpy).toHaveBeenCalledTimes(1);
+ });
+});
+```
+
+## CI Configuration
+
+You would need a different configuration for your CI environment. To set up a new configuration for your unit tests, find the test project in _angular.json_ file and add one as seen below:
+
+```json
+// angular.json
+
+"test": {
+ "builder": "@angular-devkit/build-angular:karma",
+ "options": { /* several options here */ },
+ "configurations": {
+ "production": {
+ "karmaConfig": "karma.conf.prod.js"
+ }
+ }
+}
+```
+
+Now you can copy the _karma.conf.js_ as _karma.conf.prod.js_ and use any configuration you like in it. Please check [Karma configuration file document](http://karma-runner.github.io/5.2/config/configuration-file.html) for config options.
+
+Finally, don't forget to run your CI tests with the following command:
+
+```sh
+npm test -- --prod
+```
diff --git a/docs/en/UI/Angular/images/page-alert-warning-example.png b/docs/en/UI/Angular/images/page-alert-warning-example.png
new file mode 100644
index 0000000000..253a811a22
Binary files /dev/null and b/docs/en/UI/Angular/images/page-alert-warning-example.png differ
diff --git a/docs/en/UI/Angular/images/page-alert-with-params-example.png b/docs/en/UI/Angular/images/page-alert-with-params-example.png
new file mode 100644
index 0000000000..8fc5236de3
Binary files /dev/null and b/docs/en/UI/Angular/images/page-alert-with-params-example.png differ
diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json
index c7a7554fdc..517da0239f 100644
--- a/docs/en/docs-nav.json
+++ b/docs/en/docs-nav.json
@@ -740,6 +740,10 @@
{
"text": "PWA Configuration",
"path": "UI/Angular/PWA-Configuration.md"
+ },
+ {
+ "text": "Unit Testing",
+ "path": "UI/Angular/Testing.md"
}
]
},
@@ -750,6 +754,10 @@
"text": "Config State Service",
"path": "UI/Angular/Config-State-Service.md"
},
+ {
+ "text": "Authorization",
+ "path": "UI/Angular/Authorization.md"
+ },
{
"text": "HTTP Requests",
"path": "UI/Angular/HTTP-Requests.md"
@@ -814,6 +822,10 @@
{
"text": "Toast Overlay",
"path": "UI/Angular/Toaster-Service.md"
+ },
+ {
+ "text": "Page Alerts",
+ "path": "UI/Angular/Page-Alerts.md"
}
]
},
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor
index 6b93618f44..bfc970c436 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor
+++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor
@@ -21,7 +21,7 @@
private IReadOnlyList _otherLanguages;
private LanguageInfo _currentLanguage;
- protected async override Task OnInitializedAsync()
+ protected override async Task OnInitializedAsync()
{
var selectedLanguageName = await JsRuntime.InvokeAsync(
"localStorage.getItem",
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs
index 494eca34ab..3238483cfb 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs
@@ -13,7 +13,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
protected ApplicationMenu Menu { get; set; }
- protected async override Task OnInitializedAsync()
+ protected override async Task OnInitializedAsync()
{
Menu = await MenuManager.GetAsync(StandardMenus.User);
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs
index 1779d73d28..416efeffad 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs
@@ -11,7 +11,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
protected ApplicationMenu Menu { get; set; }
- protected async override Task OnInitializedAsync()
+ protected override async Task OnInitializedAsync()
{
Menu = await MenuManager.GetAsync(StandardMenus.Main);
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs
index 33044282f9..6fddf263b3 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs
@@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
private List ToolbarItemRenders { get; set; } = new List();
- protected async override Task OnInitializedAsync()
+ protected override async Task OnInitializedAsync()
{
var toolbar = await ToolbarManager.GetAsync(StandardToolbars.Main);
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Toolbars/ToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Toolbars/ToolbarConfigurationContext.cs
index 7174dbe431..4e30a50206 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Toolbars/ToolbarConfigurationContext.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/Toolbars/ToolbarConfigurationContext.cs
@@ -4,35 +4,19 @@ using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
+using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Toolbars
{
public class ToolbarConfigurationContext : IToolbarConfigurationContext
{
public IServiceProvider ServiceProvider { get; }
- private readonly object _serviceProviderLock = new object();
- private TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (_serviceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
-
- return reference;
- }
+ private readonly IAbpLazyServiceProvider _lazyServiceProvider;
- public IAuthorizationService AuthorizationService => LazyGetRequiredService(typeof(IAuthorizationService), ref _authorizationService);
- private IAuthorizationService _authorizationService;
+ public IAuthorizationService AuthorizationService => _lazyServiceProvider.LazyGetRequiredService();
- private IStringLocalizerFactory _stringLocalizerFactory;
- public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(typeof(IStringLocalizerFactory),ref _stringLocalizerFactory);
+ public IStringLocalizerFactory StringLocalizerFactory => _lazyServiceProvider.LazyGetRequiredService();
public Toolbar Toolbar { get; }
@@ -40,6 +24,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Toolbars
{
Toolbar = toolbar;
ServiceProvider = serviceProvider;
+ _lazyServiceProvider = ServiceProvider.GetRequiredService();
}
public Task IsGrantedAsync(string policyName)
diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs
index 7fa2038020..255e0ac89b 100644
--- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs
+++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs
@@ -25,7 +25,12 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext)
{
- var hostName = httpContext.Request.Host.Host.RemovePreFix(ProtocolPrefixes);
+ if (!httpContext.Request.Host.HasValue)
+ {
+ return Task.FromResult(null);
+ }
+
+ var hostName = httpContext.Request.Host.Value.RemovePreFix(ProtocolPrefixes);
var extractResult = FormattedStringValueExtracter.Extract(hostName, _domainFormat, ignoreCase: true);
context.Handled = true;
diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs
index 868ef78519..77c12bef7b 100644
--- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs
+++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/FormTenantResolveContributor.cs
@@ -11,7 +11,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
public override string Name => ContributorName;
- protected async override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext)
+ protected override async Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext)
{
if (!httpContext.Request.HasFormContentType)
{
diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs
index 18f76ee711..3b454b5ef9 100644
--- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs
+++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributerBase.cs
@@ -10,7 +10,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
{
public abstract class HttpTenantResolveContributorBase : TenantResolveContributorBase
{
- public async override Task ResolveAsync(ITenantResolveContext context)
+ public override async Task ResolveAsync(ITenantResolveContext context)
{
var httpContext = context.GetHttpContext();
if (httpContext == null)
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo.Abp.AspNetCore.Mvc.Client.Common.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo.Abp.AspNetCore.Mvc.Client.Common.csproj
index dc672d842f..b509a5df59 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo.Abp.AspNetCore.Mvc.Client.Common.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo.Abp.AspNetCore.Mvc.Client.Common.csproj
@@ -16,7 +16,9 @@
+
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientCommonModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientCommonModule.cs
index de5e80ff64..b37c9d57fd 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientCommonModule.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientCommonModule.cs
@@ -1,5 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.Authorization;
using Volo.Abp.Caching;
+using Volo.Abp.Features;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
@@ -10,7 +12,9 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
typeof(AbpHttpClientModule),
typeof(AbpAspNetCoreMvcContractsModule),
typeof(AbpCachingModule),
- typeof(AbpLocalizationModule)
+ typeof(AbpLocalizationModule),
+ typeof(AbpAuthorizationModule),
+ typeof(AbpFeaturesModule)
)]
public class AbpAspNetCoreMvcClientCommonModule : AbpModule
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs
index 4cba01bea2..f769f512a5 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs
@@ -13,7 +13,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
ConfigurationClient = configurationClient;
}
- public async override Task GetOrNullAsync(string name)
+ public override async Task GetOrNullAsync(string name)
{
var configuration = await ConfigurationClient.GetAsync();
return configuration.Features.Values.GetOrDefault(name);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo.Abp.AspNetCore.Mvc.Client.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo.Abp.AspNetCore.Mvc.Client.csproj
index 3657e27fef..aae260d7e8 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo.Abp.AspNetCore.Mvc.Client.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo.Abp.AspNetCore.Mvc.Client.csproj
@@ -18,6 +18,7 @@
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs
index 1186b48ae7..48e2461167 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/AbpAspNetCoreMvcClientModule.cs
@@ -1,9 +1,11 @@
-using Volo.Abp.Modularity;
+using Volo.Abp.EventBus;
+using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc.Client
{
[DependsOn(
- typeof(AbpAspNetCoreMvcClientCommonModule)
+ typeof(AbpAspNetCoreMvcClientCommonModule),
+ typeof(AbpEventBusModule)
)]
public class AbpAspNetCoreMvcClientModule : AbpModule
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs
index a6a4d33668..4f5b7c84b0 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs
@@ -56,7 +56,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
async () => await Proxy.Service.GetAsync(),
() => new DistributedCacheEntryOptions
{
- AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(120) //TODO: Should be configurable. Default value should be higher (5 mins would be good).
+ AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable.
}
);
@@ -83,7 +83,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
protected virtual string CreateCacheKey()
{
- return $"ApplicationConfiguration_{CurrentUser.Id?.ToString("N") ?? "Anonymous"}_{CultureInfo.CurrentUICulture.Name}";
+ return MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser);
}
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs
new file mode 100644
index 0000000000..4b4a0e6301
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs
@@ -0,0 +1,13 @@
+using System.Globalization;
+using Volo.Abp.Users;
+
+namespace Volo.Abp.AspNetCore.Mvc.Client
+{
+ internal static class MvcCachedApplicationConfigurationClientHelper
+ {
+ public static string CreateCacheKey(ICurrentUser currentUser)
+ {
+ return $"ApplicationConfiguration_{currentUser.Id?.ToString("N") ?? "Anonymous"}_{CultureInfo.CurrentUICulture.Name}";
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCurrentApplicationConfigurationCacheResetEventHandler.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCurrentApplicationConfigurationCacheResetEventHandler.cs
new file mode 100644
index 0000000000..e8f5b201da
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCurrentApplicationConfigurationCacheResetEventHandler.cs
@@ -0,0 +1,34 @@
+using System.Threading.Tasks;
+using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
+using Volo.Abp.Caching;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.EventBus;
+using Volo.Abp.Users;
+
+namespace Volo.Abp.AspNetCore.Mvc.Client
+{
+ public class MvcCurrentApplicationConfigurationCacheResetEventHandler :
+ ILocalEventHandler,
+ ITransientDependency
+ {
+ protected ICurrentUser CurrentUser { get; }
+ protected IDistributedCache Cache { get; }
+
+ public MvcCurrentApplicationConfigurationCacheResetEventHandler(ICurrentUser currentUser,
+ IDistributedCache cache)
+ {
+ CurrentUser = currentUser;
+ Cache = cache;
+ }
+
+ public virtual async Task HandleEventAsync(CurrentApplicationConfigurationCacheResetEventData eventData)
+ {
+ await Cache.RemoveAsync(CreateCacheKey());
+ }
+
+ protected virtual string CreateCacheKey()
+ {
+ return MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser);
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo.Abp.AspNetCore.Mvc.Contracts.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo.Abp.AspNetCore.Mvc.Contracts.csproj
index 04b2e7ec59..7a5da3dca7 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo.Abp.AspNetCore.Mvc.Contracts.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo.Abp.AspNetCore.Mvc.Contracts.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcContractsModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcContractsModule.cs
index 54a7589dd4..3bf299437c 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcContractsModule.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcContractsModule.cs
@@ -4,7 +4,7 @@ using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc
{
[DependsOn(
- typeof(AbpDddApplicationModule)
+ typeof(AbpDddApplicationContractsModule)
)]
public class AbpAspNetCoreMvcContractsModule : AbpModule
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentApplicationConfigurationCacheResetEventData.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentApplicationConfigurationCacheResetEventData.cs
new file mode 100644
index 0000000000..e84e96d9dd
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentApplicationConfigurationCacheResetEventData.cs
@@ -0,0 +1,10 @@
+namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
+{
+ ///
+ /// This event is used to invalidate current user's cached configuration.
+ ///
+ public class CurrentApplicationConfigurationCacheResetEventData
+ {
+
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelperService.cs
index e1b4469f8c..4b433ac495 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelperService.cs
@@ -8,7 +8,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb
{
public class AbpBreadcrumbTagHelperService : AbpTagHelperService
{
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "nav";
output.Attributes.Add("aria-label", "breadcrumb");
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelperService.cs
index e4a277ba66..c3672db7f5 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelperService.cs
@@ -19,7 +19,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel
L = localizer;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "div";
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs
index f9e019391f..6afb918704 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs
@@ -9,7 +9,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
{
public class AbpAccordionItemTagHelperService : AbpTagHelperService
{
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
SetRandomIdIfNotProvided();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelperService.cs
index 7651309e1a..d55bb04d21 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelperService.cs
@@ -17,7 +17,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
HtmlGenerator = htmlGenerator;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
SetRandomIdIfNotProvided();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs
index 198c5b91e6..3c429b32ef 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs
@@ -6,7 +6,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
{
public class AbpCollapseBodyTagHelperService : AbpTagHelperService
{
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "div";
output.Attributes.AddClass("collapse");
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs
index 52ea6ace85..c6a0307d2d 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs
@@ -24,7 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown
_serviceProvider = serviceProvider;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var content = await output.GetChildContentAsync();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
index da622b968b..7d2f0804b7 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
@@ -36,7 +36,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
_localizer = localizer;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var list = InitilizeFormGroupContentsContext(context, output);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
index 246c611533..48abbd93e9 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
@@ -26,7 +26,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
_tagHelperLocalizer = tagHelperLocalizer;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var (innerHtml, isCheckBox) = await GetFormInputGroupAsHtmlAsync(context, output);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
index dde58ed3e4..6050fb91d6 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
@@ -36,7 +36,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
_stringLocalizerFactory = stringLocalizerFactory;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var innerHtml = await GetFormInputGroupAsHtmlAsync(context, output);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalTagHelperService.cs
index aa83265e94..5bc2330bf1 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Modal/AbpModalTagHelperService.cs
@@ -8,7 +8,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
{
public class AbpModalTagHelperService : AbpTagHelperService
{
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = null;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs
index 148f196aad..cb1e395f40 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs
@@ -32,7 +32,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
_stringLocalizerFactory = stringLocalizerFactory;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (TagHelper.Model.ShownItemsCount <= 0)
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabDropdownTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabDropdownTagHelperService.cs
index 02810e9666..726a947be2 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabDropdownTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabDropdownTagHelperService.cs
@@ -9,7 +9,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
{
public class AbpTabDropdownTagHelperService : AbpTagHelperService
{
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (string.IsNullOrWhiteSpace(TagHelper.Name))
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs
index db05c5c686..a9a134ceba 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs
@@ -9,7 +9,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
{
public class AbpTabTagHelperService : AbpTagHelperService
{
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
SetPlaceholderForNameIfNotProvided();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabsTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabsTagHelperService.cs
index 8046af8ccd..92e50990a4 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabsTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabsTagHelperService.cs
@@ -20,7 +20,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
HtmlGenerator = htmlGenerator;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
SetRandomNameIfNotProvided();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs
index 98fe3546c5..00c3762ed9 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
+using Volo.Abp.DependencyInjection;
using Volo.Abp.Localization;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
@@ -13,35 +14,18 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
public IFileProvider FileProvider { get; }
+ public IServiceProvider ServiceProvider { get; }
+
+ private readonly IAbpLazyServiceProvider _lazyServiceProvider;
+
public BundleConfigurationContext(IServiceProvider serviceProvider, IFileProvider fileProvider)
{
Files = new List();
ServiceProvider = serviceProvider;
+ _lazyServiceProvider = ServiceProvider.GetRequiredService();
FileProvider = fileProvider;
}
- public IServiceProvider ServiceProvider { get; }
- private readonly object _serviceProviderLock = new object();
-
- private TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (_serviceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
-
- return reference;
- }
-
- private IOptions _abpLocalizationOptions;
-
- public AbpLocalizationOptions LocalizationOptions =>
- LazyGetRequiredService(typeof(IOptions), ref _abpLocalizationOptions).Value;
+ public AbpLocalizationOptions LocalizationOptions => _lazyServiceProvider.LazyGetRequiredService>().Value;
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelperService.cs
index 0ffb5b9049..eca80c5fcf 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelperService.cs
@@ -16,7 +16,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
ResourceService = resourceService;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var tagHelperItems = context.Items.GetOrDefault(AbpTagHelperConsts.ContextBundleItemListKey) as List;
if (tagHelperItems != null)
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleTagHelperService.cs
index 9158f33b90..f0c76d5cc4 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleTagHelperService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleTagHelperService.cs
@@ -16,7 +16,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
ResourceService = resourceService;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
await ResourceService.ProcessAsync(
TagHelper.ViewContext,
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs
index 9e4e77a6dd..6efbb793e7 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs
@@ -38,7 +38,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
);
}
- protected async override Task> GetBundleFilesAsync(string bundleName)
+ protected override async Task> GetBundleFilesAsync(string bundleName)
{
return await BundleManager.GetScriptBundleFilesAsync(bundleName);
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs
index a9d9b54fca..8612e4f8b4 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs
@@ -38,7 +38,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
);
}
- protected async override Task> GetBundleFilesAsync(string bundleName)
+ protected override async Task> GetBundleFilesAsync(string bundleName)
{
return await BundleManager.GetStyleBundleFilesAsync(bundleName);
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs
index 9a16b4b43a..328024cc2b 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs
@@ -28,7 +28,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.S
_guidGenerator = guidGenerator;
}
- public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
+ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.TagName = null;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs
index 37f3308198..7ae40af60f 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarConfigurationContext.cs
@@ -5,35 +5,19 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theming;
+using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars
{
public class ToolbarConfigurationContext : IToolbarConfigurationContext
{
public IServiceProvider ServiceProvider { get; }
- private readonly object _serviceProviderLock = new object();
- private TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (_serviceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
-
- return reference;
- }
+ private readonly IAbpLazyServiceProvider _lazyServiceProvider;
- public IAuthorizationService AuthorizationService => LazyGetRequiredService(typeof(IAuthorizationService), ref _authorizationService);
- private IAuthorizationService _authorizationService;
+ public IAuthorizationService AuthorizationService => _lazyServiceProvider.LazyGetRequiredService();
- private IStringLocalizerFactory _stringLocalizerFactory;
- public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(typeof(IStringLocalizerFactory),ref _stringLocalizerFactory);
+ public IStringLocalizerFactory StringLocalizerFactory => _lazyServiceProvider.LazyGetRequiredService();
public ITheme Theme { get; }
@@ -44,8 +28,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars
Theme = currentTheme;
Toolbar = toolbar;
ServiceProvider = serviceProvider;
+ _lazyServiceProvider = ServiceProvider.GetRequiredService();
}
-
+
public Task IsGrantedAsync(string policyName)
{
return AuthorizationService.IsGrantedAsync(policyName);
@@ -62,7 +47,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars
{
return StringLocalizerFactory.Create();
}
-
+
[NotNull]
public IStringLocalizer GetLocalizer(Type resourceType)
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs
index fcbe9af59c..449747d0cc 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs
@@ -10,6 +10,7 @@ using System;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.UI.Alerts;
using Volo.Abp.AspNetCore.Mvc.Validation;
+using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
@@ -24,67 +25,27 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages
{
public abstract class AbpPageModel : PageModel
{
- public IServiceProvider ServiceProvider { get; set; }
- protected readonly object ServiceProviderLock = new object();
-
- protected TService LazyGetRequiredService(ref TService reference)
- => LazyGetRequiredService(typeof(TService), ref reference);
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
- protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (ServiceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
-
- return reference;
- }
+ public IServiceProvider ServiceProvider { get; set; }
- protected IClock Clock => LazyGetRequiredService(ref _clock);
- private IClock _clock;
+ protected IClock Clock => LazyServiceProvider.LazyGetRequiredService();
protected AlertList Alerts => AlertManager.Alerts;
- protected IUnitOfWorkManager UnitOfWorkManager => LazyGetRequiredService(ref _unitOfWorkManager);
- private IUnitOfWorkManager _unitOfWorkManager;
+ protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService();
protected Type ObjectMapperContext { get; set; }
- protected IObjectMapper ObjectMapper
- {
- get
- {
- if (_objectMapper != null)
- {
- return _objectMapper;
- }
-
- if (ObjectMapperContext == null)
- {
- return LazyGetRequiredService(ref _objectMapper);
- }
-
- return LazyGetRequiredService(
- typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext),
- ref _objectMapper
- );
- }
- }
- private IObjectMapper _objectMapper;
+ protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService(provider =>
+ ObjectMapperContext == null
+ ? provider.GetRequiredService()
+ : (IObjectMapper) provider.GetRequiredService(typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext)));
- protected IGuidGenerator GuidGenerator => LazyGetRequiredService(ref _guidGenerator);
- private IGuidGenerator _guidGenerator;
+ protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
- protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory);
- private ILoggerFactory _loggerFactory;
+ protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService();
- protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory);
- private IStringLocalizerFactory _stringLocalizerFactory;
+ protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetRequiredService();
protected IStringLocalizer L
{
@@ -103,31 +64,23 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages
protected Type LocalizationResourceType { get; set; }
- protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser);
- private ICurrentUser _currentUser;
+ protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService();
- protected ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant);
- private ICurrentTenant _currentTenant;
+ protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService();
- protected ISettingProvider SettingProvider => LazyGetRequiredService(ref _settingProvider);
- private ISettingProvider _settingProvider;
+ protected ISettingProvider SettingProvider => LazyServiceProvider.LazyGetRequiredService();
- protected IModelStateValidator ModelValidator => LazyGetRequiredService(ref _modelValidator);
- private IModelStateValidator _modelValidator;
+ protected IModelStateValidator ModelValidator => LazyServiceProvider.LazyGetRequiredService();
- protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService);
- private IAuthorizationService _authorizationService;
+ protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService();
- protected IAlertManager AlertManager => LazyGetRequiredService(ref _alertManager);
- private IAlertManager _alertManager;
+ protected IAlertManager AlertManager => LazyServiceProvider.LazyGetRequiredService();
protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current;
- protected ILogger Logger => _lazyLogger.Value;
- private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true);
+ protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
- protected IAppUrlProvider AppUrlProvider => LazyGetRequiredService(ref _appUrlProvider);
- private IAppUrlProvider _appUrlProvider;
+ protected IAppUrlProvider AppUrlProvider => LazyServiceProvider.LazyGetRequiredService();
protected virtual NoContentResult NoContent() //TODO: Is that true to return empty result like that?
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
index d0806d929d..81c4a3e7e6 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj
@@ -21,6 +21,7 @@
+
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs
new file mode 100644
index 0000000000..07b54cc5df
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpActionContextExtensions.cs
@@ -0,0 +1,20 @@
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Volo.Abp.AspNetCore.Mvc
+{
+ internal static class AbpActionContextExtensions
+ {
+ public static T GetRequiredService(this FilterContext context)
+ where T : class
+ {
+ return context.HttpContext.RequestServices.GetRequiredService();
+ }
+
+ public static T GetService(this FilterContext context, T defaultValue = default)
+ where T : class
+ {
+ return context.HttpContext.RequestServices.GetService() ?? defaultValue;
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
index e5edd9662d..0c2e9345e6 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs
@@ -22,6 +22,7 @@ using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
using Volo.Abp.ApiVersioning;
+using Volo.Abp.Application;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.AspNetCore.Mvc.ApiExploring;
using Volo.Abp.AspNetCore.Mvc.Conventions;
@@ -49,7 +50,8 @@ namespace Volo.Abp.AspNetCore.Mvc
typeof(AbpApiVersioningAbstractionsModule),
typeof(AbpAspNetCoreMvcContractsModule),
typeof(AbpUiNavigationModule),
- typeof(AbpGlobalFeaturesModule)
+ typeof(AbpGlobalFeaturesModule),
+ typeof(AbpDddApplicationModule)
)]
public class AbpAspNetCoreMvcModule : AbpModule
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
index f83353092e..52f1d251cb 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Aspects;
using Volo.Abp.AspNetCore.Mvc.Validation;
+using Volo.Abp.DependencyInjection;
using Volo.Abp.Features;
using Volo.Abp.Guids;
using Volo.Abp.Localization;
@@ -22,85 +23,41 @@ namespace Volo.Abp.AspNetCore.Mvc
{
public abstract class AbpController : Controller, IAvoidDuplicateCrossCuttingConcerns
{
- public IServiceProvider ServiceProvider { get; set; }
- protected readonly object ServiceProviderLock = new object();
-
- protected TService LazyGetRequiredService(ref TService reference)
- => LazyGetRequiredService(typeof(TService), ref reference);
-
- protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (ServiceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
- return reference;
- }
+ public IServiceProvider ServiceProvider { get; set; }
- protected IUnitOfWorkManager UnitOfWorkManager => LazyGetRequiredService(ref _unitOfWorkManager);
- private IUnitOfWorkManager _unitOfWorkManager;
+ protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService();
protected Type ObjectMapperContext { get; set; }
- protected IObjectMapper ObjectMapper
- {
- get
- {
- if (_objectMapper != null)
- {
- return _objectMapper;
- }
+ protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService(provider =>
+ ObjectMapperContext == null
+ ? provider.GetRequiredService()
+ : (IObjectMapper) provider.GetRequiredService(typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext)));
- if (ObjectMapperContext == null)
- {
- return LazyGetRequiredService(ref _objectMapper);
- }
+ protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
- return LazyGetRequiredService(
- typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext),
- ref _objectMapper
- );
- }
- }
- private IObjectMapper _objectMapper;
-
- protected IGuidGenerator GuidGenerator => LazyGetRequiredService(ref _guidGenerator);
- private IGuidGenerator _guidGenerator;
-
- protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory);
- private ILoggerFactory _loggerFactory;
+ protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService();
- protected ILogger Logger => _lazyLogger.Value;
- private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true);
+ protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
- protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser);
- private ICurrentUser _currentUser;
+ protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService();
- protected ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant);
- private ICurrentTenant _currentTenant;
+ protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService();
- protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService);
- private IAuthorizationService _authorizationService;
+ protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetRequiredService();
protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current;
- protected IClock Clock => LazyGetRequiredService(ref _clock);
- private IClock _clock;
+ protected IClock Clock => LazyServiceProvider.LazyGetRequiredService();
- protected IModelStateValidator ModelValidator => LazyGetRequiredService(ref _modelValidator);
- private IModelStateValidator _modelValidator;
+ protected IModelStateValidator ModelValidator => LazyServiceProvider.LazyGetRequiredService();
- protected IFeatureChecker FeatureChecker => LazyGetRequiredService(ref _featureChecker);
- private IFeatureChecker _featureChecker;
+ protected IFeatureChecker FeatureChecker => LazyServiceProvider.LazyGetRequiredService();
- protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory);
- private IStringLocalizerFactory _stringLocalizerFactory;
+ protected IAppUrlProvider AppUrlProvider => LazyServiceProvider.LazyGetRequiredService();
+
+ protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetRequiredService();
protected IStringLocalizer L
{
@@ -116,9 +73,6 @@ namespace Volo.Abp.AspNetCore.Mvc
}
private IStringLocalizer _localizer;
- protected IAppUrlProvider AppUrlProvider => LazyGetRequiredService(ref _appUrlProvider);
- private IAppUrlProvider _appUrlProvider;
-
protected Type LocalizationResource
{
get => _localizationResource;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
index 2c0e38c13c..2ac02b8ac5 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
@@ -1,55 +1,22 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping;
namespace Volo.Abp.AspNetCore.Mvc
{
public abstract class AbpViewComponent : ViewComponent
{
- public IServiceProvider ServiceProvider { get; set; }
- protected readonly object ServiceProviderLock = new object();
-
- protected TService LazyGetRequiredService(ref TService reference)
- => LazyGetRequiredService(typeof(TService), ref reference);
-
- protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (ServiceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
- return reference;
- }
+ public IServiceProvider ServiceProvider { get; set; }
protected Type ObjectMapperContext { get; set; }
- protected IObjectMapper ObjectMapper
- {
- get
- {
- if (_objectMapper != null)
- {
- return _objectMapper;
- }
-
- if (ObjectMapperContext == null)
- {
- return LazyGetRequiredService(ref _objectMapper);
- }
- return LazyGetRequiredService(
- typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext),
- ref _objectMapper
- );
- }
- }
- private IObjectMapper _objectMapper;
+ protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService(provider =>
+ ObjectMapperContext == null
+ ? provider.GetRequiredService()
+ : (IObjectMapper) provider.GetRequiredService(typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext)));
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs
index 0ee62f9b65..33db273c07 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs
@@ -12,17 +12,6 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
{
public class AbpAuditActionFilter : IAsyncActionFilter, ITransientDependency
{
- protected AbpAuditingOptions Options { get; }
- private readonly IAuditingHelper _auditingHelper;
- private readonly IAuditingManager _auditingManager;
-
- public AbpAuditActionFilter(IOptions options, IAuditingHelper auditingHelper, IAuditingManager auditingManager)
- {
- Options = options.Value;
- _auditingHelper = auditingHelper;
- _auditingManager = auditingManager;
- }
-
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (!ShouldSaveAudit(context, out var auditLog, out var auditLogAction))
@@ -63,7 +52,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
auditLog = null;
auditLogAction = null;
- if (!Options.IsEnabled)
+ var options = context.GetRequiredService>().Value;
+ if (!options.IsEnabled)
{
return false;
}
@@ -73,19 +63,20 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
return false;
}
- var auditLogScope = _auditingManager.Current;
+ var auditLogScope = context.GetRequiredService().Current;
if (auditLogScope == null)
{
return false;
}
- if (!_auditingHelper.ShouldSaveAudit(context.ActionDescriptor.GetMethodInfo(), true))
+ var auditingHelper = context.GetRequiredService();
+ if (!auditingHelper.ShouldSaveAudit(context.ActionDescriptor.GetMethodInfo(), true))
{
return false;
}
auditLog = auditLogScope.Log;
- auditLogAction = _auditingHelper.CreateAuditLogAction(
+ auditLogAction = auditingHelper.CreateAuditLogAction(
auditLog,
context.ActionDescriptor.AsControllerActionDescriptor().ControllerTypeInfo.AsType(),
context.ActionDescriptor.AsControllerActionDescriptor().MethodInfo,
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs
index 6e9996574c..cc12120280 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditPageFilter.cs
@@ -12,22 +12,11 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
{
public class AbpAuditPageFilter : IAsyncPageFilter, ITransientDependency
{
- protected AbpAuditingOptions Options { get; }
- private readonly IAuditingHelper _auditingHelper;
- private readonly IAuditingManager _auditingManager;
-
- public AbpAuditPageFilter(IOptions options, IAuditingHelper auditingHelper, IAuditingManager auditingManager)
- {
- Options = options.Value;
- _auditingHelper = auditingHelper;
- _auditingManager = auditingManager;
- }
-
public Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context)
{
return Task.CompletedTask;
}
-
+
public async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next)
{
if (context.HandlerMethod == null || !ShouldSaveAudit(context, out var auditLog, out var auditLogAction))
@@ -68,7 +57,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
auditLog = null;
auditLogAction = null;
- if (!Options.IsEnabled)
+ var options = context.GetRequiredService>().Value;
+ if (!options.IsEnabled)
{
return false;
}
@@ -78,19 +68,20 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
return false;
}
- var auditLogScope = _auditingManager.Current;
+ var auditLogScope = context.GetRequiredService().Current;
if (auditLogScope == null)
{
return false;
}
- if (!_auditingHelper.ShouldSaveAudit(context.HandlerMethod.MethodInfo, true))
+ var auditingHelper = context.GetRequiredService();
+ if (!auditingHelper.ShouldSaveAudit(context.HandlerMethod.MethodInfo, true))
{
return false;
}
auditLog = auditLogScope.Log;
- auditLogAction = _auditingHelper.CreateAuditLogAction(
+ auditLogAction = auditingHelper.CreateAuditLogAction(
auditLog,
context.HandlerMethod.GetType(),
context.HandlerMethod.MethodInfo,
@@ -100,4 +91,4 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs
index d3ecfaff27..706e514254 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs
@@ -18,7 +18,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Content
return typeof(IRemoteStreamContent).IsAssignableFrom(type);
}
- public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
+ public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
{
var remoteStream = (IRemoteStreamContent)context.Object;
using (var stream = remoteStream.GetStream())
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs
index c6f353b876..6c447bc893 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionFilter.cs
@@ -1,11 +1,10 @@
-using System;
+using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
@@ -19,27 +18,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
{
public class AbpExceptionFilter : IAsyncExceptionFilter, ITransientDependency
{
- public ILogger Logger { get; set; }
-
- private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
- private readonly IHttpExceptionStatusCodeFinder _statusCodeFinder;
- private readonly IJsonSerializer _jsonSerializer;
- private readonly AbpExceptionHandlingOptions _exceptionHandlingOptions;
-
- public AbpExceptionFilter(
- IExceptionToErrorInfoConverter errorInfoConverter,
- IHttpExceptionStatusCodeFinder statusCodeFinder,
- IJsonSerializer jsonSerializer,
- IOptions exceptionHandlingOptions)
- {
- _errorInfoConverter = errorInfoConverter;
- _statusCodeFinder = statusCodeFinder;
- _jsonSerializer = jsonSerializer;
- _exceptionHandlingOptions = exceptionHandlingOptions.Value;
-
- Logger = NullLogger.Instance;
- }
-
public async Task OnExceptionAsync(ExceptionContext context)
{
if (!ShouldHandleException(context))
@@ -78,9 +56,13 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
//TODO: Trigger an AbpExceptionHandled event or something like that.
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
- context.HttpContext.Response.StatusCode = (int)_statusCodeFinder.GetStatusCode(context.HttpContext, context.Exception);
+ context.HttpContext.Response.StatusCode = (int) context
+ .GetRequiredService()
+ .GetStatusCode(context.HttpContext, context.Exception);
- var remoteServiceErrorInfo = _errorInfoConverter.Convert(context.Exception, _exceptionHandlingOptions.SendExceptionsDetailsToClients);
+ var exceptionHandlingOptions = context.GetRequiredService>().Value;
+ var exceptionToErrorInfoConverter = context.GetRequiredService();
+ var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, exceptionHandlingOptions.SendExceptionsDetailsToClients);
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
@@ -88,17 +70,15 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
var remoteServiceErrorInfoBuilder = new StringBuilder();
remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
- remoteServiceErrorInfoBuilder.AppendLine( _jsonSerializer.Serialize(remoteServiceErrorInfo, indented: true));
- Logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
+ remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true));
+
+ var logger = context.GetService>(NullLogger.Instance);
+
+ logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
- Logger.LogException(context.Exception, logLevel);
+ logger.LogException(context.Exception, logLevel);
- await context.HttpContext
- .RequestServices
- .GetRequiredService()
- .NotifyAsync(
- new ExceptionNotificationContext(context.Exception)
- );
+ await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception));
context.Exception = null; //Handled!
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs
index 9ef0378909..f3666d2f91 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/AbpExceptionPageFilter.cs
@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
@@ -19,27 +18,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
{
public class AbpExceptionPageFilter : IAsyncPageFilter, ITransientDependency
{
- public ILogger Logger { get; set; }
-
- private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
- private readonly IHttpExceptionStatusCodeFinder _statusCodeFinder;
- private readonly IJsonSerializer _jsonSerializer;
- private readonly AbpExceptionHandlingOptions _exceptionHandlingOptions;
-
- public AbpExceptionPageFilter(
- IExceptionToErrorInfoConverter errorInfoConverter,
- IHttpExceptionStatusCodeFinder statusCodeFinder,
- IJsonSerializer jsonSerializer,
- IOptions exceptionHandlingOptions)
- {
- _errorInfoConverter = errorInfoConverter;
- _statusCodeFinder = statusCodeFinder;
- _jsonSerializer = jsonSerializer;
- _exceptionHandlingOptions = exceptionHandlingOptions.Value;
-
- Logger = NullLogger.Instance;
- }
-
public Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context)
{
return Task.CompletedTask;
@@ -90,9 +68,13 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
//TODO: Trigger an AbpExceptionHandled event or something like that.
context.HttpContext.Response.Headers.Add(AbpHttpConsts.AbpErrorFormat, "true");
- context.HttpContext.Response.StatusCode = (int)_statusCodeFinder.GetStatusCode(context.HttpContext, context.Exception);
+ context.HttpContext.Response.StatusCode = (int) context
+ .GetRequiredService()
+ .GetStatusCode(context.HttpContext, context.Exception);
- var remoteServiceErrorInfo = _errorInfoConverter.Convert(context.Exception, _exceptionHandlingOptions.SendExceptionsDetailsToClients);
+ var exceptionHandlingOptions = context.GetRequiredService>().Value;
+ var exceptionToErrorInfoConverter = context.GetRequiredService();
+ var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, exceptionHandlingOptions.SendExceptionsDetailsToClients);
context.Result = new ObjectResult(new RemoteServiceErrorResponse(remoteServiceErrorInfo));
@@ -100,17 +82,14 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
var remoteServiceErrorInfoBuilder = new StringBuilder();
remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
- remoteServiceErrorInfoBuilder.AppendLine( _jsonSerializer.Serialize(remoteServiceErrorInfo, indented: true));
- Logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
+ remoteServiceErrorInfoBuilder.AppendLine(context.GetRequiredService().Serialize(remoteServiceErrorInfo, indented: true));
+
+ var logger = context.GetService>(NullLogger.Instance);
+ logger.LogWithLevel(logLevel, remoteServiceErrorInfoBuilder.ToString());
- Logger.LogException(context.Exception, logLevel);
+ logger.LogException(context.Exception, logLevel);
- await context.HttpContext
- .RequestServices
- .GetRequiredService()
- .NotifyAsync(
- new ExceptionNotificationContext(context.Exception)
- );
+ await context.GetRequiredService().NotifyAsync(new ExceptionNotificationContext(context.Exception));
context.Exception = null; //Handled!
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeatureActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeatureActionFilter.cs
index 577acda339..2d468b30d9 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeatureActionFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeatureActionFilter.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc.Filters;
-using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Volo.Abp.Aspects;
@@ -10,16 +9,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Features
{
public class AbpFeatureActionFilter : IAsyncActionFilter, ITransientDependency
{
- private readonly IMethodInvocationFeatureCheckerService _methodInvocationAuthorizationService;
-
- public AbpFeatureActionFilter(IMethodInvocationFeatureCheckerService methodInvocationAuthorizationService)
- {
- _methodInvocationAuthorizationService = methodInvocationAuthorizationService;
- }
-
- public async Task OnActionExecutionAsync(
- ActionExecutingContext context,
- ActionExecutionDelegate next)
+ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (!context.ActionDescriptor.IsControllerAction())
{
@@ -31,9 +21,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Features
using (AbpCrossCuttingConcerns.Applying(context.Controller, AbpCrossCuttingConcerns.FeatureChecking))
{
- await _methodInvocationAuthorizationService.CheckAsync(
- new MethodInvocationFeatureCheckerContext(methodInfo)
- );
+ var methodInvocationFeatureCheckerService = context.GetRequiredService();
+ await methodInvocationFeatureCheckerService.CheckAsync(new MethodInvocationFeatureCheckerContext(methodInfo));
await next();
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeaturePageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeaturePageFilter.cs
index 83e26ace9c..913716ab33 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeaturePageFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeaturePageFilter.cs
@@ -9,18 +9,11 @@ namespace Volo.Abp.AspNetCore.Mvc.Features
{
public class AbpFeaturePageFilter : IAsyncPageFilter, ITransientDependency
{
- private readonly IMethodInvocationFeatureCheckerService _methodInvocationAuthorizationService;
-
- public AbpFeaturePageFilter(IMethodInvocationFeatureCheckerService methodInvocationAuthorizationService)
- {
- _methodInvocationAuthorizationService = methodInvocationAuthorizationService;
- }
-
public Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context)
{
return Task.CompletedTask;
}
-
+
public async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next)
{
if (context.HandlerMethod == null || !context.ActionDescriptor.IsPageAction())
@@ -33,12 +26,11 @@ namespace Volo.Abp.AspNetCore.Mvc.Features
using (AbpCrossCuttingConcerns.Applying(context.HandlerInstance, AbpCrossCuttingConcerns.FeatureChecking))
{
- await _methodInvocationAuthorizationService.CheckAsync(
- new MethodInvocationFeatureCheckerContext(methodInfo)
- );
+ var methodInvocationFeatureCheckerService = context.GetRequiredService();
+ await methodInvocationFeatureCheckerService.CheckAsync(new MethodInvocationFeatureCheckerContext(methodInfo));
await next();
}
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs
index e3fa489115..9498b31a3f 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeatureActionFilter.cs
@@ -13,13 +13,6 @@ namespace Volo.Abp.AspNetCore.Mvc.GlobalFeatures
{
public class GlobalFeatureActionFilter : IAsyncActionFilter, ITransientDependency
{
- public ILogger Logger { get; set; }
-
- public GlobalFeatureActionFilter()
- {
- Logger = NullLogger.Instance;
- }
-
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (!context.ActionDescriptor.IsControllerAction())
@@ -30,7 +23,8 @@ namespace Volo.Abp.AspNetCore.Mvc.GlobalFeatures
if (!IsGlobalFeatureEnabled(context.Controller.GetType(), out var attribute))
{
- Logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute.Name}' feature.");
+ var logger = context.GetService>(NullLogger.Instance);
+ logger.LogWarning($"The '{context.Controller.GetType().FullName}' controller needs to enable '{attribute.Name}' feature.");
context.Result = new NotFoundResult();
return;
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs
index d29c44b4af..a3415f6be8 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/GlobalFeatures/GlobalFeaturePageFilter.cs
@@ -13,13 +13,6 @@ namespace Volo.Abp.AspNetCore.Mvc.GlobalFeatures
{
public class GlobalFeaturePageFilter: IAsyncPageFilter, ITransientDependency
{
- public ILogger Logger { get; set; }
-
- public GlobalFeaturePageFilter()
- {
- Logger = NullLogger.Instance;
- }
-
public Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context)
{
return Task.CompletedTask;
@@ -35,7 +28,8 @@ namespace Volo.Abp.AspNetCore.Mvc.GlobalFeatures
if (!IsGlobalFeatureEnabled(context.HandlerInstance.GetType(), out var attribute))
{
- Logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute.Name}' feature.");
+ var logger = context.GetService>(NullLogger.Instance);
+ logger.LogWarning($"The '{context.HandlerInstance.GetType().FullName}' page needs to enable '{attribute.Name}' feature.");
context.Result = new NotFoundResult();
return;
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonInputFormatter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonInputFormatter.cs
index bd2ade69ad..8c0277321e 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonInputFormatter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonInputFormatter.cs
@@ -8,8 +8,14 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
{
public class AbpHybridJsonInputFormatter : TextInputFormatter, IInputFormatterExceptionPolicy
{
- public AbpHybridJsonInputFormatter()
+ private readonly SystemTextJsonInputFormatter _systemTextJsonInputFormatter;
+ private readonly NewtonsoftJsonInputFormatter _newtonsoftJsonInputFormatter;
+
+ public AbpHybridJsonInputFormatter(SystemTextJsonInputFormatter systemTextJsonInputFormatter, NewtonsoftJsonInputFormatter newtonsoftJsonInputFormatter)
{
+ _systemTextJsonInputFormatter = systemTextJsonInputFormatter;
+ _newtonsoftJsonInputFormatter = newtonsoftJsonInputFormatter;
+
SupportedEncodings.Add(UTF8EncodingWithoutBOM);
SupportedEncodings.Add(UTF16EncodingLittleEndian);
@@ -18,7 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationAnyJsonSyntax);
}
- public async override Task ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
+ public override async Task ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
{
return await GetTextInputFormatter(context).ReadRequestBodyAsync(context, encoding);
}
@@ -26,12 +32,13 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
protected virtual TextInputFormatter GetTextInputFormatter(InputFormatterContext context)
{
var typesMatcher = context.HttpContext.RequestServices.GetRequiredService();
+
if (!typesMatcher.Match(context.ModelType))
{
- return context.HttpContext.RequestServices.GetRequiredService();
+ return _systemTextJsonInputFormatter;
}
- return context.HttpContext.RequestServices.GetRequiredService();
+ return _newtonsoftJsonInputFormatter;
}
public virtual InputFormatterExceptionPolicy ExceptionPolicy => InputFormatterExceptionPolicy.MalformedInputExceptions;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOptionsSetup.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOptionsSetup.cs
new file mode 100644
index 0000000000..c0987e8f76
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOptionsSetup.cs
@@ -0,0 +1,73 @@
+using System.Buffers;
+using System.Text.Encodings.Web;
+using System.Text.Json;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Formatters;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.ObjectPool;
+using Microsoft.Extensions.Options;
+
+namespace Volo.Abp.AspNetCore.Mvc.Json
+{
+ public class AbpHybridJsonOptionsSetup : IConfigureOptions
+ {
+ private readonly IOptions _jsonOptions;
+ private readonly IOptions _mvcNewtonsoftJsonOptions;
+ private readonly ILoggerFactory _loggerFactory;
+ private readonly ArrayPool _charPool;
+ private readonly ObjectPoolProvider _objectPoolProvider;
+
+ public AbpHybridJsonOptionsSetup(
+ IOptions jsonOptions,
+ IOptions mvcNewtonsoftJsonOptions,
+ ILoggerFactory loggerFactory,
+ ArrayPool charPool,
+ ObjectPoolProvider objectPoolProvider)
+ {
+ _jsonOptions = jsonOptions;
+ _mvcNewtonsoftJsonOptions = mvcNewtonsoftJsonOptions;
+ _loggerFactory = loggerFactory;
+ _charPool = charPool;
+ _objectPoolProvider = objectPoolProvider;
+ }
+
+ public void Configure(MvcOptions options)
+ {
+ var systemTextJsonInputFormatter = new SystemTextJsonInputFormatter(
+ _jsonOptions.Value,
+ _loggerFactory.CreateLogger());
+
+ var newtonsoftJsonInputFormatter = new NewtonsoftJsonInputFormatter(
+ _loggerFactory.CreateLogger(),
+ _mvcNewtonsoftJsonOptions.Value.SerializerSettings,
+ _charPool,
+ _objectPoolProvider,
+ options,
+ _mvcNewtonsoftJsonOptions.Value);
+
+ options.InputFormatters.RemoveType();
+ options.InputFormatters.RemoveType();
+ options.InputFormatters.Add(new AbpHybridJsonInputFormatter(systemTextJsonInputFormatter, newtonsoftJsonInputFormatter));
+
+ var jsonSerializerOptions = _jsonOptions.Value.JsonSerializerOptions;
+ if (jsonSerializerOptions.Encoder is null)
+ {
+ // If the user hasn't explicitly configured the encoder, use the less strict encoder that does not encode all non-ASCII characters.
+ jsonSerializerOptions = new JsonSerializerOptions(jsonSerializerOptions)
+ {
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ };
+ }
+
+ var systemTextJsonOutputFormatter = new SystemTextJsonOutputFormatter(jsonSerializerOptions);
+ var newtonsoftJsonOutputFormatter = new NewtonsoftJsonOutputFormatter(
+ _mvcNewtonsoftJsonOptions.Value.SerializerSettings,
+ _charPool,
+ options);
+
+ options.OutputFormatters.RemoveType();
+ options.OutputFormatters.RemoveType();
+ options.OutputFormatters.Add(new AbpHybridJsonOutputFormatter(systemTextJsonOutputFormatter, newtonsoftJsonOutputFormatter));
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOutputFormatter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOutputFormatter.cs
index 1507457f08..1dcd5d0fac 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOutputFormatter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/AbpHybridJsonOutputFormatter.cs
@@ -8,8 +8,14 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
{
public class AbpHybridJsonOutputFormatter : TextOutputFormatter
{
- public AbpHybridJsonOutputFormatter()
+ private readonly SystemTextJsonOutputFormatter _systemTextJsonOutputFormatter;
+ private readonly NewtonsoftJsonOutputFormatter _newtonsoftJsonOutputFormatter;
+
+ public AbpHybridJsonOutputFormatter(SystemTextJsonOutputFormatter systemTextJsonOutputFormatter, NewtonsoftJsonOutputFormatter newtonsoftJsonOutputFormatter)
{
+ _systemTextJsonOutputFormatter = systemTextJsonOutputFormatter;
+ _newtonsoftJsonOutputFormatter = newtonsoftJsonOutputFormatter;
+
SupportedEncodings.Add(Encoding.UTF8);
SupportedEncodings.Add(Encoding.Unicode);
@@ -18,7 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationAnyJsonSyntax);
}
- public async override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
+ public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
{
await GetTextInputFormatter(context).WriteResponseBodyAsync(context, selectedEncoding);
}
@@ -28,10 +34,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
var typesMatcher = context.HttpContext.RequestServices.GetRequiredService();
if (!typesMatcher.Match(context.ObjectType))
{
- return context.HttpContext.RequestServices.GetRequiredService();
+ return _systemTextJsonOutputFormatter;
}
- return context.HttpContext.RequestServices.GetRequiredService();
+ return _newtonsoftJsonOutputFormatter;
}
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs
index b4e19e6ae7..366a24e8f4 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs
@@ -1,12 +1,7 @@
-using System.Buffers;
-using System.Text.Json;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Formatters;
+using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
-using System.Text.Encodings.Web;
-using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ObjectPool;
using Volo.Abp.Json;
@@ -24,68 +19,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
return builder;
}
- //SystemTextJsonInputFormatter
- builder.Services.AddTransient(provider =>
- {
- var jsonOptions = provider.GetRequiredService>();
- var logger = provider.GetRequiredService().CreateLogger();
- return new SystemTextJsonInputFormatter(jsonOptions.Value, logger);
- });
-
builder.Services.TryAddTransient();
- //NewtonsoftJsonInputFormatter
- builder.Services.AddTransient(provider =>
- {
- var jsonOptions = provider.GetRequiredService>().Value;
-
- return new NewtonsoftJsonInputFormatter(
- provider.GetRequiredService().CreateLogger(),
- jsonOptions.SerializerSettings,
- provider.GetRequiredService>(),
- provider.GetRequiredService(),
- provider.GetRequiredService>().Value,
- jsonOptions);
- });
-
- //SystemTextJsonOutputFormatter
- builder.Services.AddTransient(provider =>
- {
- var jsonSerializerOptions = provider.GetRequiredService>().Value.JsonSerializerOptions;
- if (jsonSerializerOptions.Encoder is null)
- {
- // If the user hasn't explicitly configured the encoder, use the less strict encoder that does not encode all non-ASCII characters.
- jsonSerializerOptions = new JsonSerializerOptions(jsonSerializerOptions)
- {
- Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
- };
- }
- return new SystemTextJsonOutputFormatter(jsonSerializerOptions);
- });
-
- //NewtonsoftJsonOutputFormatter
- builder.Services.AddTransient(provider =>
- {
- var jsonOptions = provider.GetRequiredService>().Value;
- return new NewtonsoftJsonOutputFormatter(
- jsonOptions.SerializerSettings,
- provider.GetRequiredService>(),
- provider.GetRequiredService>().Value);
- });
-
builder.Services.TryAddEnumerable(ServiceDescriptor.Transient, AbpJsonOptionsSetup>());
builder.Services.TryAddEnumerable(ServiceDescriptor.Transient, AbpMvcNewtonsoftJsonOptionsSetup>());
-
- builder.Services.Configure(options =>
- {
- options.InputFormatters.RemoveType();
- options.InputFormatters.RemoveType();
- options.InputFormatters.Add(new AbpHybridJsonInputFormatter());
-
- options.OutputFormatters.RemoveType();
- options.OutputFormatters.RemoveType();
- options.OutputFormatters.Add(new AbpHybridJsonOutputFormatter());
- });
-
+ builder.Services.TryAddEnumerable(ServiceDescriptor.Transient, AbpHybridJsonOptionsSetup>());
return builder;
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs
index 43dedf916f..95a961b814 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Abstractions;
@@ -12,15 +12,6 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
{
public class AbpUowActionFilter : IAsyncActionFilter, ITransientDependency
{
- private readonly IUnitOfWorkManager _unitOfWorkManager;
- private readonly AbpUnitOfWorkDefaultOptions _defaultOptions;
-
- public AbpUowActionFilter(IUnitOfWorkManager unitOfWorkManager, IOptions options)
- {
- _unitOfWorkManager = unitOfWorkManager;
- _defaultOptions = options.Value;
- }
-
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (!context.ActionDescriptor.IsControllerAction())
@@ -45,20 +36,22 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
var options = CreateOptions(context, unitOfWorkAttr);
+ var unitOfWorkManager = context.GetRequiredService();
+
//Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware
- if (_unitOfWorkManager.TryBeginReserved(UnitOfWork.UnitOfWorkReservationName, options))
+ if (unitOfWorkManager.TryBeginReserved(UnitOfWork.UnitOfWorkReservationName, options))
{
var result = await next();
if (!Succeed(result))
{
- await RollbackAsync(context);
+ await RollbackAsync(context, unitOfWorkManager);
}
return;
}
//Begin a new, independent unit of work
- using (var uow = _unitOfWorkManager.Begin(options))
+ using (var uow = unitOfWorkManager.Begin(options))
{
var result = await next();
if (Succeed(result))
@@ -76,7 +69,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
if (unitOfWorkAttribute?.IsTransactional == null)
{
- options.IsTransactional = _defaultOptions.CalculateIsTransactional(
+ var abpUnitOfWorkDefaultOptions = context.GetRequiredService>().Value;
+ options.IsTransactional = abpUnitOfWorkDefaultOptions.CalculateIsTransactional(
autoValue: !string.Equals(context.HttpContext.Request.Method, HttpMethod.Get.Method, StringComparison.OrdinalIgnoreCase)
);
}
@@ -84,9 +78,9 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
return options;
}
- private async Task RollbackAsync(ActionExecutingContext context)
+ private async Task RollbackAsync(ActionExecutingContext context, IUnitOfWorkManager unitOfWorkManager)
{
- var currentUow = _unitOfWorkManager.Current;
+ var currentUow = unitOfWorkManager.Current;
if (currentUow != null)
{
await currentUow.RollbackAsync(context.HttpContext.RequestAborted);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs
index 960c47b591..30c713940f 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowPageFilter.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Abstractions;
@@ -12,14 +12,6 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
{
public class AbpUowPageFilter : IAsyncPageFilter, ITransientDependency
{
- private readonly IUnitOfWorkManager _unitOfWorkManager;
- private readonly AbpUnitOfWorkDefaultOptions _defaultOptions;
-
- public AbpUowPageFilter(IUnitOfWorkManager unitOfWorkManager, IOptions options)
- {
- _unitOfWorkManager = unitOfWorkManager;
- _defaultOptions = options.Value;
- }
public Task OnPageHandlerSelectionAsync(PageHandlerSelectedContext context)
{
return Task.CompletedTask;
@@ -49,20 +41,22 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
var options = CreateOptions(context, unitOfWorkAttr);
+ var unitOfWorkManager = context.GetRequiredService();
+
//Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware
- if (_unitOfWorkManager.TryBeginReserved(UnitOfWork.UnitOfWorkReservationName, options))
+ if (unitOfWorkManager.TryBeginReserved(UnitOfWork.UnitOfWorkReservationName, options))
{
var result = await next();
if (!Succeed(result))
{
- await RollbackAsync(context);
+ await RollbackAsync(context, unitOfWorkManager);
}
return;
}
//Begin a new, independent unit of work
- using (var uow = _unitOfWorkManager.Begin(options))
+ using (var uow = unitOfWorkManager.Begin(options))
{
var result = await next();
if (Succeed(result))
@@ -80,7 +74,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
if (unitOfWorkAttribute?.IsTransactional == null)
{
- options.IsTransactional = _defaultOptions.CalculateIsTransactional(
+ var abpUnitOfWorkDefaultOptions = context.GetRequiredService>().Value;
+ options.IsTransactional = abpUnitOfWorkDefaultOptions.CalculateIsTransactional(
autoValue: !string.Equals(context.HttpContext.Request.Method, HttpMethod.Get.Method, StringComparison.OrdinalIgnoreCase)
);
}
@@ -88,9 +83,9 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
return options;
}
- private async Task RollbackAsync(PageHandlerExecutingContext context)
+ private async Task RollbackAsync(PageHandlerExecutingContext context, IUnitOfWorkManager unitOfWorkManager)
{
- var currentUow = _unitOfWorkManager.Current;
+ var currentUow = unitOfWorkManager.Current;
if (currentUow != null)
{
await currentUow.RollbackAsync(context.HttpContext.RequestAborted);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs
index 8fe699f4ba..751afe84d0 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs
@@ -7,13 +7,6 @@ namespace Volo.Abp.AspNetCore.Mvc.Validation
{
public class AbpValidationActionFilter : IAsyncActionFilter, ITransientDependency
{
- private readonly IModelStateValidator _validator;
-
- public AbpValidationActionFilter(IModelStateValidator validator)
- {
- _validator = validator;
- }
-
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
//TODO: Configuration to disable validation for controllers..?
@@ -25,7 +18,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Validation
return;
}
- _validator.Validate(context.ModelState);
+ context.GetRequiredService().Validate(context.ModelState);
await next();
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
index 4e23a4cb41..a9d9316f41 100644
--- a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
+++ b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
@@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
+using Volo.Abp.DependencyInjection;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing;
@@ -14,48 +15,23 @@ namespace Volo.Abp.AspNetCore.SignalR
{
public abstract class AbpHub : Hub
{
- public IServiceProvider ServiceProvider { get; set; }
- protected readonly object ServiceProviderLock = new object();
-
- protected TService LazyGetRequiredService(ref TService reference)
- => LazyGetRequiredService(typeof(TService), ref reference);
-
- protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (ServiceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
- return reference;
- }
+ public IServiceProvider ServiceProvider { get; set; }
- protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory);
- private ILoggerFactory _loggerFactory;
+ protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetService();
- protected ILogger Logger => _lazyLogger.Value;
- private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true);
+ protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
- protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser);
- private ICurrentUser _currentUser;
+ protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetService();
- protected ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant);
- private ICurrentTenant _currentTenant;
+ protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetService();
- protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService);
- private IAuthorizationService _authorizationService;
+ protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetService();
- protected IClock Clock => LazyGetRequiredService(ref _clock);
- private IClock _clock;
+ protected IClock Clock => LazyServiceProvider.LazyGetService();
- protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory);
- private IStringLocalizerFactory _stringLocalizerFactory;
+ protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetService();
protected IStringLocalizer L
{
@@ -102,48 +78,23 @@ namespace Volo.Abp.AspNetCore.SignalR
public abstract class AbpHub : Hub
where T : class
{
- public IServiceProvider ServiceProvider { get; set; }
- protected readonly object ServiceProviderLock = new object();
-
- protected TService LazyGetRequiredService(ref TService reference)
- => LazyGetRequiredService(typeof(TService), ref reference);
-
- protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (ServiceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
- return reference;
- }
+ public IServiceProvider ServiceProvider { get; set; }
- protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory);
- private ILoggerFactory _loggerFactory;
+ protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetService();
- protected ILogger Logger => _lazyLogger.Value;
- private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true);
+ protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
- protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser);
- private ICurrentUser _currentUser;
+ protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetService();
- protected ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant);
- private ICurrentTenant _currentTenant;
+ protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetService();
- protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService);
- private IAuthorizationService _authorizationService;
+ protected IAuthorizationService AuthorizationService => LazyServiceProvider.LazyGetService();
- protected IClock Clock => LazyGetRequiredService(ref _clock);
- private IClock _clock;
+ protected IClock Clock => LazyServiceProvider.LazyGetService();
- protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory);
- private IStringLocalizerFactory _stringLocalizerFactory;
+ protected IStringLocalizerFactory StringLocalizerFactory => LazyServiceProvider.LazyGetService();
protected IStringLocalizer L
{
diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/SecurityLog/AspNetCoreSecurityLogManager.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/SecurityLog/AspNetCoreSecurityLogManager.cs
index b518c5abbb..f0fc0aa347 100644
--- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/SecurityLog/AspNetCoreSecurityLogManager.cs
+++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/SecurityLog/AspNetCoreSecurityLogManager.cs
@@ -48,7 +48,7 @@ namespace Volo.Abp.AspNetCore.SecurityLog
WebClientInfoProvider = webClientInfoProvider;
}
- protected async override Task CreateAsync()
+ protected override async Task CreateAsync()
{
var securityLogInfo = await base.CreateAsync();
diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs
index 0eef78ed6a..9142db5617 100644
--- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs
+++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Aspects;
using Volo.Abp.DependencyInjection;
using Volo.Abp.DynamicProxy;
@@ -9,16 +10,14 @@ namespace Volo.Abp.Auditing
{
public class AuditingInterceptor : AbpInterceptor, ITransientDependency
{
- private readonly IAuditingHelper _auditingHelper;
- private readonly IAuditingManager _auditingManager;
+ private readonly IServiceScopeFactory _serviceScopeFactory;
- public AuditingInterceptor(IAuditingHelper auditingHelper, IAuditingManager auditingManager)
+ public AuditingInterceptor(IServiceScopeFactory serviceScopeFactory)
{
- _auditingHelper = auditingHelper;
- _auditingManager = auditingManager;
+ _serviceScopeFactory = serviceScopeFactory;
}
- public async override Task InterceptAsync(IAbpMethodInvocation invocation)
+ public override async Task InterceptAsync(IAbpMethodInvocation invocation)
{
if (!ShouldIntercept(invocation, out var auditLog, out var auditLogAction))
{
@@ -58,26 +57,31 @@ namespace Volo.Abp.Auditing
return false;
}
- var auditLogScope = _auditingManager.Current;
- if (auditLogScope == null)
+ using (var scope = _serviceScopeFactory.CreateScope())
{
- return false;
- }
+ var auditingManager = scope.ServiceProvider.GetRequiredService();
+ var auditLogScope = auditingManager.Current;
+ if (auditLogScope == null)
+ {
+ return false;
+ }
- if (!_auditingHelper.ShouldSaveAudit(invocation.Method))
- {
- return false;
- }
+ var auditingHelper = scope.ServiceProvider.GetRequiredService();
+ if (!auditingHelper.ShouldSaveAudit(invocation.Method))
+ {
+ return false;
+ }
- auditLog = auditLogScope.Log;
- auditLogAction = _auditingHelper.CreateAuditLogAction(
- auditLog,
- invocation.TargetObject.GetType(),
- invocation.Method,
- invocation.Arguments
- );
+ auditLog = auditLogScope.Log;
+ auditLogAction = auditingHelper.CreateAuditLogAction(
+ auditLog,
+ invocation.TargetObject.GetType(),
+ invocation.Method,
+ invocation.Arguments
+ );
- return true;
+ return true;
+ }
}
}
}
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs
index f889251c69..f636877fc1 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs
@@ -23,7 +23,7 @@ namespace Volo.Abp.Authorization
_options = options.Value;
}
- public async override Task GetPolicyAsync(string policyName)
+ public override async Task GetPolicyAsync(string policyName)
{
var policy = await base.GetPolicyAsync(policyName);
if (policy != null)
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptor.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptor.cs
index 82f4adeabe..44466884dd 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptor.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptor.cs
@@ -13,7 +13,7 @@ namespace Volo.Abp.Authorization
_methodInvocationAuthorizationService = methodInvocationAuthorizationService;
}
- public async override Task InterceptAsync(IAbpMethodInvocation invocation)
+ public override async Task InterceptAsync(IAbpMethodInvocation invocation)
{
await AuthorizeAsync(invocation);
await invocation.ProceedAsync();
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Localization/nl.json b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Localization/nl.json
new file mode 100644
index 0000000000..6be7515c01
--- /dev/null
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Localization/nl.json
@@ -0,0 +1,10 @@
+{
+ "culture": "nl",
+ "texts": {
+ "Volo.Authorization:010001": "Autorisatie mislukt! De benodigde policy is niet aan u verleend.",
+ "Volo.Authorization:010002": "Autorisatie mislukt! De benodigde policy: '{PolicyName}' is niet aan u verleend.",
+ "Volo.Authorization:010003": "Autorisatie mislukt! De benodigde policy is niet aan de opgegeven resource: '{ResourceName}' verleend.",
+ "Volo.Authorization:010004": "Autorisatie mislukt! De benodigde requirement is niet aan de opgegeven resource: '{ResourceName}' verleend.",
+ "Volo.Authorization:010005": "Autorisatie mislukt! De benodigde requirements zijn niet aan de opgegeven resource: '{ResourceName}' verleend."
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/MethodInvocationAuthorizationService.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/MethodInvocationAuthorizationService.cs
index fb35d142cb..c00c652500 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/MethodInvocationAuthorizationService.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/MethodInvocationAuthorizationService.cs
@@ -36,7 +36,7 @@ namespace Volo.Abp.Authorization
{
return;
}
-
+
await _abpAuthorizationService.CheckAsync(authorizationPolicy);
}
@@ -64,4 +64,4 @@ namespace Volo.Abp.Authorization
return attributes;
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/PermissionRequirementHandler.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/PermissionRequirementHandler.cs
index b0446f5602..d4ec7c1d3c 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/PermissionRequirementHandler.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/PermissionRequirementHandler.cs
@@ -13,7 +13,7 @@ namespace Volo.Abp.Authorization
_permissionChecker = permissionChecker;
}
- protected async override Task HandleRequirementAsync(
+ protected override async Task HandleRequirementAsync(
AuthorizationHandlerContext context,
PermissionRequirement requirement)
{
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs
index ac76733524..6e14b304e3 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs
@@ -19,7 +19,7 @@ namespace Volo.Abp.Authorization.Permissions
CurrentTenant = currentTenant;
}
- public async override Task CheckAsync(PermissionValueCheckContext context)
+ public override async Task CheckAsync(PermissionValueCheckContext context)
{
var clientId = context.Principal?.FindFirst(AbpClaimTypes.ClientId)?.Value;
@@ -36,7 +36,7 @@ namespace Volo.Abp.Authorization.Permissions
}
}
- public async override Task CheckAsync(PermissionValuesCheckContext context)
+ public override async Task CheckAsync(PermissionValuesCheckContext context)
{
var permissionNames = context.Permissions.Select(x => x.Name).ToArray();
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RolePermissionValueProvider.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RolePermissionValueProvider.cs
index e3ab7629a2..eec94b3b98 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RolePermissionValueProvider.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RolePermissionValueProvider.cs
@@ -17,7 +17,7 @@ namespace Volo.Abp.Authorization.Permissions
}
- public async override Task CheckAsync(PermissionValueCheckContext context)
+ public override async Task CheckAsync(PermissionValueCheckContext context)
{
var roles = context.Principal?.FindAll(AbpClaimTypes.Role).Select(c => c.Value).ToArray();
@@ -37,7 +37,7 @@ namespace Volo.Abp.Authorization.Permissions
return PermissionGrantResult.Undefined;
}
- public async override Task CheckAsync(PermissionValuesCheckContext context)
+ public override async Task CheckAsync(PermissionValuesCheckContext context)
{
var permissionNames = context.Permissions.Select(x => x.Name).ToList();
var result = new MultiplePermissionGrantResult(permissionNames.ToArray());
diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/UserPermissionValueProvider.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/UserPermissionValueProvider.cs
index fcdc25d1e1..c90344371e 100644
--- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/UserPermissionValueProvider.cs
+++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/UserPermissionValueProvider.cs
@@ -16,7 +16,7 @@ namespace Volo.Abp.Authorization.Permissions
}
- public async override Task CheckAsync(PermissionValueCheckContext context)
+ public override async Task CheckAsync(PermissionValueCheckContext context)
{
var userId = context.Principal?.FindFirst(AbpClaimTypes.UserId)?.Value;
@@ -30,7 +30,7 @@ namespace Volo.Abp.Authorization.Permissions
: PermissionGrantResult.Undefined;
}
- public async override Task CheckAsync(PermissionValuesCheckContext context)
+ public override async Task CheckAsync(PermissionValuesCheckContext context)
{
var permissionNames = context.Permissions.Select(x => x.Name).ToArray();
diff --git a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs
index 2635294323..8eec35d816 100644
--- a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs
+++ b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs
@@ -30,7 +30,7 @@ namespace Volo.Abp.BackgroundJobs
Timer.Period = WorkerOptions.JobPollPeriod;
}
- protected async override Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
+ protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{
var store = workerContext.ServiceProvider.GetRequiredService();
diff --git a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AsyncPeriodicBackgroundWorkerBase.cs b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AsyncPeriodicBackgroundWorkerBase.cs
index 094c6eb7eb..ce4f9b42d7 100644
--- a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AsyncPeriodicBackgroundWorkerBase.cs
+++ b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AsyncPeriodicBackgroundWorkerBase.cs
@@ -22,13 +22,13 @@ namespace Volo.Abp.BackgroundWorkers
Timer.Elapsed = Timer_Elapsed;
}
- public async override Task StartAsync(CancellationToken cancellationToken = default)
+ public override async Task StartAsync(CancellationToken cancellationToken = default)
{
await base.StartAsync(cancellationToken);
Timer.Start(cancellationToken);
}
- public async override Task StopAsync(CancellationToken cancellationToken = default)
+ public override async Task StopAsync(CancellationToken cancellationToken = default)
{
Timer.Stop(cancellationToken);
await base.StopAsync(cancellationToken);
diff --git a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerBase.cs b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerBase.cs
index bf654cf6a7..85523d7ee9 100644
--- a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerBase.cs
+++ b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerBase.cs
@@ -1,9 +1,9 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
+using Volo.Abp.DependencyInjection;
namespace Volo.Abp.BackgroundWorkers
{
@@ -13,33 +13,14 @@ namespace Volo.Abp.BackgroundWorkers
public abstract class BackgroundWorkerBase : IBackgroundWorker
{
//TODO: Add UOW, Localization and other useful properties..?
- public IServiceProvider ServiceProvider { get; set; }
- protected readonly object ServiceProviderLock = new object();
- protected TService LazyGetRequiredService(ref TService reference)
- => LazyGetRequiredService(typeof(TService), ref reference);
+ public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
- protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference)
- {
- if (reference == null)
- {
- lock (ServiceProviderLock)
- {
- if (reference == null)
- {
- reference = (TRef)ServiceProvider.GetRequiredService(serviceType);
- }
- }
- }
-
- return reference;
- }
+ public IServiceProvider ServiceProvider { get; set; }
- protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory);
- private ILoggerFactory _loggerFactory;
+ protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService();
- protected ILogger Logger => _lazyLogger.Value;
- private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true);
+ protected ILogger Logger => LazyServiceProvider.LazyGetService(provider => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance);
public virtual Task StartAsync(CancellationToken cancellationToken = default)
{
diff --git a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/PeriodicBackgroundWorkerBase.cs b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/PeriodicBackgroundWorkerBase.cs
index 6ac757fef5..e89204e81f 100644
--- a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/PeriodicBackgroundWorkerBase.cs
+++ b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/PeriodicBackgroundWorkerBase.cs
@@ -25,13 +25,13 @@ namespace Volo.Abp.BackgroundWorkers
Timer.Elapsed += Timer_Elapsed;
}
- public async override Task StartAsync(CancellationToken cancellationToken = default)
+ public override async Task StartAsync(CancellationToken cancellationToken = default)
{
await base.StartAsync(cancellationToken);
Timer.Start(cancellationToken);
}
- public async override Task StopAsync(CancellationToken cancellationToken = default)
+ public override async Task StopAsync(CancellationToken cancellationToken = default)
{
Timer.Stop(cancellationToken);
await base.StopAsync(cancellationToken);
diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
index e3e7112afa..7f0edf3b4a 100644
--- a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
+++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
@@ -41,7 +41,7 @@ namespace Volo.Abp.BlazoriseUI.Components
[Inject]
protected IUiMessageService UiMessageService { get; set; }
- protected async override Task OnInitializedAsync()
+ protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await SetDefaultValuesAsync();
diff --git a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
index de793e078f..9405337b89 100644
--- a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
+++ b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
@@ -12,9 +12,9 @@
-
-
-
+
+
+
diff --git a/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs
index d6c9303afd..39e8aff996 100644
--- a/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs
+++ b/framework/src/Volo.Abp.BlobStoring.Aliyun/Volo/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs
@@ -73,7 +73,7 @@ namespace Volo.Abp.BlobStoring.Aliyun
return Task.FromResult(BlobExists(ossClient, containerName, blobName));
}
- public async override Task GetOrNullAsync(BlobProviderGetArgs args)
+ public override async Task GetOrNullAsync(BlobProviderGetArgs args)
{
var containerName = GetContainerName(args);
var blobName = AliyunBlobNameCalculator.Calculate(args);
diff --git a/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProvider.cs
index 191f9a0ac7..dd9c205d8b 100644
--- a/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProvider.cs
+++ b/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/AwsBlobProvider.cs
@@ -20,7 +20,7 @@ namespace Volo.Abp.BlobStoring.Aws
AmazonS3ClientFactory = amazonS3ClientFactory;
}
- public async override Task SaveAsync(BlobProviderSaveArgs args)
+ public override async Task SaveAsync(BlobProviderSaveArgs args)
{
var blobName = AwsBlobNameCalculator.Calculate(args);
var configuration = args.Configuration.GetAwsConfiguration();
@@ -48,7 +48,7 @@ namespace Volo.Abp.BlobStoring.Aws
}
}
- public async override Task DeleteAsync(BlobProviderDeleteArgs args)
+ public override async Task DeleteAsync(BlobProviderDeleteArgs args)
{
var blobName = AwsBlobNameCalculator.Calculate(args);
var containerName = GetContainerName(args);
@@ -70,7 +70,7 @@ namespace Volo.Abp.BlobStoring.Aws
}
}
- public async override Task ExistsAsync(BlobProviderExistsArgs args)
+ public override async Task ExistsAsync(BlobProviderExistsArgs args)
{
var blobName = AwsBlobNameCalculator.Calculate(args);
var containerName = GetContainerName(args);
@@ -81,7 +81,7 @@ namespace Volo.Abp.BlobStoring.Aws
}
}
- public async override Task GetOrNullAsync(BlobProviderGetArgs args)
+ public override async Task GetOrNullAsync(BlobProviderGetArgs args)
{
var blobName = AwsBlobNameCalculator.Calculate(args);
var containerName = GetContainerName(args);
diff --git a/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProvider.cs
index 3a9a062e76..1afc3b6a53 100644
--- a/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProvider.cs
+++ b/framework/src/Volo.Abp.BlobStoring.Azure/Volo/Abp/BlobStoring/Azure/AzureBlobProvider.cs
@@ -15,7 +15,7 @@ namespace Volo.Abp.BlobStoring.Azure
AzureBlobNameCalculator = azureBlobNameCalculator;
}
- public async override Task SaveAsync(BlobProviderSaveArgs args)
+ public override async Task SaveAsync(BlobProviderSaveArgs args)
{
var blobName = AzureBlobNameCalculator.Calculate(args);
var configuration = args.Configuration.GetAzureConfiguration();
@@ -33,7 +33,7 @@ namespace Volo.Abp.BlobStoring.Azure
await GetBlobClient(args, blobName).UploadAsync(args.BlobStream, true);
}
- public async override Task DeleteAsync(BlobProviderDeleteArgs args)
+ public override async Task DeleteAsync(BlobProviderDeleteArgs args)
{
var blobName = AzureBlobNameCalculator.Calculate(args);
@@ -45,14 +45,14 @@ namespace Volo.Abp.BlobStoring.Azure
return false;
}
- public async override Task ExistsAsync(BlobProviderExistsArgs args)
+ public override async Task ExistsAsync(BlobProviderExistsArgs args)
{
var blobName = AzureBlobNameCalculator.Calculate(args);
return await BlobExistsAsync(args, blobName);
}
- public async override Task GetOrNullAsync(BlobProviderGetArgs args)
+ public override async Task GetOrNullAsync(BlobProviderGetArgs args)
{
var blobName = AzureBlobNameCalculator.Calculate(args);
diff --git a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs
index 3a512a0ba3..cbfe4bcaf7 100644
--- a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs
+++ b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs
@@ -16,7 +16,7 @@ namespace Volo.Abp.BlobStoring.FileSystem
FilePathCalculator = filePathCalculator;
}
- public async override Task SaveAsync(BlobProviderSaveArgs args)
+ public override async Task SaveAsync(BlobProviderSaveArgs args)
{
var filePath = FilePathCalculator.Calculate(args);
@@ -59,7 +59,7 @@ namespace Volo.Abp.BlobStoring.FileSystem
return ExistsAsync(filePath);
}
- public async override Task GetOrNullAsync(BlobProviderGetArgs args)
+ public override async Task GetOrNullAsync(BlobProviderGetArgs args)
{
var filePath = FilePathCalculator.Calculate(args);
diff --git a/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProvider.cs b/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProvider.cs
index fca23324dc..8e18f9dedb 100644
--- a/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProvider.cs
+++ b/framework/src/Volo.Abp.BlobStoring.Minio/Volo/Abp/BlobStoring/Minio/MinioBlobProvider.cs
@@ -16,7 +16,7 @@ namespace Volo.Abp.BlobStoring.Minio
MinioBlobNameCalculator = minioBlobNameCalculator;
}
- public async override Task SaveAsync(BlobProviderSaveArgs args)
+ public override async Task SaveAsync(BlobProviderSaveArgs args)
{
var blobName = MinioBlobNameCalculator.Calculate(args);
var configuration = args.Configuration.GetMinioConfiguration();
@@ -36,7 +36,7 @@ namespace Volo.Abp.BlobStoring.Minio
await client.PutObjectAsync(containerName, blobName, args.BlobStream, args.BlobStream.Length);
}
- public async override Task DeleteAsync(BlobProviderDeleteArgs args)
+ public override async Task DeleteAsync(BlobProviderDeleteArgs args)
{
var blobName = MinioBlobNameCalculator.Calculate(args);
var client = GetMinioClient(args);
@@ -51,7 +51,7 @@ namespace Volo.Abp.BlobStoring.Minio
return false;
}
- public async override Task ExistsAsync(BlobProviderExistsArgs args)
+ public override async Task ExistsAsync(BlobProviderExistsArgs args)
{
var blobName = MinioBlobNameCalculator.Calculate(args);
var client = GetMinioClient(args);
@@ -60,7 +60,7 @@ namespace Volo.Abp.BlobStoring.Minio
return await BlobExistsAsync(client, containerName, blobName);
}
- public async override Task GetOrNullAsync(BlobProviderGetArgs args)
+ public override async Task GetOrNullAsync(BlobProviderGetArgs args)
{
var blobName = MinioBlobNameCalculator.Calculate(args);
var client = GetMinioClient(args);
diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapter.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapter.cs
index 7a99859d3a..433fde192f 100644
--- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapter.cs
+++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapter.cs
@@ -18,7 +18,7 @@ namespace Volo.Abp.Castle.DynamicProxy
Proceed = proceed;
}
- public async override Task ProceedAsync()
+ public override async Task ProceedAsync()
{
await Proceed(Invocation, ProceedInfo);
}
diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs
index a0babad231..ef1c0ae54d 100644
--- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs
+++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpMethodInvocationAdapterWithReturnValue.cs
@@ -19,7 +19,7 @@ namespace Volo.Abp.Castle.DynamicProxy
Proceed = proceed;
}
- public async override Task ProceedAsync()
+ public override async Task ProceedAsync()
{
ReturnValue = await Proceed(Invocation, ProceedInfo);
}
diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncAbpInterceptorAdapter.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncAbpInterceptorAdapter.cs
index 6d08e8f6a6..8a0c4fdd45 100644
--- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncAbpInterceptorAdapter.cs
+++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAsyncAbpInterceptorAdapter.cs
@@ -15,14 +15,14 @@ namespace Volo.Abp.Castle.DynamicProxy
_abpInterceptor = abpInterceptor;
}
- protected async override Task InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func proceed)
+ protected override async Task InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func proceed)
{
await _abpInterceptor.InterceptAsync(
new CastleAbpMethodInvocationAdapter(invocation, proceedInfo, proceed)
);
}
- protected async override Task