diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..9805011759 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,137 @@ +# EditorConfig is awesome: https://EditorConfig.org +# Please feel free to update it (by considering the code style of ABP Team). +# top-most EditorConfig file +root = true + +[*.cs] + +#Namespace settings +csharp_style_namespace_declarations = file_scoped +dotnet_diagnostic.IDE0161.severity = warning + +#Core editorconfig formatting - indentation + +#use tabs for indentation +indent_style = tabs + +#Formatting - indentation options + +#indent switch case contents. +csharp_indent_case_contents = true +#indent switch labels +csharp_indent_switch_labels = true + +#Formatting - new line options + +#place catch statements on a new line +csharp_new_line_before_catch = true +#place else statements on a new line +csharp_new_line_before_else = true +#require members of object intializers to be on separate lines +csharp_new_line_before_members_in_object_initializers = true +#require braces to be on a new line for object_collection_array_initializers, methods, control_blocks, types, and lambdas (also known as "Allman" style) +csharp_new_line_before_open_brace = object_collection_array_initializers, methods, control_blocks, types, lambdas + +#Formatting - organize using options + +#sort System.* using directives alphabetically, and place them before other usings +dotnet_sort_system_directives_first = true + +#Formatting - spacing options + +#require NO space between a cast and the value +csharp_space_after_cast = false +#require a space before the colon for bases or interfaces in a type declaration +csharp_space_after_colon_in_inheritance_clause = true +#require a space after a keyword in a control flow statement such as a for loop +csharp_space_after_keywords_in_control_flow_statements = true +#require a space before the colon for bases or interfaces in a type declaration +csharp_space_before_colon_in_inheritance_clause = true +#remove space within empty argument list parentheses +csharp_space_between_method_call_empty_parameter_list_parentheses = false +#remove space between method call name and opening parenthesis +csharp_space_between_method_call_name_and_opening_parenthesis = false +#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call +csharp_space_between_method_call_parameter_list_parentheses = false +#remove space within empty parameter list parentheses for a method declaration +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. +csharp_space_between_method_declaration_parameter_list_parentheses = false + +#Formatting - wrapping options + +#leave code block on single line +csharp_preserve_single_line_blocks = true + +#Style - Code block preferences + +#prefer curly braces even for one line of code +csharp_prefer_braces = true:suggestion + +#Style - expression bodied member options + +#prefer block bodies for constructors +csharp_style_expression_bodied_constructors = false:suggestion +#prefer block bodies for methods +csharp_style_expression_bodied_methods = false:suggestion +#prefer expression-bodied members for properties +csharp_style_expression_bodied_properties = true:suggestion + +#Style - expression level options + +#prefer out variables to be declared inline in the argument list of a method call when possible +csharp_style_inlined_variable_declaration = true:suggestion +#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_member_access = true:suggestion + +#Style - Expression-level preferences + +#prefer default over default(T) +csharp_prefer_simple_default_expression = true:suggestion +#prefer objects to be initialized using object initializers when possible +dotnet_style_object_initializer = true:suggestion +#prefer inferred tuple element names +dotnet_style_prefer_inferred_tuple_names = true:suggestion + +#Style - implicit and explicit types + +#prefer var over explicit type in all cases, unless overridden by another code style rule +csharp_style_var_elsewhere = true:suggestion +#prefer var is used to declare variables with built-in system types such as int +csharp_style_var_for_built_in_types = true:suggestion +#prefer var when the type is already mentioned on the right-hand side of a declaration expression +csharp_style_var_when_type_is_apparent = true:suggestion + +#Style - language keyword and framework type options + +#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion + +#Style - Miscellaneous preferences + +#prefer local functions over anonymous functions +csharp_style_pattern_local_over_anonymous_function = true:suggestion + +#Style - modifier options + +#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +#Style - Modifier preferences + +#when this rule is set to a list of modifiers, prefer the specified ordering. +csharp_preferred_modifier_order = public,protected,private,virtual,async,readonly,static,override,abstract:suggestion + +#Style - Pattern matching + +#prefer pattern matching instead of is expression with type casts +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion + +#Style - qualification options + +#prefer fields not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_field = false:suggestion +#prefer methods not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_method = false:suggestion +#prefer properties not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_property = false:suggestion diff --git a/.gitignore b/.gitignore index 79d0ea6388..1faf2fac91 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ *.user *.userosscache *.sln.docstates -*.editorconfig + # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en-GB.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en-GB.json index 4ea99af7e1..f64b385908 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en-GB.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en-GB.json @@ -210,6 +210,10 @@ "Completed": "Completed", "Failed": "Failed", "PaymentRequestDeletionWarningMessage": "This payment request will be deleted. Do you confirm that?", - "Payment": "Payment" + "Payment": "Payment", + "Permission:SendWelcomeEmail": "Send Welcome Email", + "SendWelcomeEmail": "Send Welcome Email", + "SendWelcomeEmailWarningMessage": "Are you sure you want to send welcome email to the organization members?", + "SendWelcomeEmailSuccessMessage": "Welcome email sent successfully!" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json index 923535cfdd..f926259297 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json @@ -352,6 +352,11 @@ "Volo.AbpIo.Commercial:030008": "Purchase date can be set only when status is Purchased!", "Volo.AbpIo.Commercial:030009": "User not found!", "Volo.AbpIo.Commercial:030010": "To purchase the trial license, first you need to activate your trial license!", - "Volo.AbpIo.Commercial:030011": "You cannot delete a trial license when it is purchased!" + "Volo.AbpIo.Commercial:030011": "You cannot delete a trial license when it is purchased!", + "Permission:SendWelcomeEmail": "Send Welcome Email", + "SendWelcomeEmail": "Send Welcome Email", + "SendWelcomeEmailWarningMessage": "Are you sure you want to send welcome email to the organization members?", + "SendWelcomeEmailSuccessMessage": "Welcome email sent successfully!", + "PaymentRequestId": "Payment Request Id" } } diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json index 1bba0bb964..5942fca747 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json @@ -348,6 +348,10 @@ "Volo.AbpIo.Commercial:030008": "Satın alma tarihi yalnızca durum Satın Alındı olduğunda ayarlanabilir!", "Volo.AbpIo.Commercial:030009": "Kullanıcı bulunamadı!", "Volo.AbpIo.Commercial:030010": "Deneme lisansını satın almak için önce deneme lisansınızı etkinleştirmeniz gerekir!", - "Volo.AbpIo.Commercial:030011": "Satın alındığında bir deneme lisansını silemezsiniz!" + "Volo.AbpIo.Commercial:030011": "Satın alındığında bir deneme lisansını silemezsiniz!", + "Permission:SendWelcomeEmail": "Hoşgeldin Emaili Gönder", + "SendWelcomeEmail": "Hoşgeldin Emaili Gönder", + "SendWelcomeEmailWarningMessage": "Organizasyon üyelerine hoşgeldin emaili göndermek istediğinden emin misin?", + "SendWelcomeEmailSuccessMessage": "Hoşgeldin emaili başarıyla gönderilmiştir!" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en-GB.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en-GB.json index 87b934f8c5..caa14e8d94 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en-GB.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en-GB.json @@ -102,6 +102,10 @@ "InvalidFormInputs": "Please, type the valid information specified on the form.", "DDDBookEmailBody": "Thank you.
To download your book, click here.", "FreeDDDEBook": "Free DDD E-Book", - "CommercialNewsletterConfirmationMessage": "I agree to the Terms & Conditions and Privacy Policy." + "CommercialNewsletterConfirmationMessage": "I agree to the Terms & Conditions and Privacy Policy.", + "RemoveCurrentUserFromOrganizationWarningMessage": "You are removing yourself from your own organization. You will no longer be able to manage this organization, do you confirm?", + "RenewExistingOrganizationOrCreateNewOneMessage": "You can renew the license of your organization(s) by clicking the below \"Extend Now\" button(s) and thus you can extend the license expiry date by 1 year. If you continue to checkout, you will have a new organization. Do you want to continue with a new organization?", + "ExtendNow": "Extend Now", + "ContinueWithNewOrganization": "Continue with a new organization" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index f4a8153ec1..7bb8f4d109 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -178,7 +178,7 @@ "ChangingLicenseType": "Can I upgrade my license type later?", "ChangingLicenseTypeExplanation": "You can upgrade to a higher license by paying the difference within your active license period. When you upgrade to a higher license plan, you get the benefits of the new plan, but the license upgrade does not change the license expiry date. Besides, you can also add new developer seats to your existing license, see \"How many developers can work on the ABP Commercial?\"", "LicenseExtendUpgradeDiff": "What is the difference between license extend and upgrade?", - "LicenseExtendUpgradeDiffExplanation": "Extending: By extending/renewing your license, you will continue to get premium support and get major updates for the modules and themes. Besides, you will be able to continue creating new projects. And you will still be able to use ABP Suite which speeds up your development.
Upgrading: By upgrading your license, you will promote to a higher license plan which will allow you to get additional benefits. See the license comparison table to check the differences between the license plans.On the other hand, when you upgrade, your license expiry date will not change!To extend your license end date, you need to extend your license.", + "LicenseExtendUpgradeDiffExplanation": "Extending: By extending/renewing your license, you will continue to get premium support and get major updates for the modules and themes. Besides, you will be able to continue creating new projects. And you will still be able to use ABP Suite which speeds up your development. When you extend your license, 1 year is added to your license expiry date.
Upgrading: By upgrading your license, you will promote to a higher license plan which will allow you to get additional benefits. See the license comparison table to check the differences between the license plans.On the other hand, when you upgrade, your license expiry date will not change!To extend your license end date, you need to extend your license.", "LicenseRenewalCost": "What is the license renewal cost after 1 year?", "LicenseRenewalCostExplanation": "The renewal (extend) rate of all ABP Commercial perpetual licenses is {0} of the license list price. The renewal price of the standard Team License is ${1}, standard Business License is ${2} and standard Enterprise License is ${3}. If you are already a customer, log into your account to review the available renewal pricing.", "HowDoIRenewMyLicense": "How do I renew my license?", @@ -390,6 +390,16 @@ "TrialLicenseExpireMessage": "You are using the trial license and your trial license will expire on {0}.", "TryForFree": "Try For Free", "TrialLicenseExpiredInfo": "Your trial license period has expired!", - "CommercialNewsletterConfirmationMessage": "I agree to the Terms & Conditions and Privacy Policy." + "CommercialNewsletterConfirmationMessage": "I agree to the Terms & Conditions and Privacy Policy.", + "DowngradeLicensePlan": "Can I downgrade to a lower license plan in the future?", + "DowngradeLicensePlanExplanation": "You cannot downgrade your existing license plan. But you can purchase a new lower license plan and continue to your development on the new license. After you purchase a lower license, you just need to login to your new license plan via ABP CLI command: ` abp login -o `.", + "LicenseTransfer": "Can a license be transferred from one developer to another?", + "LicenseTransferExplanation": "Yes! When you purchase a license, you become the license holder, hence you will have access to the organization management page. An organization has owner and developer roles. Owners can manage the developer seats and assign developers. Each assigned developer will login via ABP CLI command into the system and will have development and support permissions.", + "UserOwnerDescription": "The 'Owner' of the organization is the admin of this account. He/she manages the organization by purchasing licenses, allocating developers. An 'Owner' cannot write code in the ABP Commercial projects, cannot download the ABP sample projects, or cannot ask questions on the support website. If you want to do all these, you have to add yourself as a developer too.", + "UserDeveloperDescription": "The 'Developers' can write code in the ABP Commercial projects, download the ABP sample projects, or ask questions on the support website. On the other hand, the 'Developers' cannot manage this organization.", + "RemoveCurrentUserFromOrganizationWarningMessage": "You are removing yourself from your own organization. You will no longer be able to manage this organization, do you confirm?", + "RenewExistingOrganizationOrCreateNewOneMessage": "You can renew the license of your organization(s) by clicking the below \"Extend Now\" button(s) and thus you can extend the license expiry date by 1 year. If you continue to checkout, you will have a new organization. Do you want to continue with a new organization?", + "ExtendNow": "Extend Now", + "ContinueWithNewOrganization": "Continue with a new organization" } } diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/tr.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/tr.json index ae472a27f0..5e93833b0d 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/tr.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/tr.json @@ -390,6 +390,10 @@ "TrialLicenseExpireMessage": "Deneme lisansını kullanıyorsunuz ve deneme lisansınızın süresi {0} tarihinde sona erecek.", "TryForFree": "Ücretsiz deneyin", "TrialLicenseExpiredInfo": "Deneme lisansınızın süresi doldu!", - "CommercialNewsletterConfirmationMessage": "Şartlar, Koşullar ve Gizlilik politikasını kabul ediyorum." + "CommercialNewsletterConfirmationMessage": "Şartlar, Koşullar ve Gizlilik politikasını kabul ediyorum.", + "RemoveCurrentUserFromOrganizationWarningMessage": "Organizasyondan kendinizi kaldırıyorsunuz. Artık bu organizasyonu yönetemeyeceksiniz, onaylıyor musunuz? ", + "RenewExistingOrganizationOrCreateNewOneMessage": "Aşağıdaki \"Şimdi Uzat\" buton(lar)una tıklayarak organizasyon(lar)ınızın lisansını yenileyebilir ve böylece lisans geçerlilik süresini 1 yıl uzatabilirsiniz. Ödemeye devam ederseniz, yeni bir organizasyonunuz olacak. Yeni bir organizasyonla devam etmek istiyor musunuz? ", + "ExtendNow": "Şimdi Uzat", + "ContinueWithNewOrganization": "Yeni bir organizasyon ile devam et" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ar.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ar.json index 44d5d79aac..751b33613e 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ar.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ar.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "يجب عليك إدخال 3 أحرف على الأقل!", "Volo.AbpIo.Domain:060001": "عنوان URL المصدر (\"{ArticleUrl}\") ليس عنوان URL لـ Github", "Volo.AbpIo.Domain:060002": "محتوى المقالة غير متوفر من مورد Github (\"{ArticleUrl}\").", - "Volo.AbpIo.Domain:060003": "لم يتم العثور على محتوى مقال!" + "Volo.AbpIo.Domain:060003": "لم يتم العثور على محتوى مقال!", + "SeeMore": "شاهد المزيد" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json index 9dc7da3144..f3da536e7e 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Sie müssen mindestens 3 Zeichen eingeben!", "Volo.AbpIo.Domain:060001": "Quell-URL(\"{ArticleUrl}\") ist keine Github-URL", "Volo.AbpIo.Domain:060002": "Artikelinhalt ist über die Github(\"{ArticleUrl}\")-Ressource nicht verfügbar.", - "Volo.AbpIo.Domain:060003": "Kein Artikelinhalt gefunden!" + "Volo.AbpIo.Domain:060003": "Kein Artikelinhalt gefunden!", + "SeeMore": "Mehr Sehen" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en-GB.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en-GB.json index 652090d864..5925ffb172 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en-GB.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en-GB.json @@ -101,6 +101,7 @@ "ArticleRequestMessageTitle": "Open an issue on the GitHub to request an article/tutorial you want to see on this web site.", "ArticleRequestMessageBody": "Here is the list of the requested articles by the Community. Do you want to write a requested article? Please click on the request and join the discussion.", "Language": "Language", - "CreateArticleLanguageInfo": "The language in which the article is written" + "CreateArticleLanguageInfo": "Language of the article", + "SeeMore": "See More" } -} \ No newline at end of file +} diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json index 2da4a62481..16a86cac37 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "You must enter at least 3 characters!", "Volo.AbpIo.Domain:060001": "Source URL(\"{ArticleUrl}\") is not Github URL", "Volo.AbpIo.Domain:060002": "Article Content is not available from Github(\"{ArticleUrl}\") resource.", - "Volo.AbpIo.Domain:060003": "No article content found!" + "Volo.AbpIo.Domain:060003": "No article content found!", + "SeeMore": "See More" } } diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json index 7b34e043a7..3066263e8b 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "¡Debes ingresar al menos 3 caracteres!", "Volo.AbpIo.Domain:060001": "La URL de origen (\"{ArticleUrl}\") no es la URL de Github", "Volo.AbpIo.Domain:060002": "El contenido del artículo no está disponible en el recurso de Github (\"{ArticleUrl}\").", - "Volo.AbpIo.Domain:060003": "¡No se encontró contenido del artículo!" + "Volo.AbpIo.Domain:060003": "¡No se encontró contenido del artículo!", + "SeeMore": "Ver Más" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fi.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fi.json index 2c09984774..435ac1ef92 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fi.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fi.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Sinun on annettava vähintään 3 merkkiä!", "Volo.AbpIo.Domain:060001": "Lähteen URL-osoite (\"{ArticleUrl}\") ei ole Githubin URL-osoite", "Volo.AbpIo.Domain:060002": "Artikkelin sisältö ei ole saatavilla Githubin (\"{ArticleUrl}\") -resurssista.", - "Volo.AbpIo.Domain:060003": "Artikkelin sisältöä ei löytynyt!" + "Volo.AbpIo.Domain:060003": "Artikkelin sisältöä ei löytynyt!", + "SeeMore": "Katso Lisää" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fr.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fr.json index 42f239f987..cbeb8ae084 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fr.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/fr.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Vous devez saisir au moins 3 caractères!", "Volo.AbpIo.Domain:060001": "L'URL source (\"{ArticleUrl}\") n'est pas une URL Github", "Volo.AbpIo.Domain:060002": "Le contenu de l'article n'est pas disponible à partir de la ressource Github(\"{ArticleUrl}\").", - "Volo.AbpIo.Domain:060003": "Aucun contenu d'article trouvé !" + "Volo.AbpIo.Domain:060003": "Aucun contenu d'article trouvé !", + "SeeMore": "Voir Plus" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/hi.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/hi.json index aa351262ca..1e8d5a9e9f 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/hi.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/hi.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "आपको कम से कम 3 वर्ण दर्ज करने होंगे!", "Volo.AbpIo.Domain:060001": "स्रोत URL (\"{ArticleUrl}\") जीथब URL नहीं है", "Volo.AbpIo.Domain:060002": "लेख सामग्री Github (\"{ArticleUrl}\") संसाधन से उपलब्ध नहीं है।", - "Volo.AbpIo.Domain:060003": "कोई लेख सामग्री नहीं मिली!" + "Volo.AbpIo.Domain:060003": "कोई लेख सामग्री नहीं मिली!", + "SeeMore": "और देखें" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/is.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/is.json index fd128eb596..7c8f3f2fba 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/is.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/is.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Þú verður að slá inn að minnsta kosti 3 stafi!", "Volo.AbpIo.Domain:060001": "Upprunaslóð (\"{ArticleUrl} \") er ekki Github slóð", "Volo.AbpIo.Domain:060002": "Innihald greinar er ekki fáanlegt frá Github (\"{ArticleUrl} \") resoursum.", - "Volo.AbpIo.Domain:060003": "Innihald greinar fannst ekki!" + "Volo.AbpIo.Domain:060003": "Innihald greinar fannst ekki!", + "SeeMore": "Sjá Meira" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/it.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/it.json index f104045682..1b305d9b4a 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/it.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/it.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Devi inserire almeno 3 caratteri!", "Volo.AbpIo.Domain:060001": "Source URL(\"{ArticleUrl}\") non è un URL di GitHub", "Volo.AbpIo.Domain:060002": "Il contenuto dell'articolo non è disponibile dalla risorsa Github(\"{ArticleUrl}\").", - "Volo.AbpIo.Domain:060003": "Nessun contenuto dell'articolo trovato!" + "Volo.AbpIo.Domain:060003": "Nessun contenuto dell'articolo trovato!", + "SeeMore": "Vedi Altro" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ro-RO.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ro-RO.json index 4c78f15d99..a15a1bc102 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ro-RO.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/ro-RO.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Trebuie să introduceţi cel putin 3 caractere!", "Volo.AbpIo.Domain:060001": "Sursa URL(\"{ArticleUrl}\") nu este URL GitHub", "Volo.AbpIo.Domain:060002": "Conţinutul articolului nu este disponibil din resursa de pe GitHub(\"{ArticleUrl}\").", - "Volo.AbpIo.Domain:060003": "Nu a fost găsit conţinutul articolului!" + "Volo.AbpIo.Domain:060003": "Nu a fost găsit conţinutul articolului!", + "SeeMore": "Vezi mai mult" } } diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/sk.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/sk.json index e01e201969..3a2b2e5f1d 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/sk.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/sk.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "Musíte zadať aspoň 3 znaky!", "Volo.AbpIo.Domain:060001": "Zdrojová URL(\"{ArticleUrl}\") nie je URL Githubu", "Volo.AbpIo.Domain:060002": "Obsah článku nie je dostupný v Github zdroji(\"{ArticleUrl}\").", - "Volo.AbpIo.Domain:060003": "Nenašiel sa žiadny obsah článku!" + "Volo.AbpIo.Domain:060003": "Nenašiel sa žiadny obsah článku!", + "SeeMore": "Vidět Víc" } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/zh-Hans.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/zh-Hans.json index f504842e70..15dd748d6e 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/zh-Hans.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/zh-Hans.json @@ -142,6 +142,7 @@ "MinimumSearchContent": "您必须输入至少 3 个字符!", "Volo.AbpIo.Domain:060001": "源 URL(\"{ArticleUrl}\") 不是 Github URL", "Volo.AbpIo.Domain:060002": "文章内容无法从 Github(\"{ArticleUrl}\") 资源中获得。", - "Volo.AbpIo.Domain:060003": "没有找到文章内容!" + "Volo.AbpIo.Domain:060003": "没有找到文章内容!", + "SeeMore": "查看更多" } } \ No newline at end of file diff --git a/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/POST.md b/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/POST.md index e1bc93e23a..32ab4684f2 100644 --- a/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/POST.md +++ b/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/POST.md @@ -127,13 +127,7 @@ First of all, you need to have EF Core or MongoDB installed into your solution. #### Install the packages -Install the new [Volo.Abp.EventBus.Boxes](https://www.nuget.org/packages/Volo.Abp.EventBus.Boxes) NuGet package to your database layer (to `EntityFrameworkCore` or `MongoDB` project) or to the host application. Open a command-line terminal at the root directory of your database (or host) project and execute the following command: - -````csharp -abp add-package Volo.Abp.EventBus.Boxes -```` - -This will install the package and setup the ABP module dependency. This package depends on [DistributedLock.Core](https://www.nuget.org/packages/DistributedLock.Core) library which provides a distributed locking system for concurrency control in a distributed environment. There are [many distributed lock providers](https://github.com/madelson/DistributedLock#implementations), including Redis, SqlServer and ZooKeeper. You can use the one you like. Here, I will show the Redis provider. +For the outbox & inbox functionality, ABP depends on [DistributedLock.Core](https://www.nuget.org/packages/DistributedLock.Core) library which provides a distributed locking system for concurrency control in a distributed environment. There are [many distributed lock providers](https://github.com/madelson/DistributedLock#implementations), including Redis, SqlServer and ZooKeeper. You can use the one you like. Here, I will show the Redis provider. Add [DistributedLock.Redis](https://www.nuget.org/packages/DistributedLock.Redis) NuGet package to your project, then add the following code into the ConfigureService method of your ABP module class: @@ -285,6 +279,16 @@ This can be a breaking change in rare cases (for example, if you create host sid ## Community News +### ABP Community Talks 2021.12 + +![community-talks](community-talks.png) + +As the core ABP development team, we've decided to organize monthly live meetings with the ABP community. The first live meeting will be at **December 16, 2021, 17:00 (UTC)** on YouTube. ABP core team members will present some of the new features coming with ABP 5.0. + +**Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-4afca9c9** + +You can also [subscribe to the Volosoft channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders for further ABP events and videos. + ### ABP was on ASP.NET Community Startup! It was great for us to be invited to Microsoft's [ASP.NET Community Weekly Standup](https://dotnet.microsoft.com/live/community-standup) show, at September 28. There was a very high attention and that made us very happy. Thanks to the ABP Community and all the watchers :) If you've missed the talk, [you can watch it here](https://www.youtube.com/watch?v=vMWM-_ihjwM). diff --git a/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/community-talks.png b/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/community-talks.png new file mode 100644 index 0000000000..4056d1afb8 Binary files /dev/null and b/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/community-talks.png differ diff --git a/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/cover-50.png b/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/cover-50.png new file mode 100644 index 0000000000..bd343e70b0 Binary files /dev/null and b/docs/en/Blog-Posts/2021-11-18 v5_0_Preview/cover-50.png differ diff --git a/docs/en/Blog-Posts/2021-12-15 v5_0_Release_Stable/POST.md b/docs/en/Blog-Posts/2021-12-15 v5_0_Release_Stable/POST.md new file mode 100644 index 0000000000..329db94af3 --- /dev/null +++ b/docs/en/Blog-Posts/2021-12-15 v5_0_Release_Stable/POST.md @@ -0,0 +1,47 @@ +# ABP.IO Platform 5.0 Final Has Been Released! + +[ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) 5.0 versions have been released today. + +## What's new with 5.0? + +Since all the new features are already explained in details with the [5.0 RC.1 Announcement Post](https://blog.abp.io/abp/ABP-IO-Platform-5.0-RC-1-Has-Been-Released), I will not repeat all the details again. See the [RC Blog Post](https://blog.abp.io/abp/ABP-IO-Platform-5.0-RC-1-Has-Been-Released) for all the features and enhancements. + +## Getting started with 5.0 + +### Creating new solutions + +You can create a new solution with the ABP Framework version 5.0 by either using the `abp new` command or using the **direct download** tab on the [get started page](https://abp.io/get-started). + +Type the following command in a command-line terminal to install the ABP CLI version 5.0: + +````bash +dotnet tool install -g Volo.Abp.Cli --version 5.0.0 +```` + +To upgrade your existing ABP CLI installation: + +````bash +dotnet tool update -g Volo.Abp.Cli --version 5.0.0 +```` + +Then you can create a new solution using the `abp new` command: + +````bash +abp new Acme.BookStore +```` + +> See the [getting started document](https://docs.abp.io/en/abp/latest/Getting-Started) for details. + +### Upgrading existing solutions + +Check [the migration guide](https://docs.abp.io/en/abp/latest/Migration-Guides/Abp-5_0) for the applications with the version 4.x upgrading to the version 5.0. Also see [the upgrading guide](https://docs.abp.io/en/abp/latest/Upgrading) to understand how to update existing solutions. + +## ABP Community Talks 2021.12 + +![community-talks](community-talks.png) + +As the core ABP development team, we've decided to organize monthly live meetings with the ABP community. The first live meeting will be at **December 16, 2021, 17:00 (UTC)** on YouTube. ABP core team members will present some of the new features coming with ABP 5.0. + +**Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-4afca9c9** + +See you in the event! diff --git a/docs/en/Blog-Posts/2021-12-15 v5_0_Release_Stable/community-talks.png b/docs/en/Blog-Posts/2021-12-15 v5_0_Release_Stable/community-talks.png new file mode 100644 index 0000000000..4056d1afb8 Binary files /dev/null and b/docs/en/Blog-Posts/2021-12-15 v5_0_Release_Stable/community-talks.png differ diff --git a/docs/en/Community-Articles/2021-06-17-Using-Elsa-Workflow-with-ABP-Framework/POST.md b/docs/en/Community-Articles/2021-06-17-Using-Elsa-Workflow-with-ABP-Framework/POST.md index 1a07d744e7..5880406ffb 100644 --- a/docs/en/Community-Articles/2021-06-17-Using-Elsa-Workflow-with-ABP-Framework/POST.md +++ b/docs/en/Community-Articles/2021-06-17-Using-Elsa-Workflow-with-ABP-Framework/POST.md @@ -241,8 +241,9 @@ private void ConfigureElsa(ServiceConfigurationContext context, IConfiguration c .WithExposedHeaders("Content-Disposition")) ); - //register controllers inside elsa - context.Services.AddAssemblyOf(); + //Uncomment the below line if your abp version is lower than v4.4 to register controllers of Elsa . + //See https://github.com/abpframework/abp/pull/9299 (we will no longer need to specify this line of code from v4.4) + // context.Services.AddAssemblyOf(); //Disable antiforgery validation for elsa Configure(options => @@ -269,11 +270,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex } ``` -* In here we've specified the Elsa Server Api's assembly by using the `AddAssemblyOf<>` extension method to register the required services (controllers). These services required for the dashboard (if we create a workflow by using **Elsa Workflow Designer** it calls some services under the hook, therefore we need to be assured about these services get registered). - -* With [v4.4](https://github.com/abpframework/abp/pull/9299), we will no longer need to specify this line of code. - -> **Note:** `AddAssemblyOf<>` extension method can help you to register all your services by convention. You can check [here](https://docs.abp.io/en/abp/latest/Dependency-Injection#conventional-registration) for more information about conventional registration. +* These services required for the dashboard. * We don't need to register our workflows one by one anymore. Because now we use `.AddWorkflowsFrom()`, and this registers workflows on our behalf. @@ -371,12 +368,14 @@ namespace ElsaDemo.Permissions - + - + + + ``` diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md new file mode 100644 index 0000000000..6abf984298 --- /dev/null +++ b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/POST.md @@ -0,0 +1,1671 @@ +# Many to Many Relationship with ABP and EF Core + +## Introduction + +In this article, we'll create a **BookStore** application like in [the ABP tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC&DB=EF) and add an extra `Category` feature to demonstrate how we can manage the many-to-many relationship with ABP-based applications (by following DDD rules). + +You can see the ER Diagram of our application below. This diagram will be helpful for us to demonstrate the relations between our entities. + +![ER-Diagram](./er-diagram.png) + +When we've examined the ER Diagram, we can see the one-to-many relationship between the **Author** and the **Book** tables. Also, the many-to-many relationship (**BookCategory** table) between the **Book** and the **Category** tables. (There can be more than one category on each book and vice-versa in our scenario). + +### Source Code + +You can find the source code of the application at https://github.com/EngincanV/ABP-Many-to-Many-Relationship-Demo . + +### Demo of the Final Application + +At the end of this article, we will have created an application same as in the gif below. + +![Demo of The Final Application](./application-final-demo.gif) + +## Creating the Solution + +In this article, we will create a new startup template with EF Core as a database provider and MVC for UI framework. + +* We can create a new startup template by using the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI): + +```bash +abp new BookStore -t app --version 5.0.0-beta.2 +``` + +* Our project boilerplate will be ready after the download is finished. Then, we can open the solution and start developing. + +## Starting the Development + +Let's start with creating our Domain Entities. + +### Step 1 - (Creating the Domain Entities) + +We can create a folder-structure under the `BookStore.Domain` project like in the image below. + +![Domain-Layer-Folder-Structure](./domain-file-structure.png) + +Open the entity classes and add the following codes to each of these classes. + +* **Author.cs** + +```csharp +using System; +using JetBrains.Annotations; +using Volo.Abp; +using Volo.Abp.Domain.Entities.Auditing; + +namespace BookStore.Authors +{ + public class Author : FullAuditedAggregateRoot + { + public string Name { get; private set; } + + public DateTime BirthDate { get; set; } + + public string ShortBio { get; set; } + + /* This constructor is for deserialization / ORM purpose */ + private Author() + { + } + + public Author(Guid id, [NotNull] string name, DateTime birthDate, [CanBeNull] string shortBio = null) + : base(id) + { + SetName(name); + BirthDate = birthDate; + ShortBio = shortBio; + } + + public void SetName([NotNull] string name) + { + Name = Check.NotNullOrWhiteSpace( + name, + nameof(name), + maxLength: AuthorConsts.MaxNameLength + ); + } + } +} +``` + +> We'll create the `AuthorConsts` class later in this step. + +* **Book.cs** + +```csharp +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using Volo.Abp; +using Volo.Abp.Domain.Entities.Auditing; + +namespace BookStore.Books +{ + public class Book : FullAuditedAggregateRoot + { + public Guid AuthorId { get; set; } + + public string Name { get; private set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + + public ICollection Categories { get; private set; } + + private Book() + { + } + + public Book(Guid id, Guid authorId, string name, DateTime publishDate, float price) + : base(id) + { + AuthorId = authorId; + SetName(name); + PublishDate = publishDate; + Price = price; + + Categories = new Collection(); + } + + public void SetName(string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), BookConsts.MaxNameLength); + } + + public void AddCategory(Guid categoryId) + { + Check.NotNull(categoryId, nameof(categoryId)); + + if (IsInCategory(categoryId)) + { + return; + } + + Categories.Add(new BookCategory(bookId: Id, categoryId)); + } + + public void RemoveCategory(Guid categoryId) + { + Check.NotNull(categoryId, nameof(categoryId)); + + if (!IsInCategory(categoryId)) + { + return; + } + + Categories.RemoveAll(x => x.CategoryId == categoryId); + } + + public void RemoveAllCategoriesExceptGivenIds(List categoryIds) + { + Check.NotNullOrEmpty(categoryIds, nameof(categoryIds)); + + Categories.RemoveAll(x => !categoryIds.Contains(x.CategoryId)); + } + + public void RemoveAllCategories() + { + Categories.RemoveAll(x => x.BookId == Id); + } + + private bool IsInCategory(Guid categoryId) + { + return Categories.Any(x => x.CategoryId == categoryId); + } + } +} +``` + +* In our scenario, a book can have more than one category and a category can have more than one book so we need to create a many-to-many relationship between them. + +* For achieving this, we will create a **join entity** named `BookCategory`, and this class will simply have variables named `BookId` and `CategoryId`. + +* To manage this **join entity**, we can add it as a sub-collection to the **Book** entity, as we do above. We add this sub-collection +to **Book** class instead of **Category** class, because a book can have tens (or mostly hundreds) of categories but on the other perspective a category can have more than a hundred (or even way much) books inside of it. + +* It is a significant performance problem to load thousands of items whenever you query a category. Therefore it makes much more sense to add that sub-collection to the `Book` entity. + +> Don't forget: **Aggregate is a pattern in Domain-Driven Design. A DDD aggregate is a cluster of domain objects that can be treated as a single unit.** (See the full [description](https://martinfowler.com/bliki/DDD_Aggregate.html)) + +* Notice that, `BookCategory` is not an **Aggregate Root** so we are not violating one of the base rules about Aggregate Root (Rule: **"Reference Other Aggregates Only by ID"**). + +* If we examine the methods in the `Book` class (such as **RemoveAllCategories**, **RemoveAllCategoriesExceptGivenIds** and **AddCategory**) we will manage our sub-collection `Categories` (**BookCategory** - join table/entity) through them. (Adds or removes categories for books) + +> We'll create the `BookCategory` and `BookConsts` classes later in this step. + +* **BookCategory.cs** + +```csharp +using System; +using Volo.Abp.Domain.Entities; + +namespace BookStore.Books +{ + public class BookCategory : Entity + { + public Guid BookId { get; protected set; } + + public Guid CategoryId { get; protected set; } + + /* This constructor is for deserialization / ORM purpose */ + private BookCategory() + { + } + + public BookCategory(Guid bookId, Guid categoryId) + { + BookId = bookId; + CategoryId = categoryId; + } + + public override object[] GetKeys() + { + return new object[] {BookId, CategoryId}; + } + } +} +``` + +* Here, as you can notice, we've defined the `BookCategory` as the **Join Table/Entity** for our many-to-many relationship and ensured the required properties (BookId and CategoryId) were set in the constructor method of this class to create this object. + +* And also we've derived this class from the `Entity` class and therefore we've had to override the **GetKeys** method of this class to define the **Composite Key**. + +> The composite key is composed of `BookId` and `CategoryId` in our case. And they are unique together. + +> For more information about **Entities with Composite Keys**, you can read the relevant section from [Entities documentation](https://docs.abp.io/en/abp/latest/Entities#entities-with-composite-keys). + +* **BookManager.cs** + +```csharp +using System; +using System.Linq; +using System.Threading.Tasks; +using BookStore.Categories; +using JetBrains.Annotations; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; + +namespace BookStore.Books +{ + public class BookManager : DomainService + { + private readonly IBookRepository _bookRepository; + private readonly IRepository _categoryRepository; + + public BookManager(IBookRepository bookRepository, IRepository categoryRepository) + { + _bookRepository = bookRepository; + _categoryRepository = categoryRepository; + } + + public async Task CreateAsync(Guid authorId, string name, DateTime publishDate, float price, [CanBeNull]string[] categoryNames) + { + var book = new Book(GuidGenerator.Create(), authorId, name, publishDate, price); + + await SetCategoriesAsync(book, categoryNames); + + await _bookRepository.InsertAsync(book); + } + + public async Task UpdateAsync( + Book book, + Guid authorId, + string name, + DateTime publishDate, + float price, + [CanBeNull] string[] categoryNames + ) + { + book.AuthorId = authorId; + book.SetName(name); + book.PublishDate = publishDate; + book.Price = price; + + await SetCategoriesAsync(book, categoryNames); + + await _bookRepository.UpdateAsync(book); + } + + private async Task SetCategoriesAsync(Book book, [CanBeNull] string[] categoryNames) + { + if (categoryNames == null || !categoryNames.Any()) + { + book.RemoveAllCategories(); + return; + } + + var query = (await _categoryRepository.GetQueryableAsync()) + .Where(x => categoryNames.Contains(x.Name)) + .Select(x => x.Id) + .Distinct(); + + var categoryIds = await AsyncExecuter.ToListAsync(query); + if (!categoryIds.Any()) + { + return; + } + + book.RemoveAllCategoriesExceptGivenIds(categoryIds); + + foreach (var categoryId in categoryIds) + { + book.AddCategory(categoryId); + } + } + } +} +``` + +* If we examine the codes in the `BookManager` class, we can see that we've managed the `BookCategory` class (our join table/entity) by using some methods that we've defined in the `Book` class such as **RemoveAllCategories**, **RemoveAllCategoriesExceptGivenIds** and **AddCategory**. + +* These methods basically add or remove categories related to the book by conditions. + +* In the `CreateAsync` method, if the category names are specified, we'll retrieve their ids from the database and by using the **AddCategory** method that we've defined in the `Book` class, we'll add them. + +* In the `UpdateAsync` method, the same logic is also valid. But in this case, the user might want to remove some categories from books, so if the user sends us an empty **categoryNames** array, we remove all categories from the book he wants to update. If the user sends us some category names, we remove the excluded ones and add the new ones according to the **categoryNames** array. + +* **BookWithDetails.cs** + +```csharp +using System; +using Volo.Abp.Auditing; + +namespace BookStore.Books +{ + public class BookWithDetails : IHasCreationTime + { + public Guid Id { get; set; } + + public string Name { get; set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + + public string AuthorName { get; set; } + + public string[] CategoryNames { get; set; } + + public DateTime CreationTime { get; set; } + } +} +``` + +We will use this class to retrieve books with their sub-categories and author names. + +* **IBookRepository.cs** + +```csharp +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace BookStore.Books +{ + public interface IBookRepository : IRepository + { + Task> GetListAsync( + string sorting, + int skipCount, + int maxResultCount, + CancellationToken cancellationToken = default + ); + + Task GetAsync(Guid id, CancellationToken cancellationToken = default); + } +} +``` + +We need to create two methods named **GetListAsync** and **GetAsync** and specify their return type as `BookWithDetails`. So by implementing these methods, we will return the book/books by their details (author name and categories). + +* **Category.cs** + +```csharp +using System; +using Volo.Abp; +using Volo.Abp.Domain.Entities.Auditing; + +namespace BookStore.Categories +{ + public class Category : AuditedAggregateRoot + { + public string Name { get; private set; } + + /* This constructor is for deserialization / ORM purpose */ + private Category() + { + } + + public Category(Guid id, string name) : base(id) + { + SetName(name); + } + + public Category SetName(string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), CategoryConsts.MaxNameLength); + return this; + } + } +} +``` + +After defining our entities we can seed initial data to our database by using the [Data Seeding](https://docs.abp.io/en/abp/5.0/Data-Seeding#data-seeding) system of the ABP framework. We will create initial data for both the `Category` and `Author` entities because we will not create CRUD pages for these entities. + +> We will create only CRUD pages for the Book entity therefore we don't need to add initial data for the Book entity. We can create a new book by using the create modal of the Book page. (We will create it in the sixth step.) + +Create a class named `BookStoreDataSeederContributor` in your `*.Domain` project and update with the following code: + +* **BookStoreDataSeederContributor.cs** + +```csharp +using System; +using System.Threading.Tasks; +using BookStore.Authors; +using BookStore.Categories; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; + +namespace BookStore +{ + public class BookStoreDataSeederContributor : IDataSeedContributor, ITransientDependency + { + private readonly IGuidGenerator _guidGenerator; + private readonly IRepository _categoryRepository; + private readonly IRepository _authorRepository; + + public BookStoreDataSeederContributor( + IGuidGenerator guidGenerator, + IRepository categoryRepository, + IRepository authorRepository + ) + { + _guidGenerator = guidGenerator; + _categoryRepository = categoryRepository; + _authorRepository = authorRepository; + } + + public async Task SeedAsync(DataSeedContext context) + { + await SeedCategoriesAsync(); + await SeedAuthorsAsync(); + } + + private async Task SeedCategoriesAsync() + { + if (await _categoryRepository.GetCountAsync() <= 0) + { + await _categoryRepository.InsertAsync( + new Category(_guidGenerator.Create(), "History") + ); + + await _categoryRepository.InsertAsync( + new Category(_guidGenerator.Create(), "Unknown") + ); + + await _categoryRepository.InsertAsync( + new Category(_guidGenerator.Create(), "Adventure") + ); + + await _categoryRepository.InsertAsync( + new Category(_guidGenerator.Create(), "Action") + ); + + await _categoryRepository.InsertAsync( + new Category(_guidGenerator.Create(), "Crime") + ); + + await _categoryRepository.InsertAsync( + new Category(_guidGenerator.Create(), "Dystopia") + ); + } + } + + private async Task SeedAuthorsAsync() + { + if (await _authorRepository.GetCountAsync() <= 0) + { + await _authorRepository.InsertAsync( + new Author( + _guidGenerator.Create(), + "George Orwell", + new DateTime(1903, 06, 25), + "Orwell produced literary criticism and poetry, fiction and polemical journalism; and is best known for the allegorical novella Animal Farm (1945) and the dystopian novel Nineteen Eighty-Four (1949)." + ) + ); + + await _authorRepository.InsertAsync( + new Author( + _guidGenerator.Create(), + "Dan Brown", + new DateTime(1964, 06, 22), + "Daniel Gerhard Brown (born June 22, 1964) is an American author best known for his thriller novels" + ) + ); + } + } + } +} +``` + +### Step 2 - (Define Consts) + +We can create a folder-structure under the `BookStore.Domain.Shared` project like in the image below. + +![Domain Shared File Structure](./domain-shared-file-structure.png) + +* **AuthorConsts.cs** + +```csharp +namespace BookStore.Authors +{ + public class AuthorConsts + { + public const int MaxNameLength = 128; + + public const int MaxShortBioLength = 256; + } +} +``` + +* **BookConsts.cs** + +```csharp +namespace BookStore.Books +{ + public class BookConsts + { + public const int MaxNameLength = 128; + } +} +``` + +* **CategoryConsts.cs** + +```csharp +namespace BookStore.Categories +{ + public class CategoryConsts + { + public const int MaxNameLength = 64; + } +} +``` + +In these classes, we've defined max text length for our entity properties that we will use in the **Database Integration** section to specify limits for our properties. (E.g. varchar(128) for BookName) + +### Step 3 - (Database Integration) + +After defining our entities, we can configure them for the database integration. +Open the `BookStoreDbContext` class in the `BookStore.EntityFrameworkCore` project and update the following code blocks. + +```csharp +namespace BookStore.EntityFrameworkCore +{ + [ReplaceDbContext(typeof(IIdentityDbContext))] + [ReplaceDbContext(typeof(ITenantManagementDbContext))] + [ConnectionStringName("Default")] + public class BookStoreDbContext : + AbpDbContext, + IIdentityDbContext, + ITenantManagementDbContext + { + //... + + //DbSet properties for our Aggregate Roots + public DbSet Authors { get; set; } + public DbSet Books { get; set; } + public DbSet Categories { get; set; } + + //NOTE: We don't need to add DbSet, because we will be query it via using the Book entity + // public DbSet BookCategories { get; set; } + + //... + + protected override void OnModelCreating(ModelBuilder builder) + { + //... + + /* Configure your own tables/entities inside here */ + builder.Entity(b => + { + b.ToTable(BookStoreConsts.DbTablePrefix + "Authors" + BookStoreConsts.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Name) + .HasMaxLength(AuthorConsts.MaxNameLength) + .IsRequired(); + + b.Property(x => x.ShortBio) + .HasMaxLength(AuthorConsts.MaxShortBioLength) + .IsRequired(); + }); + + builder.Entity(b => + { + b.ToTable(BookStoreConsts.DbTablePrefix + "Books" + BookStoreConsts.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Name) + .HasMaxLength(BookConsts.MaxNameLength) + .IsRequired(); + + //one-to-many relationship with Author table + b.HasOne().WithMany().HasForeignKey(x => x.AuthorId).IsRequired(); + + //many-to-many relationship with Category table => BookCategories + b.HasMany(x => x.Categories).WithOne().HasForeignKey(x => x.BookId).IsRequired(); + }); + + builder.Entity(b => + { + b.ToTable(BookStoreConsts.DbTablePrefix + "Categories" + BookStoreConsts.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Name) + .HasMaxLength(CategoryConsts.MaxNameLength) + .IsRequired(); + }); + + builder.Entity(b => + { + b.ToTable(BookStoreConsts.DbTablePrefix + "BookCategories" + BookStoreConsts.DbSchema); + b.ConfigureByConvention(); + + //define composite key + b.HasKey(x => new { x.BookId, x.CategoryId }); + + //many-to-many configuration + b.HasOne().WithMany(x => x.Categories).HasForeignKey(x => x.BookId).IsRequired(); + b.HasOne().WithMany().HasForeignKey(x => x.CategoryId).IsRequired(); + + b.HasIndex(x => new { x.BookId, x.CategoryId }); + }); + } + } +} +``` + +* In this class, we've defined the **DbSet** properties for our **Aggregate Roots** (**Book**, **Author** and **Category**). Notice, we didn't define the **DbSet** for the `BookCategory` class (our join table/entity). Because, the `Book` aggregate is responsible for managing it via sub-collection. + +* After that, we can use the **FluentAPI** to configure our tables in the `OnModelCreating` method of this class. + +```csharp +builder.Entity(b => +{ + //... + + //one-to-many relationship with Author table + b.HasOne().WithMany().HasForeignKey(x => x.AuthorId).IsRequired(); + + //many-to-many relationship with Category table => BookCategories + b.HasMany(x => x.Categories).WithOne().HasForeignKey(x => x.BookId).IsRequired(); +}); +``` + +Here, we have provided the one-to-many relationship between the **Book** and the **Author** in the above code-block. + +```csharp +builder.Entity(b => +{ + //... + + //define composite key + b.HasKey(x => new { x.BookId, x.CategoryId }); + + //many-to-many configuration + b.HasOne().WithMany(x => x.Categories).HasForeignKey(x => x.BookId).IsRequired(); + b.HasOne().WithMany().HasForeignKey(x => x.CategoryId).IsRequired(); + + b.HasIndex(x => new { x.BookId, x.CategoryId }); +}); +``` + +Here, firstly we've defined the composite key for our `BookCategory` entity. `BookId` and `CategoryId` are together as composite keys for the `BookCategory` table. Then we've configured the many-to-many relationship between the `Book` and the `Category` tables like in the above code-block. + +#### Implementing the `IBookRepository` Interface + +After making the relevant configurations for the database integration, we can now implement the `IBookRepository` interface. To do this, create a folder named `Books` in the `BookStore.EntityFrameworkCore` project and inside of this folder, create a class named `EfCoreBookRepository` and update this class with the following code: + +```csharp +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading; +using System.Threading.Tasks; +using BookStore.Authors; +using BookStore.Categories; +using BookStore.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace BookStore.Books +{ + public class EfCoreBookRepository : EfCoreRepository, IBookRepository + { + public EfCoreBookRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public async Task> GetListAsync( + string sorting, + int skipCount, + int maxResultCount, + CancellationToken cancellationToken = default + ) + { + var query = await ApplyFilterAsync(); + + return await query + .OrderBy(!string.IsNullOrWhiteSpace(sorting) ? sorting : nameof(Book.Name)) + .PageBy(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async Task GetAsync(Guid id, CancellationToken cancellationToken = default) + { + var query = await ApplyFilterAsync(); + + return await query + .Where(x => x.Id == id) + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + + private async Task> ApplyFilterAsync() + { + var dbContext = await GetDbContextAsync(); + + return (await GetDbSetAsync()) + .Include(x => x.Categories) + .Join(dbContext.Set(), book => book.AuthorId, author => author.Id, + (book, author) => new {book, author}) + .Select(x => new BookWithDetails + { + Id = x.book.Id, + Name = x.book.Name, + Price = x.book.Price, + PublishDate = x.book.PublishDate, + CreationTime = x.book.CreationTime, + AuthorName = x.author.Name, + CategoryNames = (from bookCategories in x.book.Categories + join category in dbContext.Set() on bookCategories.CategoryId equals category.Id + select category.Name).ToArray() + }); + } + + public override Task> WithDetailsAsync() + { + return base.WithDetailsAsync(x => x.Categories); + } + } +} +``` + +* Here, we've implemented our custom repository methods and returned the book with details (author name and categories). + +### Step 4 - (Database Migration) + +* We've integrated our entities with the database in the previous step, now we can create a new database migration and apply it to the database. So let's do that. + +* Open the `BookStore.EntityFrameworkCore` project in the terminal. And create a new database migration by using the following command: + +```bash +dotnet ef migrations add +``` + +* Then, run the `BookStore.DbMigrator` application to create the database. + +### Step 5 - (Create Application Services) + +* Let's start with defining our DTOs and application service interfaces in the `BookStore.Application.Contracts` layer. We can create a folder-structure like in the image below: + +![Application Contracts Folder Structure](./application-contracts-folder-structure.png) + +* We can use the [`CrudAppService`](https://docs.abp.io/en/abp/latest/Application-Services#crud-application-services) base class of the ABP Framework to create application services to **Get**, **Create**, **Update** and **Delete** authors and categories. + +* **AuthorDto.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; + +namespace BookStore.Authors +{ + public class AuthorDto : EntityDto + { + public string Name { get; set; } + + public DateTime BirthDate { get; set; } + + public string ShortBio { get; set; } + } +} +``` + +* **AuthorLookupDto.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; + +namespace BookStore.Authors +{ + public class AuthorLookupDto : EntityDto + { + public string Name { get; set; } + } +} +``` + +We will use this DTO class as output DTO to get all the authors and list them in a select box in the book creation model. (Like in the image below.) + +![Book Create Modal](./book-creation-modal.png) + +* **CreateUpdateAuthorDto.cs** + +```csharp +using System; + +namespace BookStore.Authors +{ + public class CreateUpdateAuthorDto + { + public string Name { get; set; } + + public DateTime BirthDate { get; set; } + + public string ShortBio { get; set; } + } +} +``` + +* **IAuthorAppService.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace BookStore.Authors +{ + public interface IAuthorAppService : + ICrudAppService + { + } +} +``` + +* **BookDto.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; + +namespace BookStore.Books +{ + public class BookDto : EntityDto + { + public string AuthorName { get; set; } + + public string Name { get; set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + + public string[] CategoryNames { get; set; } + } +} +``` + +When listing the Book/Books we will retrieve them with all their details (author name and category names). + +* **BookGetListInput.cs** + +```csharp +using Volo.Abp.Application.Dtos; + +namespace BookStore.Books +{ + public class BookGetListInput : PagedAndSortedResultRequestDto + { + } +} +``` + +* **CreateUpdateBookDto.cs** + +```csharp +using System; + +namespace BookStore.Books +{ + public class CreateUpdateBookDto + { + public Guid AuthorId { get; set; } + + public string Name { get; set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + + public string[] CategoryNames { get; set; } + } +} +``` + +To create or update a book we will use this input DTO. + +* **IBookAppService.cs** + +```csharp +using System; +using System.Threading.Tasks; +using BookStore.Authors; +using BookStore.Categories; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace BookStore.Books +{ + public interface IBookAppService : IApplicationService + { + Task> GetListAsync(BookGetListInput input); + + Task GetAsync(Guid id); + + Task CreateAsync(CreateUpdateBookDto input); + + Task UpdateAsync(Guid id, CreateUpdateBookDto input); + + Task DeleteAsync(Guid id); + + Task> GetAuthorLookupAsync(); + + Task> GetCategoryLookupAsync(); + } +} +``` + +* We will create custom application service method for managing Books instead of using the `CrudAppService`'s methods. + +* Also we will create two additional methods and they are `GetAuthorLookupAsync` and `GetCategoryLookupAsync`. We will use these two methods to retrieve all the authors and categories without pagination and list them as a select box item in create/update modals for the Book page. +(You can see the usage of these two methods in the gif below.) + +![New Book](./book-create.gif) + +* **CategoryDto.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; + +namespace BookStore.Categories +{ + public class CategoryDto : EntityDto + { + public string Name { get; set; } + } +} +``` + +* **CategoryLookupDto.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; + +namespace BookStore.Categories +{ + public class CategoryLookupDto : EntityDto + { + public string Name { get; set; } + } +} +``` + +We will use this DTO class as an output DTO to get all categories without pagination and list them in a select box in the book create/update modals. + +* **CreateUpdateCategoryDto.cs** + +```csharp +namespace BookStore.Categories +{ + public class CreateUpdateCategoryDto + { + public string Name { get; set; } + } +} +``` + +* **ICategoryAppService.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace BookStore.Categories +{ + public interface ICategoryAppService : + ICrudAppService + { + } +} +``` + +After creating the DTOs and application service interfaces, now we can define the implementation of those interfaces. So, we can create a folder-structure like in the image below for the `BookStore.Application` layer. Open the application service classes and add the following codes to each of these classes. + +![Application Folder Structure](./application-folder-structure.png) + +* **AuthorAppService.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace BookStore.Authors +{ + public class AuthorAppService : + CrudAppService, + IAuthorAppService + { + public AuthorAppService(IRepository repository) : base(repository) + { + } + } +} +``` + +* **CategoryAppService.cs** + +```csharp +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace BookStore.Categories +{ + public class CategoryAppService : + CrudAppService, + ICategoryAppService + { + public CategoryAppService(IRepository repository) : base(repository) + { + } + } +} +``` + +Thanks to the `CrudAppService`, we don't need to manually implement the crud methods for **AuthorAppService** and **CategoryAppService**. + +* **BookAppService.cs** + +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using BookStore.Authors; +using BookStore.Categories; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Repositories; + +namespace BookStore.Books +{ + public class BookAppService : BookStoreAppService, IBookAppService + { + private readonly IBookRepository _bookRepository; + private readonly BookManager _bookManager; + private readonly IRepository _authorRepository; + private readonly IRepository _categoryRepository; + + public BookAppService( + IBookRepository bookRepository, + BookManager bookManager, + IRepository authorRepository, + IRepository categoryRepository + ) + { + _bookRepository = bookRepository; + _bookManager = bookManager; + _authorRepository = authorRepository; + _categoryRepository = categoryRepository; + } + + public async Task> GetListAsync(BookGetListInput input) + { + var books = await _bookRepository.GetListAsync(input.Sorting, input.SkipCount, input.MaxResultCount); + var totalCount = await _bookRepository.CountAsync(); + + return new PagedResultDto(totalCount, ObjectMapper.Map, List>(books)); + } + + public async Task GetAsync(Guid id) + { + var book = await _bookRepository.GetAsync(id); + + return ObjectMapper.Map(book); + } + + public async Task CreateAsync(CreateUpdateBookDto input) + { + await _bookManager.CreateAsync( + input.AuthorId, + input.Name, + input.PublishDate, + input.Price, + input.CategoryNames + ); + } + + public async Task UpdateAsync(Guid id, CreateUpdateBookDto input) + { + var book = await _bookRepository.GetAsync(id, includeDetails: true); //return type is: Book (not BookWithDetails) Because, we don't need author name + + await _bookManager.UpdateAsync( + book, + input.AuthorId, + input.Name, + input.PublishDate, + input.Price, + input.CategoryNames + ); + } + + public async Task DeleteAsync(Guid id) + { + await _bookRepository.DeleteAsync(id); + } + + public async Task> GetAuthorLookupAsync() + { + var authors = await _authorRepository.GetListAsync(); + + return new ListResultDto( + ObjectMapper.Map, List>(authors) + ); + } + + public async Task> GetCategoryLookupAsync() + { + var categories = await _categoryRepository.GetListAsync(); + + return new ListResultDto( + ObjectMapper.Map, List>(categories) + ); + } + } +} +``` + +* As you can notice here, we've used our **Domain Service** class named `BookManager` in the **CreateAsync** and **UpdateAsync** methods. (Defined them in step 1) + +* As you may remember, in these methods, new categories are added to the book or removed from the sub-collection (**Categories** (`BookCategory`)) according to the relevant category names. + +* After implementing the application services, we need to define the mappings for our services to work. So open the `BookStoreApplicationAutoMapperProfile` class and update it with the following code: + +```csharp +using AutoMapper; +using BookStore.Authors; +using BookStore.Books; +using BookStore.Categories; + +namespace BookStore +{ + public class BookStoreApplicationAutoMapperProfile : Profile + { + public BookStoreApplicationAutoMapperProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + + CreateMap(); + CreateMap(); + CreateMap(); + + CreateMap(); + } + } +} + +``` + +### Step 6 - (UI) + +The only thing we need to do is, by using the application service methods that we've defined in the previous step to create the UI. + +![Web Folder Structure](./web-folder-structure.png) + +> To keep the article shorter, I'll just show you how to create the Book page (with Create/Edit modals). If you want to implement it to other pages, you can access the source code of the application at https://github.com/EngincanV/ABP-Many-to-Many-Relationship-Demo and copy-paste the relevant code-blocks to your application. + +#### Book Page + +* Create a razor page named **Index.cshtml** under the **Pages/Books** folder of the `BookStore.Web` project and paste the following code to that page. + +* **Index.cshtml** + +```html +@page +@model BookStore.Web.Pages.Books.Index + +@section scripts +{ + +} + + + + + + Books + + + + + + + + + + +``` + +In here we've added a **New Book** button and a table with an id named "BooksTable". We'll create an `Index.js` file and by using [datatable.js](https://datatables.net) we will fill the table with our records. + +* **Index.js** + +```js +$(function () { + var createModal = new abp.ModalManager(abp.appPath + 'Books/CreateModal'); + var editModal = new abp.ModalManager(abp.appPath + 'Books/EditModal'); + + var bookService = bookStore.books.book; + + var dataTable = $('#BooksTable').DataTable( + abp.libs.datatables.normalizeConfiguration({ + serverSide: true, + paging: true, + order: [[1, "asc"]], + searching: false, + scrollX: true, + ajax: abp.libs.datatables.createAjax(bookService.getList), + columnDefs: [ + { + title: 'Actions', + rowAction: { + items: + [ + { + text: 'Edit', + action: function (data) { + editModal.open({ id: data.record.id }); + } + }, + { + text: 'Delete', + confirmMessage: function (data) { + return "Are you sure to delete the book '" + data.record.name +"'?"; + }, + action: function (data) { + bookService + .delete(data.record.id) + .then(function() { + abp.notify.info("Successfully deleted!"); + dataTable.ajax.reload(); + }); + } + } + ] + } + }, + { + title: 'Name', + data: "name" + }, + { + title: 'Publish Date', + data: "publishDate", + render: function (data) { + return luxon + .DateTime + .fromISO(data, { + locale: abp.localization.currentCulture.name + }).toLocaleString(); + } + }, + { + title: 'Author Name', + data: "authorName" + }, + { + title: 'Price', + data: "price" + }, + { + title: 'Categories', + data: "categoryNames", + render: function (data) { + return data.join(", "); + } + } + ] + }) + ); + + createModal.onResult(function () { + dataTable.ajax.reload(); + }); + + editModal.onResult(function () { + dataTable.ajax.reload(); + }); + + $('#NewBookButton').click(function (e) { + e.preventDefault(); + createModal.open(); + }); +}); + +``` + +> `abp.libs.datatables.normalizeConfiguration` is a helper function defined by the ABP Framework. It simplifies the Datatables configuration by providing conventional default values for missing options. + +* Let's examine what we've done in the `Index.js` file. + +* Firstly, we've defined our `createModal` and `editModal` modals by using the [ABP Modals](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Modals). Then, we've created the DataTable and fetched our books by using the dynamic JavaScript proxy function (`bookStore.books.book.getList`) (It sends a request to the **GetListAsync** method that we've defined in the `BookAppService` under the hook) and we've shown them in the table with an id named "BooksTable". + +* Now let's run the application and navigate to the **/Books** route to see how our Book page looks. + +![Demo](./demo.png) + +We need to see a page similar to the image above. Our app is working properly, we can continue developing. + +> If you are stuck in any point, you can examine the [source codes](https://github.com/EngincanV/ABP-Many-to-Many-Relationship-Demo). + +#### Model Classes and Mapping Configurations + +Create a folder named **Models** and add a class named `CategoryViewModel` inside of it. We will use this view modal class to determine which categories are selected or not in our Create/Edit modals. + +* **CategoryViewModel.cs** + +```csharp +using System; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Mvc; + +namespace BookStore.Web.Models +{ + public class CategoryViewModel + { + [HiddenInput] + public Guid Id { get; set; } + + public bool IsSelected { get; set; } + + [Required] + [HiddenInput] + public string Name { get; set; } + } +} +``` + +Then, we can open the `BookStoreWebAutoMapperProfile` class and define the required mappings as follows: + +```csharp +using AutoMapper; +using BookStore.Authors; +using BookStore.Books; +using BookStore.Categories; +using BookStore.Web.Models; +using BookStore.Web.Pages.Books; +using Volo.Abp.AutoMapper; + +namespace BookStore.Web +{ + public class BookStoreWebAutoMapperProfile : Profile + { + public BookStoreWebAutoMapperProfile() + { + CreateMap() + .Ignore(x => x.IsSelected); + + CreateMap(); + + CreateMap(); + + CreateMap(); + } + } +} +``` + +#### Create/Edit Modals + +After creating our index page for Books and configuring mappings, let's continue with creating the Create/Edit modals for Books. + +Create a razor page named **CreateModal.cshtml** (and **CreateModal.cshtml.cs**). + +* **CreateModal.cshtml** + +```html +@page +@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal +@model BookStore.Web.Pages.Books.CreateModal + +@{ + Layout = null; +} + +
+ + + + + +
+ + + + + + +
+
+ +
+ @for (var i = 0; i < Model.Categories.Count; i++) + { + var category = Model.Categories[i]; + + + } +
+
+
+
+ +
+
+``` + +* **CreateModal.cshtml.cs** + +```csharp +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BookStore.Books; +using BookStore.Categories; +using BookStore.Web.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace BookStore.Web.Pages.Books +{ + public class CreateModal : BookStorePageModel + { + [BindProperty] + public CreateUpdateBookDto Book { get; set; } + + [BindProperty] + public List Categories { get; set; } + + public List AuthorList { get; set; } + + private readonly IBookAppService _bookAppService; + + public CreateModal(IBookAppService bookAppService) + { + _bookAppService = bookAppService; + } + + public async Task OnGetAsync() + { + Book = new CreateUpdateBookDto(); + + //Get all authors and fill the select list + var authorLookup = await _bookAppService.GetAuthorLookupAsync(); + AuthorList = authorLookup.Items + .Select(x => new SelectListItem(x.Name, x.Id.ToString())) + .ToList(); + + //Get all categories + var categoryLookupDto = await _bookAppService.GetCategoryLookupAsync(); + Categories = ObjectMapper.Map, List>(categoryLookupDto.Items.ToList()); + } + + public async Task OnPostAsync() + { + ValidateModel(); + + var selectedCategories = Categories.Where(x => x.IsSelected).ToList(); + if (selectedCategories.Any()) + { + var categoryNames = selectedCategories.Select(x => x.Name).ToArray(); + Book.CategoryNames = categoryNames; + } + + await _bookAppService.CreateAsync(Book); + return NoContent(); + } + } +} +``` + +Here, we've got all categories and authors inside of the `OnGetAsync` method. And use them inside of the create modal to list them so the user can choose when creating a new book. + +![Create Book Modal](./book-creation-modal.png) + +* When the user submits the form, the `OnPostAsync` method runs. Inside of this method, we get the selected categories and pass them into the **CategoryNames** array of the Book object and call the `IBookAppService.CreateAsync` method to create a new book. + +Create a razor page named **EditModal.cshtml** (and **EditModal.cshtml.cs**). + +* **EditModal.cshtml** + +```html +@page +@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal +@model BookStore.Web.Pages.Books.EditModal + +@{ + Layout = null; +} + +
+ + + + + +
+ + + + + + + +
+
+ +
+ @for (var i = 0; i < Model.Categories.Count; i++) + { + var category = Model.Categories[i]; + + + } +
+
+
+
+ +
+
+``` + +* **EditModal.cshtml.cs** + +```csharp +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BookStore.Books; +using BookStore.Categories; +using BookStore.Web.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace BookStore.Web.Pages.Books +{ + public class EditModal : BookStorePageModel + { + [HiddenInput] + [BindProperty(SupportsGet = true)] + public Guid Id { get; set; } + + [BindProperty] + public CreateUpdateBookDto EditingBook { get; set; } + + [BindProperty] + public List Categories { get; set; } + + public List AuthorList { get; set; } + + private readonly IBookAppService _bookAppService; + + public EditModal(IBookAppService bookAppService) + { + _bookAppService = bookAppService; + } + + public async Task OnGetAsync() + { + var bookDto = await _bookAppService.GetAsync(Id); + EditingBook = ObjectMapper.Map(bookDto); + + //get all authors + var authorLookup = await _bookAppService.GetAuthorLookupAsync(); + AuthorList = authorLookup.Items + .Select(x => new SelectListItem(x.Name, x.Id.ToString())) + .ToList(); + + //get all categories + var categoryLookupDto = await _bookAppService.GetCategoryLookupAsync(); + Categories = ObjectMapper.Map, List>(categoryLookupDto.Items.ToList()); + + //mark as Selected for Categories in the book + if (EditingBook.CategoryNames != null && EditingBook.CategoryNames.Any()) + { + Categories + .Where(x => EditingBook.CategoryNames.Contains(x.Name)) + .ToList() + .ForEach(x => x.IsSelected = true); + } + } + + public async Task OnPostAsync() + { + ValidateModel(); + + var selectedCategories = Categories.Where(x => x.IsSelected).ToList(); + if (selectedCategories.Any()) + { + var categoryNames = selectedCategories.Select(x => x.Name).ToArray(); + EditingBook.CategoryNames = categoryNames; + } + + await _bookAppService.UpdateAsync(Id, EditingBook); + return NoContent(); + } + } +} +``` + +* As in the `CreateModal.cshtml.cs`, we've got all categories and authors inside of the `OnGetAsync` method. And also we get the book by id and mark the selected categories properties' as `IsSelected = true`. + +* When the user updates the inputs and submits the form, the `OnPostAsync` method runs. Inside of this method, we get the selected categories and pass them into the **CategoryNames** array of the Book object and call the `IBookAppService.UpdateAsync` method to update the book. + +![Edit Book Modal](./book-update-modal.png) + +### Conclusion + +In this article, I've tried to explain how to create a many-to-many relationship by using the ABP framework. (by following DDD principles) + +Thanks for reading this article, I hope it was helpful. diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-contracts-folder-structure.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-contracts-folder-structure.png new file mode 100644 index 0000000000..c0ed574489 Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-contracts-folder-structure.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-final-demo.gif b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-final-demo.gif new file mode 100644 index 0000000000..61289a8ffb Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-final-demo.gif differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-folder-structure.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-folder-structure.png new file mode 100644 index 0000000000..0d37a552d4 Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/application-folder-structure.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-create.gif b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-create.gif new file mode 100644 index 0000000000..0e534802f2 Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-create.gif differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-creation-modal.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-creation-modal.png new file mode 100644 index 0000000000..8661e016cd Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-creation-modal.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-update-modal.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-update-modal.png new file mode 100644 index 0000000000..d9d312399a Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/book-update-modal.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/demo.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/demo.png new file mode 100644 index 0000000000..9b954bd7d6 Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/demo.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/domain-file-structure.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/domain-file-structure.png new file mode 100644 index 0000000000..6a5405dafe Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/domain-file-structure.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/domain-shared-file-structure.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/domain-shared-file-structure.png new file mode 100644 index 0000000000..22a8de6599 Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/domain-shared-file-structure.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/er-diagram.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/er-diagram.png new file mode 100644 index 0000000000..5948366e0e Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/er-diagram.png differ diff --git a/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/web-folder-structure.png b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/web-folder-structure.png new file mode 100644 index 0000000000..ed4a63a06c Binary files /dev/null and b/docs/en/Community-Articles/2021-10-31-Many-to-Many-Relationship-with-ABP-and-EF-Core/web-folder-structure.png differ diff --git a/docs/en/Customizing-Application-Modules-Extending-Entities.md b/docs/en/Customizing-Application-Modules-Extending-Entities.md index c2bcd314d4..e1cb02e849 100644 --- a/docs/en/Customizing-Application-Modules-Extending-Entities.md +++ b/docs/en/Customizing-Application-Modules-Extending-Entities.md @@ -63,8 +63,6 @@ You can then use the same extra properties system defined in the previous sectio Another approach can be **creating your own entity** mapped to **the same database table** (or collection for a MongoDB database). -`AppUser` entity in the [application startup template](Startup-Templates/Application.md) already implements this approach. [EF Core Migrations document](Entity-Framework-Core-Migrations.md) describes how to implement it and manage **EF Core database migrations** in such a case. It is also possible for MongoDB, while this time you won't deal with the database migration problems. - ## Creating a New Entity with Its Own Database Table/Collection Mapping your entity to an **existing table** of a depended module has a few disadvantages; diff --git a/docs/en/Getting-Started-Running-Solution.md b/docs/en/Getting-Started-Running-Solution.md index 3f508589a3..27e6ac3dee 100644 --- a/docs/en/Getting-Started-Running-Solution.md +++ b/docs/en/Getting-Started-Running-Solution.md @@ -139,7 +139,7 @@ Ensure that the `.IdentityServer` project is the startup project. Run the applic > Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. -You can login, but you cannot enter to the main application here. This is just the authentication server. +You can login, but you cannot enter to the main application here. This is **just the authentication server**. Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a Swagger UI: diff --git a/docs/en/Getting-Started.md b/docs/en/Getting-Started.md index b3fd215e35..0304eb2320 100644 --- a/docs/en/Getting-Started.md +++ b/docs/en/Getting-Started.md @@ -15,6 +15,6 @@ This tutorial explains how to **create and run** a new web application using the ABP Framework. Follow the steps below; -1. [Setup your development environment](Getting-Started-Setup-Environment) +1. [Setup your development environment](Getting-Started-Setup-Environment.md) 2. [Creating a new solution](Getting-Started-Create-Solution.md) 3. [Running the solution](Getting-Started-Running-Solution.md) \ No newline at end of file diff --git a/docs/en/Virtual-File-System.md b/docs/en/Virtual-File-System.md index 4fa29f0738..4a13bf5740 100644 --- a/docs/en/Virtual-File-System.md +++ b/docs/en/Virtual-File-System.md @@ -119,7 +119,7 @@ The Virtual File System is well integrated to ASP.NET Core: ### Static Virtual File Folders -By default, ASP.NET Core only allows the `wwwroot` folder to contain the static files consumed by the clients. When you use the birtual File System, the following folders also can contain static files: +By default, ASP.NET Core only allows the `wwwroot` folder to contain the static files consumed by the clients. When you use the virtual File System, the following folders also can contain static files: * Pages * Views diff --git a/docs/zh-Hans/Background-Workers.md b/docs/zh-Hans/Background-Workers.md index a7563349ab..3f0e7fb369 100644 --- a/docs/zh-Hans/Background-Workers.md +++ b/docs/zh-Hans/Background-Workers.md @@ -2,7 +2,6 @@ ## 介绍 -背景工人在应用简单独立的线程在后台运行.一般来说,他们定期运行,以执行一些任务.例子; 后台工作者在应用程序后台运行的简单的独立线程,一般来说它们定期运行执行一些任务.例如; * 后台工作者可以定期**删除过时的日志**. diff --git a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md index 1e676d0c67..f55316739c 100644 --- a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md +++ b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md @@ -1,12 +1,12 @@ -# 在AspNet Core MVC Web Application中使用ABP +# 在ASP.NET Core MVC Web 应用程序中使用ABP -本教程将介绍如何开始以最少的依赖关系开始使用ABP开发. +本教程将介绍如何开始以最少的依赖关系开始使用ABP开发. -通常情况下你需要下载一个 **[启动模板](Getting-Started-AspNetCore-MVC-Template.md)** +通常情况下你希望从 **[启动模板](Getting-Started-AspNetCore-MVC-Template.md)** 开始. ## 创建一个新项目 -1. 使用Visual Studio 2019 (16.4.0+)创建一个新的AspNet Core Web Application: +1. 使用Visual Studio 2022 (17.0.0+)创建一个新的ASP.NET Core Web应用程序: ![](images/create-new-aspnet-core-application-v2.png) @@ -21,7 +21,7 @@ ## 安装 Volo.Abp.AspNetCore.Mvc 包 -Volo.Abp.AspNetCore.Mvc是ABP集成AspNet Core MVC的包,请安装它到你项目中: +Volo.Abp.AspNetCore.Mvc是ABP集成ASP.NET Core MVC的包,请安装它到你项目中: ```` Install-Package Volo.Abp.AspNetCore.Mvc @@ -29,7 +29,7 @@ Install-Package Volo.Abp.AspNetCore.Mvc ## 创建ABP模块 -ABP是一个模块化框架,它需要一个**启动 (根) 模块**继承自``AbpModule``: +ABP是一个模块化框架,它需要一个**启动(根)模块**继承自 `AbpModule`: ````C# using Microsoft.AspNetCore.Builder; @@ -43,21 +43,20 @@ namespace BasicAspNetCoreApplication [DependsOn(typeof(AbpAspNetCoreMvcModule))] public class AppModule : AbpModule { - public override void OnApplicationInitialization( - ApplicationInitializationContext context) + public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); + // Configure the HTTP request pipeline. if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else { app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseConfiguredEndpoints(); @@ -68,49 +67,44 @@ namespace BasicAspNetCoreApplication ``AppModule`` 是应用程序启动模块的好名称. -ABP的包定义了这个模块类,模块可以依赖其它模块.在上面的代码中 ``AppModule`` 依赖于 ``AbpAspNetCoreMvcModule`` (模块存在于[Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc)包中). 安装新的ABP的包后添加``DependsOn``是很常见的做法. +ABP的包定义了模块类,模块可以依赖其它模块.在上面的代码中 ``AppModule`` 依赖于 ``AbpAspNetCoreMvcModule`` (由[Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc)包定义). 安装新的ABP的包后添加``DependsOn``特性是很常见的做法. 我们在此模块类中配置ASP.NET Core管道,而不是Startup类中. ### 启动类 -接下来修改启动类集成ABP模块系统: +接下来修改启动类集成到ABP模块系统: ````C# -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; +using BasicAspNetCoreApplication; -namespace BasicAspNetCoreApplication -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } +var builder = WebApplication.CreateBuilder(args); - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } - } -} +builder.Services.ReplaceConfiguration(builder.Configuration); + +builder.Services.AddApplication(); + +var app = builder.Build(); + +app.InitializeApplication(); + +app.Run(); ```` - -``services.AddApplication()``添加了所有``AppModule``模块中定义的全部服务. -``Configure``方法中的``app.InitializeApplication()``完成初始化并启动应用程序. +``services.AddApplication()``添加了从``AppModule``中启动的所有模块中定义的所有服务. + +``app.InitializeApplication()`` 初始化并启动应用程序. ## 运行应用程序! -启动该应用,它将按预期运行. +启动该应用,它将按预期运行. ## 使用 Autofac 依赖注入框架 -虽然AspNet Core的依赖注入(DI)系统适用于基本要求,但[Autofac](https://autofac.org/)提供了属性注入和方法拦截等高级功能,这些功能是ABP执行高级应用程序框架功能所必需的. +虽然ASP.NET Core的依赖注入(DI)系统适用于基本要求,但[Autofac](https://autofac.org/)提供了属性注入和方法拦截等高级功能,这些功能是ABP执行高级应用程序框架功能所必需的. -用Autofac取代AspNet Core的DI系统并集成到ABP非常简单. +用Autofac取代ASP.NET Core的DI系统并集成到ABP非常简单. 1. 安装 [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) 包 @@ -132,27 +126,21 @@ public class AppModule : AbpModule 3. 修改``Program.cs``以使用Autofac: ````C# -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; +using BasicAspNetCoreApplication; -namespace BasicAspNetCoreApplication -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } +var builder = WebApplication.CreateBuilder(args); - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac(); // 添加这一行 - } -} +builder.Host.UseAutofac(); //Add this line + +builder.Services.ReplaceConfiguration(builder.Configuration); + +builder.Services.AddApplication(); + +var app = builder.Build(); + +app.InitializeApplication(); + +app.Run(); ```` ## 源码 diff --git a/docs/zh-Hans/Getting-Started-Create-Solution.md b/docs/zh-Hans/Getting-Started-Create-Solution.md new file mode 100644 index 0000000000..1ef4879a08 --- /dev/null +++ b/docs/zh-Hans/Getting-Started-Create-Solution.md @@ -0,0 +1,73 @@ +# 入门教程 + +````json +//[doc-params] +{ + "UI": ["MVC", "Blazor", "BlazorServer", "NG"], + "DB": ["EF", "Mongo"], + "Tiered": ["Yes", "No"] +} +```` + +> 本文档假设你更喜欢使用 **{{ UI_Value }}** 作为 UI 框架, 使用 **{{ DB_Value }}** 作为数据库提供程序. 对于其他选项, 请更改本文档顶部的首选项. + +## 创建新项目 + +我们将使用 ABP CLI 创建一个新的 ABP 项目. + +> 或者, 你可以使用[ABP Framework 网站](https://abp.io/get-started)页面上的选项轻松的 **创建并下载** 项目. + +使用 ABP CLI 的 `new` 命令创建一个新项目: + +````shell +abp new Acme.BookStore{{if UI == "NG"}} -u angular{{else if UI == "Blazor"}} -u blazor{{else if UI == "BlazorServer"}} -u blazor-server{{end}}{{if DB == "Mongo"}} -d mongodb{{end}}{{if Tiered == "Yes"}}{{if UI == "MVC" || UI == "BlazorServer"}} --tiered{{else}} --separate-identity-server{{end}}{{end}} +```` + +*你可以使用不同级别的命名空间, 例如: BookStore、Acme.BookStore或 Acme.Retail.BookStore.* + +{{ if Tiered == "Yes" }} + +{{ if UI == "MVC" || UI == "BlazorServer" }} + +* `--tified` 参数用于创建认证服务器、 UI 和 API 实际分隔的 N-层解决方案. + +{{ else }} + +* `--separate-identity-server` 参数用于将Identity Server应用程序与API主机应用程序分隔开. 如果未指定, 则服务器上将只有一个端点. + +{{ end }} + +{{ end }} + +> [ABP CLI 文档](./CLI.md) 涵盖了所有可用的命令和选项. + +## 移动端开发 + +如果你想要在你的解决方案中包含 [React Native](https://reactnative.dev/) 项目, 将 `-m react-native` (or `--mobile react-native`) 参数添加到项目创建命令. 这是一个基础的 React Native 启动模板, 用于开发基于你的 ABP 后端的移动应用程序. + +请参阅 [React Native 入门](Getting-Started-React-Native.md) 文档, 了解如何配置和运行 React Native 应用程序. + +### 解决方案结构 + +该解决方案具有分层结构 (基于 [域驱动设计](Domain-Driven-Design.md)), 并包含单元 & 集成测试项目. 请参阅 [应用程序模板文档](Startup-Templates/Application.md) 以详细了解解决方案结构. + +{{ if DB == "Mongo" }} + +#### MongoDB 事务 + +[启动模板](Startup-templates/Index.md) 默认在`.MongoDB`项目中**禁用**事务. 如果你的MongoDB服务器支持事务, 你可以在*YourProjectMongoDbModule*类中的`ConfigureServices`方法开启它: + + ```csharp +Configure(options => +{ + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Auto; +}); + ``` + +> 或者你可以删除该代码, 因为 `Auto` 已经是默认行为. + +{{ end }} + +## 下一步 + +* [运行解决方案](Getting-Started-Running-Solution.md) \ No newline at end of file diff --git a/docs/zh-Hans/Getting-Started-Running-Solution.md b/docs/zh-Hans/Getting-Started-Running-Solution.md new file mode 100644 index 0000000000..91ee846bc2 --- /dev/null +++ b/docs/zh-Hans/Getting-Started-Running-Solution.md @@ -0,0 +1,199 @@ +# 入门教程 + +````json +//[doc-params] +{ + "UI": ["MVC", "Blazor", "BlazorServer", "NG"], + "DB": ["EF", "Mongo"], + "Tiered": ["Yes", "No"] +} +```` + +> 本文档假设你更喜欢使用 **{{ UI_Value }}** 作为 UI 框架, 使用 **{{ DB_Value }}** 作为数据库提供程序. 对于其他选项, 请更改本文档顶部的首选项. + +## 创建数据库 + +### 连接字符串 + +检查在 {{if Tiered == "Yes"}}`.IdentityServer` 和`.HttpApi.Host` 项目{{else}}{{if UI=="MVC"}}`.Web` 项目{{else if UI=="BlazorServer"}}`.Blazor` 项目{{else}}`.HttpApi.Host` 项目{{end}}{{end}} 中 `appsettings.json` 文件里的**连接字符串**. + +{{ if DB == "EF" }} + +````json +"ConnectionStrings": { + "Default": "Server=(LocalDb)\MSSQLLocalDB;Database=BookStore;Trusted_Connection=True" +} +```` + +> **关于连接字符串和数据库管理系统** +> +> 解决方案配置为默认使用 **Entity Framework Core** 与 **MS SQL Server**. 但是, 如果在执行ABP CLI 的`new`命令时使用了`-dbms`参数来选择其他DBMS (如`-dbms MySQL`), 那么连接字符串可能不同. +> +> EF Core 支持 [多种](https://docs.microsoft.com/en-us/ef/core/providers/) 据库提供程序, 因此你可以使用任何受支持的DBMS. 你可以需要时候参阅[Entity Framework 集成文档](Entity-Framework-Core.md) 来学习如何[切换到另一个DBMS](Entity-Framework-Core-Other-DBMS.md). + +### 数据库迁移 + +该解决方案使用[Entity Framework Core Code First 迁移](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli). 带有 `.DbMigrator` 的控制台程序用于 **应用迁移** 和 **初始化种子数据**. 它在**开发**和**生产**环境中都很有用. + +> `.dbMigator` 项目有自己的 `appsettings.json`. 因此, 如果你更改了之前的连接字符串, 那么也应该更改这个连接字符串. + +### 初次迁移 + +`.dbMigator` 应用程序在首次运行时自动**创建初始迁移**. + +**如果你使用的是 Visual Studio, 你可以跳到 *运行 dbMigrator* 部分.** 但是, 其他 IDE (例如 Rider) 在首次运行时可能会遇到问题, 因为它会添加初始迁移并编译项目. 在这种情况下, 请在 `.dbMigration` 项目的文件夹中打开命令行终端, 然后运行以下命令: + +````bash +dotnet run +```` + +下次, 你可以像往常一样在 IDE 中运行它. + +### 运行迁移 + +右键单击 `.dbMigration` 项目, 然后选择 **设置为启动项目** + +![set-as-startup-project](images/set-as-startup-project.png) + + 按F5(或Ctrl + F5) 运行应用程序. 它将具有如下所示的输出: + + ![db-migrator-output](images/db-migrator-output.png) + +> 初始的[种子数据](Data-Seeding.md)在数据库中创建了 `admin` 用户(密码为`1q2w3E*`) 用于登录应用程序. 所以, 对于新数据库至少使用 `.DbMigrator` 一次. + +{{ else if DB == "Mongo" }} + +````json +"ConnectionStrings": { + "Default": "mongodb://localhost:27017/BookStore" +} +```` + +该解决方案配置为在本地计算机中使用 **MongoDB**, 因此你需要启动并运行 MongoDB 服务器实例, 或者将连接字符串更改为另一台 MongoDB 服务器. + +### 种子初始数据 + +该解决方案带有 `.DbMigrator` 的控制台程序用于 **初始化种子数据**. 它在**开发**和**生产**环境中都很有用. + +> `.dbMigator` 项目有自己的 `appsettings.json`. 因此, 如果你更改了之前的连接字符串, 那么也应该更改这个连接字符串. + +右键单击 `.dbMigration` 项目, 然后选择 **设置为启动项目** + +![set-as-startup-project](images/set-as-startup-project.png) + + 按F5(或Ctrl + F5) 运行应用程序. 它将具有如下所示的输出: + + ![db-migrator-output](images/db-migrator-output.png) + +> 初始的[种子数据](Data-Seeding.md)在数据库中创建了 `admin` 用户(密码为`1q2w3E*`) 用于登录应用程序. 所以, 对于新数据库至少使用 `.DbMigrator` 一次. + +{{ end }} + +## 运行应用程序 + +{{ if UI == "MVC" || UI == "BlazorServer" }} + +{{ if Tiered == "Yes" }} + +> 分层解决方案使用 **Redis** 作为分布式缓存. 确保它已安装并在本地计算机上运行. 如果你使用的是远程 Redis 服务器, 请修改项目的 ` appsettings.json` 文件中的配置. + +1. 确保 `.IdentityServer` 项目是启动项目. 运行此应用程序, 它将在浏览器中打开 **登录** 页面. + +> 在 Visual Studio 中使用 Ctrl+F5(而不是F5) 在不进行调试的情况下运行应用程序. 如果你没有调试目的, 这会更快. + +你可以登录, 但不能在这里进入主应用程序. 这 **只是身份验证服务器**. + +2. 确保 `.httpapi.Host` 项目是启动项目, 然后运行应用将在浏览器中打开 **Swagger UI**. + +![swagger-ui](images/swagger-ui.png) + +这是 Web 应用程序使用的 HTTP API. + +3. 最后, 确保 {{if UI=="MVC"}}`.Web`{{else}}`.Blazor`{{end}} 项目是启动项目,然后运行应用程序,它将在浏览器中打开 **欢迎** 页面 + +![mvc-tiered-app-home](images/bookstore-home.png) + +单击 **login** 按钮, 它将重定向到 *身份验证服务器* 以登录到应用程序: + +![bookstore-login](images/bookstore-login.png) + +{{ else # Tiered != "Yes" }} + +确保 {{if UI=="MVC"}}`.Web`{{else}}`.Blazor`{{end}} 项目是启动项目. 运行应用程序将会在浏览器中打开 **login** 页面: + +> 在 Visual Studio 中使用 Ctrl+F5(而不是F5) 在不进行调试的情况下运行应用程序. 如果你没有调试目的, 这会更快. + +![bookstore-login](images/bookstore-login.png) + +{{ end # Tiered }} + +{{ else # UI != MVC || BlazorServer }} + +### 运行 HTTP API 主机(服务器端) + +{{ if Tiered == "Yes" }} + +> 分层解决方案使用 Redis 作为分布式缓存. 确保它已安装并在本地计算机上运行. 如果你使用的是远程 Redis 服务器, 请修改项目的 `appsettings.json` 文件中的配置. + +确保 `.IdentityServer` 项目是启动项目. 运行此应用程序, 它将在浏览器中打开 **登录** 页面. + +> 在 Visual Studio 中使用 Ctrl+F5(而不是F5) 在不进行调试的情况下运行应用程序. 如果你没有调试目的, 这会更快. + +你可以登录, 但不能在这里进入主应用程序. 这 **只是身份验证服务器**. + +确保 `.HttpApi.Host` 项目是启动项目, 然后运行应用程序将打开 Swagger UI 的: + +{{ else # Tiered == "No" }} + +确保 `.HttpApi.Host` 项目是启动项目, 然后运行应用程序将打开 Swagger UI 的: + +> 在 Visual Studio 中使用 Ctrl+F5(而不是F5) 在不进行调试的情况下运行应用程序. 如果你没有调试目的, 这会更快. + +{{ end # Tiered }} + +![swagger-ui](images/swagger-ui.png) + +你可以在这里查看应用程序的API并测试它们. 获取Swagger UI的[更多信息](https://swagger.io/tools/swagger-ui/). + +{{ end # UI }} + +{{ if UI == "Blazor" }} + +### 运行 Blazor 应用程序 (客户端) + +确保 `.Blazor` 项目是启动项目并运行应用程序. + +> 在 Visual Studio 中使用 Ctrl+F5(而不是F5) 在不进行调试的情况下运行应用程序. 如果你没有调试目的, 这会更快. + +应用程序启动后, 单击页头上的 **Login** 链接, 你将重定向到身份验证服务器以输入用户名和密码: + +![bookstore-login](images/bookstore-login.png) + +{{ else if UI == "NG" }} + +### 运行 Angular 应用程序 (客户端) + +转到 `Angular` 文件夹, 打开命令行终端, 键入 `yarn` 命令(我们建议使用 [yarn](https://yarnpkg.com/) 软件包管理器, 而 `npm install` 也可以使用) + +```bash +yarn +``` + +当所有node模块加载完毕后, 执行 `yarn start` (或 `npm start`) 命令: + +```bash +yarn start +``` + +初次构建可能需要更长的时间. 完成后, 它会在默认浏览器中使用 [localhost:4200](http://localhost:4200/) 地址打开 Angular UI. + +![bookstore-login](images/bookstore-login.png) + +{{ end }} + +输入用户名 **admin** 和 密码 **1q2w3E*** 登录应用程序. 应用程序已启动并正在运行. 你可以根据此启动模板开始开发应用程序. + +## 另请参见 + +* [Web 应用程序开发教程](Tutorials/Part-1.md) +* [应用程序启动模板](Startup-Templates/Application.md) diff --git a/docs/zh-Hans/Getting-Started-Setup-Environment.md b/docs/zh-Hans/Getting-Started-Setup-Environment.md new file mode 100644 index 0000000000..c0c2d5d924 --- /dev/null +++ b/docs/zh-Hans/Getting-Started-Setup-Environment.md @@ -0,0 +1,53 @@ +# 入门教程 + +````json +//[doc-params] +{ + "UI": ["MVC", "Blazor", "BlazorServer", "NG"], + "DB": ["EF", "Mongo"], + "Tiered": ["Yes", "No"] +} +```` + +> 本文档假设你更喜欢使用 **{{ UI_Value }}** 作为 UI 框架, 使用 **{{ DB_Value }}** 作为数据库提供程序. 对于其他选项, 请更改本文档顶部的首选项. + +## 设置你的开发环境 + +第一件事! 在创建项目之前, 让我们先设置你的开发环境. + +### 先决条件 + +开发计算机上应安装以下工具: + +* 一个集成开发环境 (比如: [Visual Studio](https://visualstudio.microsoft.com/vs/)) 它需要支持 [.NET 6.0+](https://dotnet.microsoft.com/download/dotnet) 的开发. +{{ if UI != "Blazor" }} +* [Node v12 或 v14](https://nodejs.org/) +* [Yarn v1.20+ (不是v2)](https://classic.yarnpkg.com/en/docs/install) [1](#f-yarn) 或 npm v6+ (已跟随Node一起安装) +{{ end }} +{{ if Tiered == "Yes" }} +* [Redis](https://redis.io/) (启动解决方案使用 Redis 作为 [分布式缓存](Caching.md)). +{{ end }} + +{{ if UI != "Blazor" }} + +1 _Yarn v2 工作方式不同, 不被支持._ [↩](#a-yarn) + +{{ end }} + +### 安装 ABP CLI + +[ABP CLI](./CLI.md) 是一个命令行界面, 用于自动执行基于 ABP 的解决方案的一些常见任务. 首先, 你需要使用以下命令安装 ABP CLI: + +````shell +dotnet tool install -g Volo.Abp.Cli +```` + +如果已安装, 则可以使用以下命令对其进行更新: + +````shell +dotnet tool update -g Volo.Abp.Cli +```` + +## 下一步 + +* [创建新的解决方案](Getting-Started-Create-Solution.md) \ No newline at end of file diff --git a/docs/zh-Hans/Getting-Started.md b/docs/zh-Hans/Getting-Started.md index c6b3bd70df..1cf1430a35 100644 --- a/docs/zh-Hans/Getting-Started.md +++ b/docs/zh-Hans/Getting-Started.md @@ -1,374 +1,20 @@ -## 入门 +# 入门教程 ````json //[doc-params] { - "UI": ["MVC","NG"], + "UI": ["MVC", "Blazor", "BlazorServer", "NG"], "DB": ["EF", "Mongo"], "Tiered": ["Yes", "No"] } ```` -本教程介绍了如何创建一个新的{{if UI == "MVC"}} ASP.NET Core MVC web {{else if UI == "NG"}} Angular {{end}}. 配置并运行它. +> 本文档假设你更喜欢使用 **{{ UI_Value }}** 作为 UI 框架, 使用 **{{ DB_Value }}** 作为数据库提供程序. 对于其他选项, 请更改本文档顶部的首选项. -## 设置你的开发环境 +## 内容 -创建第一个项目之前,需要正确的设置你的开发环境. +本教程介绍如何使用 ABP 框架 **创建和运行** 新的 Web 应用程序. 请按照以下步骤操作; -### 预先要求 - -你需要安装以下工具: - -* [Visual Studio 2019 (v16.4+)](https://visualstudio.microsoft.com/vs/) for Windows / [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).[1](#f-editor) -* [.NET Core 3.1+](https://www.microsoft.com/net/download/dotnet-core/) - -* [Node v12 或 v14](https://nodejs.org/en/) -* [Yarn v1.19+](https://classic.yarnpkg.com/) -* [Yarn v1.20+ (not v2)](https://classic.yarnpkg.com/en/docs/install) [2](#f-yarn) 或 npm v6+ (与Node一起安装) -{{ if Tiered == "Yes" }} - -* [Redis](https://redis.io/): 入门解决方案将Redis用作[分布式缓存](Caching.md). 因此你需要安装并运行Redis. - -{{ end }} - -1 _只要支持.NET Core和ASP.NET Core,就可以使用其他编辑器代替Visual Studio._ [↩](#a-editor) - -2 _Yarn v2 的工作方式不同,不受支持._ [↩](#a-yarn) - -### 安装ABP CLI - -[ABP CLI](./CLI.md)是一个命令行页面,用于自动执行一些基于ABP的应用程序的常见任务. - -> ABP CLI是ABP框架一个免费开源的工具. - -你需要使用以下命令安排ABP CLI: - -````shell -dotnet tool install -g Volo.Abp.Cli -```` - -如果你已经安装,你可以使用以下命令更新到最新版本: - -````shell -dotnet tool update -g Volo.Abp.Cli -```` - -## 创建新项目 - -> 本文假设你使用 **{{ UI_Value }}** 做为UI框架 **{{ DB_Value }}** 做为数据库提供程序,对于其它选项,你可以更改文档顶部的首选项. - -### 使用ABP CLI创建一个新项目 - -使用ABP CLI的 `new` 命令创建新项目: - -````shell -abp new Acme.BookStore{{if UI == "NG"}} -u angular {{end}}{{if DB == "Mongo"}} -d mongodb{{end}}{{if Tiered == "Yes" && UI != "NG"}} --tiered {{else if Tiered == "Yes" && UI == "NG"}}--separate-identity-server{{end}} --mobile react-native -```` - -* 此命令还会在解决方案文件夹内创建一个React Native移动应用程序. 如果你不想要它,可以安全地删除它或从`abp new`命令中删除`--mobile react-native`选项, 以使其完全不包含在解决方案中. - -{{ if UI == "NG" }} - -* `-u` 指定UI框架, 本例中是 `angular`. - -{{ if Tiered == "Yes" }} - -* `--separate-identity-server` 参数用于将Identity服务器应用程序与API主机应用程序分隔开. 如果未指定,则服务器上将只有一个端点. - -{{ end }} - -{{ end }} - -{{ if DB == "Mongo" }} - -* `-d` 指定数据库提供程序, 本例中是 `mongodb`. - -{{ end }} - -{{ if Tiered == "Yes" && UI != "NG" }} - -* `--tiered` 参数用于创建n层解决方案,其中身份验证服务器层,UI层和API层在物理上是分离的. - -{{ end }} - -> 你可以使用不同级别的命令空间; 例如. BookStore, Acme.BookStore or Acme.Retail.BookStore. - -#### ABP CLI 命令 & 选项 - -[ABP CLI文档](./CLI.md)涵盖了ABP CLI的所有可用命令和选项. 本文档使用[应用程序启动模板](Startup-Templates/Application.md)创建新的Web应用程序. 有关其他模板,请参见[ABP启动模板](Startup-Templates/Index.md)文档. - -> 或者,您可以从[ABP Framework网站](https://abp.io/get-started)中选择"直接下载"选项卡创建新的解决方案. - -## 解决方案结构 - -{{ if UI == "MVC" }} - -创建项目后你会有以下解决方案目录和文件: - -![](images/solution-files-mvc.png) - -在Visual Studio中打开 `.sln` 文件时,将看到以下解决方案结构: - -{{if DB == "Mongo"}} - -![vs-default-app-solution-structure](images/vs-app-solution-structure-mongodb.png) - -{{else}} - -![vs-default-app-solution-structure](images/vs-app-solution-structure{{if Tiered == "Yes"}}-tiered{{end}}.png) - -{{end}} - -{{ else if UI == "NG" }} - -在创建的解决方案中有三个文件夹: - -![](images/solution-files-non-mvc.png) - -* `angular` 文件夹包含Angular UI应用程序. -* `aspnet-core` 文件夹包含后端应用程序. -* `react-native` 文件夹包含React Native UI 应用程序. - -打开 `aspnet-core` 文件夹下的 `.sln`(`Visual Studio`解决方案)文件: - -![vs-angular-app-backend-solution-structure](images/vs-spa-app-backend-structure{{if DB == "Mongo"}}-mongodb{{end}}.png) - -{{ end }} - -> ###### 关于解决方案中的项目 -> -> 根据你的**UI**,**数据库**和其他选项,你的解决方案的结构可能略有不同. - -该解决方案具有分层结构(基于[Domain Driven Design](Domain-Driven-Design.md)), 并包含配置好的的单元&集成测试项目. - -{{ if DB == "EF" }} - -集成测试项目已配置为可与 **EF Core** & **SQLite 内存** database同时使用. - -{{ else if DB == "Mongo" }} - -集成测试项目已配置为每个测试创建的内存中的**MongoDB**数据库(使用的[Mongo2Go](https://github.com/Mongo2Go/Mongo2Go)库). - -{{ end }} - -> 请参阅[应用程序模板文档](Startup-Templates/Application.md)详细了解解决方案结构. - -{{ if DB == "Mongo" }} - -> [启动模板](Startup-templates/Index.md)默认在 `.MongoDB` 项目中**禁用**了工作单元事务. 如果你的MongoDB服务器支持事务,你可以手动启用工作单元的事务: - - ```csharp - Configure(options => - { - options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled; - }); - ``` - -{{ end }} - -## 创建数据库 - -### 连接字符串 - -检查 {{if UI == "MVC"}}{{if Tiered == "Yes"}}`.IdentityServer` 和 `.HttpApi.Host` 项目{{else}}`.Web` 项目{{end}}{{else if UI == "NG" }}`.HttpApi.Host` 项目{{end}}下 `appsettings.json` 文件中的 **链接字符串**: - -{{ if DB == "EF" }} - -````json -"ConnectionStrings": { - "Default": "Server=localhost;Database=BookStore;Trusted_Connection=True" -} -```` - -该解决方案配置为**Entity Framework Core**与**MS SQL Server**一起使用. EF Core支持[各种](https://docs.microsoft.com/en-us/ef/core/providers/)数据库提供程序,因此你可以使用任何受支持的DBMS. 请参阅[Entity Framework集成文档](https://docs.abp.io/en/abp/latest/Entity-Framework-Core)了解如何切换到另一个DBMS. - -### 数据库连接字符串 - -查看`.Web`项目下`appsettings.json`文件中的 **连接字符串**: - -````json -{ - "ConnectionStrings": { - "Default": "Server=localhost;Database=BookStore;Trusted_Connection=True" - } -} -```` - -解决方案使用 **Entity Framework Core** 和 **MS SQL Server**. EF Core支持[各种](https://docs.microsoft.com/zh-cn/ef/core/providers/)数据库提供程序,因此你可以根据实际需要使用其他DBMS. 如果需要,请更改连接字符串. - -### 应用迁移 - -该解决方案使用[Entity Framework Core Code First 迁移](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli). 你需要应用迁移来创建数据库,有两种方法迁移数据库. - -#### 使用DbMigrator应用程序应用迁移 - -该解决方案包含一个控制台应用程序(在此示例中名为`Acme.BookStore.DbMigrator`),可以创建数据库,应用迁移和初始化数据. 它对开发和生产环境都很有用. - -> `.DbMigrator`项目有自己的`appsettings.json`. 因此,如果你更改了上面的连接字符串,则还应更改此字符串. - -右键单击`.DbMigrator`项目并选择 **设置为启动项目**: - -![set-as-startup-project](images/set-as-startup-project.png) - -按F5(或Ctrl + F5)运行应用程序. 它将具有如下所示的输出: - -![set-as-startup-project](images/db-migrator-app.png) - -#### 使用EF Core Update-Database命令 - -Ef Core具有`Update-Database`命令, 可根据需要创建数据库并应用挂起的迁移. 右键单击`.Web`项目并选择**设置为启动项目**: - -{{ if UI == "MVC" }} - -右键单击{{if Tiered == "Yes"}}`.IdentityServer`{{else}}`.Web`{{end}}项目并选择**设置为启动项目**: - -{{ else if UI != "MVC" }} - -右键单击`.HttpApi.Host`项目并选择**设置为启动项目**: - -{{ end }} - -![set-as-startup-project](images/set-as-startup-project.png) - -打开**包管理器控制台(Package Manager Console)**, 选择`.EntityFrameworkCore.DbMigrations`项目作为**默认项目**并运行`Update-Database`命令: - -![package-manager-console-update-database](images/package-manager-console-update-database.png) - -这将基于配置的连接字符串创建新数据库. - -> **使用`.DbMigrator`工具是建议的方法**, 因为它能初始化初始数据能够正确运行Web应用程序. -> -> 如果你只是使用 `Update-Database` 命令,你会得到一个空数据库,所以你无法登录到应用程序因为数据库中没有初始管理用户. 不需要种子数据库时,可以在开发期间使用 `Update-Database` 命令. 但是使用 `.DbMigrator` 应用程序会更简单,你始终可以使用它来迁移模式并为数据库添加种子. - -{{ else if DB == "Mongo" }} - -````json -"ConnectionStrings": { - "Default": "mongodb://localhost:27017/BookStore" -} -```` - -该解决方案被配置为在你的本地计算机中使用 **MongoDB**,因此你需要启动并运行一个MongoDB服务器实例或者将连接字符串更改为另一个MongoDB服务器. - -### 初始化种子数据 - -该解决方案附带一个 `.DbMigrator` 控制台应用程序,该应用程序为初始数据提供了种子. 它对于开发以及生产环境都很有用. - -> `.DbMigrator` 项目有自己的 `appsettings.json`.如果你更改了其他项目的 `appsettings.json`,也应该更改这个. - -右键点击 `.DbMigrator` 并选择 **设置为启动项目**. - -![set-as-startup-project](images/set-as-startup-project.png) - - 按F5(或Ctrl+F5)启动应用程序,你会看到以下输出: - - ![db-migrator-output](images/db-migrator-output.png) - -> 数据库创建后会初始化[种子数据](Data-Seeding.md), 其中包含用于登录的 `admin` 用户. 所以你至少使用 `.DbMigrator` 一次. - -{{ end }} - -### 运行应用程序 - -{{ if UI == "MVC" }} - -{{ if Tiered == "Yes" }} - -确保 `.IdentityServer` 是启动项目,运行应用程序后会在你的浏览器打开一个 **login** 页面. - -> 在Visual Studio中使用Ctrl+F5(而不是F5)运行应用,如果你不用于调试,这会减少启动时间. - -你可以登录,但是不能在这里进入主应用程序,它仅是验证服务器. - -确保 `.HttpApi.Host` 是启动项目,运行应用程序后会在你的浏览器打开一个 **Swagger UI** 页面. - -![swagger-ui](images/swagger-ui.png) - -这里是Web应用程序使用的API应用程序. - -最后确保 `.Web` 是启动项目,运行应用程序后会在你的浏览器打开一个 **welcome** 页面. - -![mvc-tiered-app-home](images/bookstore-home.png) - -点击 **login** 按钮重定向到 `Identity Server` 来登录应用程序. - -![bookstore-login](images/bookstore-login.png) - -{{ else }} - -最后确保 `.Web` 是启动项目,运行应用程序后会在你的浏览器打开一个 **login** 页面. - -> 在Visual Studio中使用Ctrl+F5(而不是F5)运行应用,如果你不用于调试,这会减少启动时间. - -![bookstore-login](images/bookstore-login.png) - -{{ end }} - -{{ else if UI != "MVC" }} - -#### 运行HTTP API Host (服务器端) - -{{ if Tiered == "Yes" }} - -确保 `.IdentityServer` 是启动项目,运行应用程序后会在你的浏览器打开一个 **login** 页面. - -> 在Visual Studio中使用Ctrl+F5(而不是F5)运行应用,如果你不用于调试,这会减少启动时间. - -你可以登录,但是不能在这里进入主应用程序,它仅是验证服务器. - -{{ end }} - -确保 `.HttpApi.Host` 是启动项目,运行应用程序后会在你的浏览器打开一个 **Swagger UI** 页面. - -{{ if Tiered == "No" }} - -> 在Visual Studio中使用Ctrl+F5(而不是F5)运行应用,如果你不用于调试,这会减少启动时间. - -{{ end }} - -![swagger-ui](images/swagger-ui.png) - -你可以看到应用程序的API并进行测试. 更多信息,请参阅[Swagger UI](https://swagger.io/tools/swagger-ui/). - -> ##### Swagger UI 授权 -> -> 大多数的HTTP API都需要身份验证和授权. 如果你要测试授权API, 请手动进入 `/Account/Login` 页面, 输入用户名: `admin` 和密码: `1q2w3E*` 登录到应用程序. 然后你可以访问授权API. - -{{ end }} - -{{ if UI == "NG" }} -#### 运行 Angular 应用程序 (客户端) - -在 `angular` 下打开命令行终端, 输入 `yarn` 命令(我们推荐使用[yarn](https://yarnpkg.com/)包管理, `npm install` 在大多数情况下也可以工作). - -```bash -yarn -``` - -等到所有node模块加载成功, 执行 `yarn start` (或 `npm start`) 命令: - -```bash -yarn start -``` - -等待 `Angular CLI` 使用 `BrowserSync` 启动 `Webpack` dev-server. -它会负责编译你的 `TypeScript`代码, 并自动重新加载浏览器. -完成后 `Angular Live Development Server` 会监听 localhost:4200. -打开你的浏览器并导航到[localhost:4200](http://localhost:4200/). - -![bookstore-login](images/bookstore-login.png) - -{{ end }} - -输入用户名 **admin**,密码 **1q2w3E*** 登录到应用程序,应用程序已经启动并执行,你可以基于此启动模板开始开发应用程序. - -#### 移动开发 - -当你创建一个新的应用程序时. 可以添加`-m react-native`选项以在解决方案中包含 `react-native`项目. 这是一个基础的[React Native](https://reactnative.dev/)启动模板,用于开发与基于ABP的后端集成的移动应用程序. - - -请参阅"[React Native入门](Getting-Started-React-Native.md)"文档了解如何配置和运行React Native应用程序. - -## 下一步是什么? - -[Web应用程序开发教程](Tutorials/Part-1.md) +1. [设置你的开发环境](Getting-Started-Setup-Environment.md) +2. [创建新的解决方案](Getting-Started-Create-Solution.md) +3. [运行解决方案](Getting-Started-Running-Solution.md) \ No newline at end of file diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json index 37f57388c0..74a44c8445 100644 --- a/docs/zh-Hans/docs-nav.json +++ b/docs/zh-Hans/docs-nav.json @@ -5,11 +5,25 @@ "path": "Tutorials/Todo/Index.md" }, { - "text": "入门", + "text": "入门教程", "items": [ { "text": "Web应用程序", - "path": "Getting-Started.md" + "path": "Getting-Started.md", + "items": [ + { + "text": "1: 设置你的开发环境", + "path": "Getting-Started-Setup-Environment.md" + }, + { + "text": "2: 创建新的解决方案", + "path": "Getting-Started-Create-Solution.md" + }, + { + "text": "3: 运行解决方案", + "path": "Getting-Started-Running-Solution.md" + } + ] }, { "text": "控制台应用程序", diff --git a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/AbpApiVersioningAbstractionsModule.cs b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/AbpApiVersioningAbstractionsModule.cs index b4f679c927..70d960c8d5 100644 --- a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/AbpApiVersioningAbstractionsModule.cs +++ b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/AbpApiVersioningAbstractionsModule.cs @@ -1,13 +1,12 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; -namespace Volo.Abp.ApiVersioning +namespace Volo.Abp.ApiVersioning; + +public class AbpApiVersioningAbstractionsModule : AbpModule { - public class AbpApiVersioningAbstractionsModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddSingleton(NullRequestedApiVersion.Instance); - } + context.Services.AddSingleton(NullRequestedApiVersion.Instance); } } diff --git a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs index 3d8a31c694..96c2ef33cd 100644 --- a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs +++ b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/IRequestedApiVersion.cs @@ -1,7 +1,6 @@ -namespace Volo.Abp.ApiVersioning +namespace Volo.Abp.ApiVersioning; + +public interface IRequestedApiVersion { - public interface IRequestedApiVersion - { - string Current { get; } - } + string Current { get; } } diff --git a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs index 721fa91815..0589c662ef 100644 --- a/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs +++ b/framework/src/Volo.Abp.ApiVersioning.Abstractions/Volo/Abp/ApiVersioning/NullRequestedApiVersion.cs @@ -1,14 +1,13 @@ -namespace Volo.Abp.ApiVersioning +namespace Volo.Abp.ApiVersioning; + +public class NullRequestedApiVersion : IRequestedApiVersion { - public class NullRequestedApiVersion : IRequestedApiVersion - { - public static NullRequestedApiVersion Instance = new NullRequestedApiVersion(); + public static NullRequestedApiVersion Instance = new NullRequestedApiVersion(); - public string Current => null; + public string Current => null; + + private NullRequestedApiVersion() + { - private NullRequestedApiVersion() - { - - } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Microsoft/AspNetCore/Builder/ApplicationBuilderAbpJwtTokenMiddlewareExtension.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Microsoft/AspNetCore/Builder/ApplicationBuilderAbpJwtTokenMiddlewareExtension.cs index 4ff54f39bf..8171013854 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Microsoft/AspNetCore/Builder/ApplicationBuilderAbpJwtTokenMiddlewareExtension.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Microsoft/AspNetCore/Builder/ApplicationBuilderAbpJwtTokenMiddlewareExtension.cs @@ -1,25 +1,24 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Builder; + +public static class ApplicationBuilderAbpJwtTokenMiddlewareExtension { - public static class ApplicationBuilderAbpJwtTokenMiddlewareExtension + public static IApplicationBuilder UseJwtTokenMiddleware(this IApplicationBuilder app, string schema = JwtBearerDefaults.AuthenticationScheme) { - public static IApplicationBuilder UseJwtTokenMiddleware(this IApplicationBuilder app, string schema = JwtBearerDefaults.AuthenticationScheme) + return app.Use(async (ctx, next) => { - return app.Use(async (ctx, next) => + if (ctx.User.Identity?.IsAuthenticated != true) { - if (ctx.User.Identity?.IsAuthenticated != true) + var result = await ctx.AuthenticateAsync(schema); + if (result.Succeeded && result.Principal != null) { - var result = await ctx.AuthenticateAsync(schema); - if (result.Succeeded && result.Principal != null) - { - ctx.User = result.Principal; - } + ctx.User = result.Principal; } + } - await next(); - }); - } + await next(); + }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo/Abp/AspNetCore/Authentication/JwtBearer/AbpAspNetCoreAuthenticationJwtBearerModule.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo/Abp/AspNetCore/Authentication/JwtBearer/AbpAspNetCoreAuthenticationJwtBearerModule.cs index 8698e2283d..1fa5077a91 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo/Abp/AspNetCore/Authentication/JwtBearer/AbpAspNetCoreAuthenticationJwtBearerModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo/Abp/AspNetCore/Authentication/JwtBearer/AbpAspNetCoreAuthenticationJwtBearerModule.cs @@ -1,11 +1,10 @@ using Volo.Abp.Modularity; using Volo.Abp.Security; -namespace Volo.Abp.AspNetCore.Authentication.JwtBearer +namespace Volo.Abp.AspNetCore.Authentication.JwtBearer; + +[DependsOn(typeof(AbpSecurityModule))] +public class AbpAspNetCoreAuthenticationJwtBearerModule : AbpModule { - [DependsOn(typeof(AbpSecurityModule))] - public class AbpAspNetCoreAuthenticationJwtBearerModule : AbpModule - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Microsoft/AspNetCore/Authentication/OAuth/Claims/AbpClaimActionCollectionExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Microsoft/AspNetCore/Authentication/OAuth/Claims/AbpClaimActionCollectionExtensions.cs index 2ad72955af..01dc489c54 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Microsoft/AspNetCore/Authentication/OAuth/Claims/AbpClaimActionCollectionExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Microsoft/AspNetCore/Authentication/OAuth/Claims/AbpClaimActionCollectionExtensions.cs @@ -1,57 +1,56 @@ using Volo.Abp.AspNetCore.Authentication.OAuth.Claims; using Volo.Abp.Security.Claims; -namespace Microsoft.AspNetCore.Authentication.OAuth.Claims +namespace Microsoft.AspNetCore.Authentication.OAuth.Claims; + +public static class AbpClaimActionCollectionExtensions { - public static class AbpClaimActionCollectionExtensions + public static void MapAbpClaimTypes(this ClaimActionCollection claimActions) { - public static void MapAbpClaimTypes(this ClaimActionCollection claimActions) + if (AbpClaimTypes.UserName != "name") + { + claimActions.MapJsonKey(AbpClaimTypes.UserName, "name"); + claimActions.DeleteClaim("name"); + claimActions.RemoveDuplicate(AbpClaimTypes.UserName); + } + + if (AbpClaimTypes.Email != "email") + { + claimActions.MapJsonKey(AbpClaimTypes.Email, "email"); + claimActions.DeleteClaim("email"); + claimActions.RemoveDuplicate(AbpClaimTypes.Email); + } + + if (AbpClaimTypes.EmailVerified != "email_verified") + { + claimActions.MapJsonKey(AbpClaimTypes.EmailVerified, "email_verified"); + } + + if (AbpClaimTypes.PhoneNumber != "phone_number") { - if (AbpClaimTypes.UserName != "name") - { - claimActions.MapJsonKey(AbpClaimTypes.UserName, "name"); - claimActions.DeleteClaim("name"); - claimActions.RemoveDuplicate(AbpClaimTypes.UserName); - } - - if (AbpClaimTypes.Email != "email") - { - claimActions.MapJsonKey(AbpClaimTypes.Email, "email"); - claimActions.DeleteClaim("email"); - claimActions.RemoveDuplicate(AbpClaimTypes.Email); - } - - if (AbpClaimTypes.EmailVerified != "email_verified") - { - claimActions.MapJsonKey(AbpClaimTypes.EmailVerified, "email_verified"); - } - - if (AbpClaimTypes.PhoneNumber != "phone_number") - { - claimActions.MapJsonKey(AbpClaimTypes.PhoneNumber, "phone_number"); - } - - if (AbpClaimTypes.PhoneNumberVerified != "phone_number_verified") - { - claimActions.MapJsonKey(AbpClaimTypes.PhoneNumberVerified, "phone_number_verified"); - } - - if (AbpClaimTypes.Role != "role") - { - claimActions.MapJsonKeyMultiple(AbpClaimTypes.Role, "role"); - } - - claimActions.RemoveDuplicate(AbpClaimTypes.Name); + claimActions.MapJsonKey(AbpClaimTypes.PhoneNumber, "phone_number"); } - public static void MapJsonKeyMultiple(this ClaimActionCollection claimActions, string claimType, string jsonKey) + if (AbpClaimTypes.PhoneNumberVerified != "phone_number_verified") { - claimActions.Add(new MultipleClaimAction(claimType, jsonKey)); + claimActions.MapJsonKey(AbpClaimTypes.PhoneNumberVerified, "phone_number_verified"); } - - public static void RemoveDuplicate(this ClaimActionCollection claimActions, string claimType) + + if (AbpClaimTypes.Role != "role") { - claimActions.Add(new RemoveDuplicateClaimAction(claimType)); + claimActions.MapJsonKeyMultiple(AbpClaimTypes.Role, "role"); } + + claimActions.RemoveDuplicate(AbpClaimTypes.Name); + } + + public static void MapJsonKeyMultiple(this ClaimActionCollection claimActions, string claimType, string jsonKey) + { + claimActions.Add(new MultipleClaimAction(claimType, jsonKey)); + } + + public static void RemoveDuplicate(this ClaimActionCollection claimActions, string claimType) + { + claimActions.Add(new RemoveDuplicateClaimAction(claimType)); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/AbpAspNetCoreAuthenticationOAuthModule.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/AbpAspNetCoreAuthenticationOAuthModule.cs index cff3f437b7..b73c78782e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/AbpAspNetCoreAuthenticationOAuthModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/AbpAspNetCoreAuthenticationOAuthModule.cs @@ -1,11 +1,10 @@ using Volo.Abp.Modularity; using Volo.Abp.Security; -namespace Volo.Abp.AspNetCore.Authentication.OAuth +namespace Volo.Abp.AspNetCore.Authentication.OAuth; + +[DependsOn(typeof(AbpSecurityModule))] +public class AbpAspNetCoreAuthenticationOAuthModule : AbpModule { - [DependsOn(typeof(AbpSecurityModule))] - public class AbpAspNetCoreAuthenticationOAuthModule : AbpModule - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/MultipleClaimAction.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/MultipleClaimAction.cs index 66ca78026d..1910af63d5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/MultipleClaimAction.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/MultipleClaimAction.cs @@ -3,51 +3,50 @@ using System.Security.Claims; using System.Text.Json; using Microsoft.AspNetCore.Authentication.OAuth.Claims; -namespace Volo.Abp.AspNetCore.Authentication.OAuth.Claims +namespace Volo.Abp.AspNetCore.Authentication.OAuth.Claims; + +public class MultipleClaimAction : ClaimAction { - public class MultipleClaimAction : ClaimAction + public MultipleClaimAction(string claimType, string jsonKey) + : base(claimType, jsonKey) { - public MultipleClaimAction(string claimType, string jsonKey) - : base(claimType, jsonKey) - { - } + } - public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) - { - JsonElement prop; + public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) + { + JsonElement prop; - if (!userData.TryGetProperty(ValueType, out prop)) - return; - - if (prop.ValueKind == JsonValueKind.Null) - { - return; - } + if (!userData.TryGetProperty(ValueType, out prop)) + return; - Claim claim; - switch (prop.ValueKind) - { - case JsonValueKind.String: - claim = new Claim(ClaimType, prop.GetString(), ValueType, issuer); + if (prop.ValueKind == JsonValueKind.Null) + { + return; + } + + Claim claim; + switch (prop.ValueKind) + { + case JsonValueKind.String: + claim = new Claim(ClaimType, prop.GetString(), ValueType, issuer); + if (!identity.Claims.Any(c => c.Type == claim.Type && c.Value == claim.Value)) + { + identity.AddClaim(claim); + } + break; + case JsonValueKind.Array: + foreach (var arramItem in prop.EnumerateArray()) + { + claim = new Claim(ClaimType, arramItem.GetString(), ValueType, issuer); if (!identity.Claims.Any(c => c.Type == claim.Type && c.Value == claim.Value)) { identity.AddClaim(claim); } - break; - case JsonValueKind.Array: - foreach (var arramItem in prop.EnumerateArray()) - { - claim = new Claim(ClaimType, arramItem.GetString(), ValueType, issuer); - if (!identity.Claims.Any(c => c.Type == claim.Type && c.Value == claim.Value)) - { - identity.AddClaim(claim); - } - } - break; - default: - throw new AbpException("Unhandled JsonValueKind: " + prop.ValueKind); - } + } + break; + default: + throw new AbpException("Unhandled JsonValueKind: " + prop.ValueKind); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/RemoveDuplicateClaimAction.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/RemoveDuplicateClaimAction.cs index ab3e4027c2..80773ed481 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/RemoveDuplicateClaimAction.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo/Abp/AspNetCore/Authentication/OAuth/Claims/RemoveDuplicateClaimAction.cs @@ -5,36 +5,35 @@ using System.Security.Claims; using System.Text.Json; using Microsoft.AspNetCore.Authentication.OAuth.Claims; -namespace Volo.Abp.AspNetCore.Authentication.OAuth.Claims +namespace Volo.Abp.AspNetCore.Authentication.OAuth.Claims; + +public class RemoveDuplicateClaimAction : ClaimAction { - public class RemoveDuplicateClaimAction : ClaimAction + public RemoveDuplicateClaimAction(string claimType) + : base(claimType, ClaimValueTypes.String) { - public RemoveDuplicateClaimAction(string claimType) - : base(claimType, ClaimValueTypes.String) + } + + /// + public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) + { + var claims = identity.Claims.Where(c => c.Type == ClaimType).ToArray(); + if (claims.Length < 2) { + return; } - /// - public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer) + var previousValues = new List(); + foreach (var claim in claims) { - var claims = identity.Claims.Where(c => c.Type == ClaimType).ToArray(); - if (claims.Length < 2) + if (claim.Value.IsIn(previousValues)) { - return; + identity.RemoveClaim(claim); } - - var previousValues = new List(); - foreach (var claim in claims) + else { - if (claim.Value.IsIn(previousValues)) - { - identity.RemoveClaim(claim); - } - else - { - previousValues.Add(claim.Value); - } + previousValues.Add(claim.Value); } } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs index acd4233512..02b292a984 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs @@ -7,59 +7,58 @@ using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Volo.Abp.AspNetCore.MultiTenancy; -namespace Microsoft.Extensions.DependencyInjection +namespace Microsoft.Extensions.DependencyInjection; + +public static class AbpOpenIdConnectExtensions { - public static class AbpOpenIdConnectExtensions - { - public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder) - => builder.AddAbpOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); + public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder) + => builder.AddAbpOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, _ => { }); - public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder, Action configureOptions) - => builder.AddAbpOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); + public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder, Action configureOptions) + => builder.AddAbpOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, configureOptions); - public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) - => builder.AddAbpOpenIdConnect(authenticationScheme, OpenIdConnectDefaults.DisplayName, configureOptions); + public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions) + => builder.AddAbpOpenIdConnect(authenticationScheme, OpenIdConnectDefaults.DisplayName, configureOptions); - public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + public static AuthenticationBuilder AddAbpOpenIdConnect(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions) + { + return builder.AddOpenIdConnect(authenticationScheme, displayName, options => { - return builder.AddOpenIdConnect(authenticationScheme, displayName, options => - { - options.ClaimActions.MapAbpClaimTypes(); + options.ClaimActions.MapAbpClaimTypes(); - configureOptions?.Invoke(options); + configureOptions?.Invoke(options); - options.Events ??= new OpenIdConnectEvents(); - var authorizationCodeReceived = options.Events.OnAuthorizationCodeReceived ?? (_ => Task.CompletedTask); + options.Events ??= new OpenIdConnectEvents(); + var authorizationCodeReceived = options.Events.OnAuthorizationCodeReceived ?? (_ => Task.CompletedTask); - options.Events.OnAuthorizationCodeReceived = receivedContext => - { - SetAbpTenantId(receivedContext); - return authorizationCodeReceived.Invoke(receivedContext); - }; + options.Events.OnAuthorizationCodeReceived = receivedContext => + { + SetAbpTenantId(receivedContext); + return authorizationCodeReceived.Invoke(receivedContext); + }; - options.Events.OnRemoteFailure = remoteFailureContext => + options.Events.OnRemoteFailure = remoteFailureContext => + { + if (remoteFailureContext.Failure is OpenIdConnectProtocolException && + remoteFailureContext.Failure.Message.Contains("access_denied")) { - if (remoteFailureContext.Failure is OpenIdConnectProtocolException && - remoteFailureContext.Failure.Message.Contains("access_denied")) - { - remoteFailureContext.HandleResponse(); - remoteFailureContext.Response.Redirect($"{remoteFailureContext.Request.PathBase}/"); - } - return Task.CompletedTask; - }; - }); - } + remoteFailureContext.HandleResponse(); + remoteFailureContext.Response.Redirect($"{remoteFailureContext.Request.PathBase}/"); + } + return Task.CompletedTask; + }; + }); + } - private static void SetAbpTenantId(AuthorizationCodeReceivedContext receivedContext) - { - var tenantKey = receivedContext.HttpContext.RequestServices - .GetRequiredService>().Value.TenantKey; + private static void SetAbpTenantId(AuthorizationCodeReceivedContext receivedContext) + { + var tenantKey = receivedContext.HttpContext.RequestServices + .GetRequiredService>().Value.TenantKey; - if (receivedContext.Request.Cookies.ContainsKey(tenantKey)) - { - receivedContext.TokenEndpointRequest.SetParameter(tenantKey, - receivedContext.Request.Cookies[tenantKey]); - } + if (receivedContext.Request.Cookies.ContainsKey(tenantKey)) + { + receivedContext.TokenEndpointRequest.SetParameter(tenantKey, + receivedContext.Request.Cookies[tenantKey]); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs index 13a8fd5c04..8670fbea17 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs @@ -2,13 +2,12 @@ using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.Authentication.OpenIdConnect +namespace Volo.Abp.AspNetCore.Authentication.OpenIdConnect; + +[DependsOn( + typeof(AbpMultiTenancyModule), + typeof(AbpAspNetCoreAuthenticationOAuthModule))] +public class AbpAspNetCoreAuthenticationOpenIdConnectModule : AbpModule { - [DependsOn( - typeof(AbpMultiTenancyModule), - typeof(AbpAspNetCoreAuthenticationOAuthModule))] - public class AbpAspNetCoreAuthenticationOpenIdConnectModule : AbpModule - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/AbpAspNetCoreComponentsServerThemingModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/AbpAspNetCoreComponentsServerThemingModule.cs index 72462b97d6..dab511b595 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/AbpAspNetCoreComponentsServerThemingModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/AbpAspNetCoreComponentsServerThemingModule.cs @@ -4,34 +4,33 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Components.Server.Theming +namespace Volo.Abp.AspNetCore.Components.Server.Theming; + +[DependsOn( + typeof(AbpAspNetCoreComponentsServerModule), + typeof(AbpAspNetCoreMvcUiPackagesModule), + typeof(AbpAspNetCoreComponentsWebThemingModule), + typeof(AbpAspNetCoreMvcUiBundlingModule) + )] +public class AbpAspNetCoreComponentsServerThemingModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreComponentsServerModule), - typeof(AbpAspNetCoreMvcUiPackagesModule), - typeof(AbpAspNetCoreComponentsWebThemingModule), - typeof(AbpAspNetCoreMvcUiBundlingModule) - )] - public class AbpAspNetCoreComponentsServerThemingModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options - .StyleBundles - .Add(BlazorStandardBundles.Styles.Global, bundle => - { - bundle.AddContributors(typeof(BlazorGlobalStyleContributor)); - }); - - options - .ScriptBundles - .Add(BlazorStandardBundles.Scripts.Global, bundle => - { - bundle.AddContributors(typeof(BlazorGlobalScriptContributor)); - }); - }); - } + options + .StyleBundles + .Add(BlazorStandardBundles.Styles.Global, bundle => + { + bundle.AddContributors(typeof(BlazorGlobalStyleContributor)); + }); + + options + .ScriptBundles + .Add(BlazorStandardBundles.Scripts.Global, bundle => + { + bundle.AddContributors(typeof(BlazorGlobalScriptContributor)); + }); + }); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalBundles.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalBundles.cs index 7112fd342d..d65efa0c3f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalBundles.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalBundles.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling +namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling; + +public class BlazorStandardBundles { - public class BlazorStandardBundles + public static class Styles { - public static class Styles - { - public static string Global = "Blazor.Global"; - } + public static string Global = "Blazor.Global"; + } - public static class Scripts - { - public static string Global = "Blazor.Global"; - } + public static class Scripts + { + public static string Global = "Blazor.Global"; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalScriptContributor.cs index 6a0542f717..8977acc869 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalScriptContributor.cs @@ -1,14 +1,13 @@ using System.Collections.Generic; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling +namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling; + +public class BlazorGlobalScriptContributor : BundleContributor { - public class BlazorGlobalScriptContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/_framework/blazor.server.js"); - context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); - } + context.Files.AddIfNotContains("/_framework/blazor.server.js"); + context.Files.AddIfNotContains("/_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalStyleContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalStyleContributor.cs index 9e712ffba7..3223be417c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalStyleContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server.Theming/Bundling/BlazorGlobalStyleContributor.cs @@ -4,19 +4,18 @@ using Volo.Abp.AspNetCore.Mvc.UI.Packages.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Packages.FontAwesome; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling +namespace Volo.Abp.AspNetCore.Components.Server.Theming.Bundling; + +[DependsOn( + typeof(BootstrapStyleContributor), + typeof(FontAwesomeStyleContributor) +)] +public class BlazorGlobalStyleContributor : BundleContributor { - [DependsOn( - typeof(BootstrapStyleContributor), - typeof(FontAwesomeStyleContributor) - )] - public class BlazorGlobalStyleContributor : BundleContributor + public override void ConfigureBundle(BundleConfigurationContext context) { - public override void ConfigureBundle(BundleConfigurationContext context) - { - context.Files.AddIfNotContains("/_content/Blazorise/blazorise.css"); - context.Files.AddIfNotContains("/_content/Blazorise.Bootstrap5/blazorise.bootstrap5.css"); - context.Files.AddIfNotContains("/_content/Blazorise.Snackbar/blazorise.snackbar.css"); - } + context.Files.AddIfNotContains("/_content/Blazorise/blazorise.css"); + context.Files.AddIfNotContains("/_content/Blazorise.Bootstrap5/blazorise.bootstrap5.css"); + context.Files.AddIfNotContains("/_content/Blazorise.Snackbar/blazorise.snackbar.css"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs index 91b672b073..dfa515c1b8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Hosting; using Volo.Abp.AspNetCore.Auditing; using Volo.Abp.AspNetCore.Components.Web; using Volo.Abp.AspNetCore.Mvc; @@ -12,49 +13,54 @@ using Volo.Abp.EventBus; using Volo.Abp.Http.Client; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Components.Server +namespace Volo.Abp.AspNetCore.Components.Server; + +[DependsOn( + typeof(AbpHttpClientModule), + typeof(AbpAspNetCoreComponentsWebModule), + typeof(AbpAspNetCoreSignalRModule), + typeof(AbpEventBusModule), + typeof(AbpAspNetCoreMvcContractsModule) + )] +public class AbpAspNetCoreComponentsServerModule : AbpModule { - [DependsOn( - typeof(AbpHttpClientModule), - typeof(AbpAspNetCoreComponentsWebModule), - typeof(AbpAspNetCoreSignalRModule), - typeof(AbpEventBusModule), - typeof(AbpAspNetCoreMvcContractsModule) - )] - public class AbpAspNetCoreComponentsServerModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + var serverSideBlazorBuilder = context.Services.AddServerSideBlazor(options => { - var serverSideBlazorBuilder = context.Services.AddServerSideBlazor(); - context.Services.ExecutePreConfiguredActions(serverSideBlazorBuilder); - - Configure(options => + if (context.Services.GetHostingEnvironment().IsDevelopment()) { - options.IgnoredUrls.AddIfNotContains("/_blazor"); - }); + options.DetailedErrors = true; + } + }); + context.Services.ExecutePreConfiguredActions(serverSideBlazorBuilder); - Configure(options => - { - options.IgnoredUrls.AddIfNotContains("/_blazor"); - }); + Configure(options => + { + options.IgnoredUrls.AddIfNotContains("/_blazor"); + }); - Configure(options => + Configure(options => + { + options.IgnoredUrls.AddIfNotContains("/_blazor"); + }); + + Configure(options => + { + options.EndpointConfigureActions.Add(endpointContext => { - options.EndpointConfigureActions.Add(endpointContext => - { - endpointContext.Endpoints.MapBlazorHub(); - endpointContext.Endpoints.MapFallbackToPage("/_Host"); - }); + endpointContext.Endpoints.MapBlazorHub(); + endpointContext.Endpoints.MapFallbackToPage("/_Host"); }); - } + }); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - context.GetEnvironment().WebRootFileProvider = - new CompositeFileProvider( - new ManifestEmbeddedFileProvider(typeof(IServerSideBlazorBuilder).Assembly), - context.GetEnvironment().WebRootFileProvider - ); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + context.GetEnvironment().WebRootFileProvider = + new CompositeFileProvider( + new ManifestEmbeddedFileProvider(typeof(IServerSideBlazorBuilder).Assembly), + context.GetEnvironment().WebRootFileProvider + ); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Configuration/BlazorServerCurrentApplicationConfigurationCacheResetService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Configuration/BlazorServerCurrentApplicationConfigurationCacheResetService.cs index 1e3cd857e5..02de9d8bf7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Configuration/BlazorServerCurrentApplicationConfigurationCacheResetService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Configuration/BlazorServerCurrentApplicationConfigurationCacheResetService.cs @@ -4,26 +4,25 @@ using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Local; -namespace Volo.Abp.AspNetCore.Components.Server.Configuration +namespace Volo.Abp.AspNetCore.Components.Server.Configuration; + +[Dependency(ReplaceServices = true)] +public class BlazorServerCurrentApplicationConfigurationCacheResetService : + ICurrentApplicationConfigurationCacheResetService, + ITransientDependency { - [Dependency(ReplaceServices = true)] - public class BlazorServerCurrentApplicationConfigurationCacheResetService : - ICurrentApplicationConfigurationCacheResetService, - ITransientDependency - { - private readonly ILocalEventBus _localEventBus; + private readonly ILocalEventBus _localEventBus; - public BlazorServerCurrentApplicationConfigurationCacheResetService( - ILocalEventBus localEventBus) - { - _localEventBus = localEventBus; - } + public BlazorServerCurrentApplicationConfigurationCacheResetService( + ILocalEventBus localEventBus) + { + _localEventBus = localEventBus; + } - public async Task ResetAsync() - { - await _localEventBus.PublishAsync( - new CurrentApplicationConfigurationCacheResetEventData() - ); - } + public async Task ResetAsync() + { + await _localEventBus.PublishAsync( + new CurrentApplicationConfigurationCacheResetEventData() + ); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs index 952a2d6de4..2071e40f0b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/Extensibility/BlazorServerLookupApiRequestService.cs @@ -13,78 +13,77 @@ using Volo.Abp.Http.Client; using Volo.Abp.Http.Client.Authentication; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.Components.Server.Extensibility +namespace Volo.Abp.AspNetCore.Components.Server.Extensibility; + +public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITransientDependency { - public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITransientDependency + public IHttpClientFactory HttpClientFactory { get; } + public IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; } + public IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; } + public ICurrentTenant CurrentTenant { get; } + public IHttpContextAccessor HttpContextAccessor { get; } + public NavigationManager NavigationManager { get; } + + public BlazorServerLookupApiRequestService(IHttpClientFactory httpClientFactory, + IRemoteServiceHttpClientAuthenticator httpClientAuthenticator, + ICurrentTenant currentTenant, + IHttpContextAccessor httpContextAccessor, + NavigationManager navigationManager, + IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) { - public IHttpClientFactory HttpClientFactory { get; } - public IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; } - public IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; } - public ICurrentTenant CurrentTenant { get; } - public IHttpContextAccessor HttpContextAccessor { get; } - public NavigationManager NavigationManager { get; } + HttpClientFactory = httpClientFactory; + HttpClientAuthenticator = httpClientAuthenticator; + CurrentTenant = currentTenant; + HttpContextAccessor = httpContextAccessor; + NavigationManager = navigationManager; + RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; + } - public BlazorServerLookupApiRequestService(IHttpClientFactory httpClientFactory, - IRemoteServiceHttpClientAuthenticator httpClientAuthenticator, - ICurrentTenant currentTenant, - IHttpContextAccessor httpContextAccessor, - NavigationManager navigationManager, - IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) - { - HttpClientFactory = httpClientFactory; - HttpClientAuthenticator = httpClientAuthenticator; - CurrentTenant = currentTenant; - HttpContextAccessor = httpContextAccessor; - NavigationManager = navigationManager; - RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; - } + public async Task SendAsync(string url) + { + var client = HttpClientFactory.CreateClient(); + var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); - public async Task SendAsync(string url) + var uri = new Uri(url, UriKind.RelativeOrAbsolute); + if (!uri.IsAbsoluteUri) { - var client = HttpClientFactory.CreateClient(); - var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); - - var uri = new Uri(url, UriKind.RelativeOrAbsolute); - if (!uri.IsAbsoluteUri) + var baseUrl = string.Empty; + try { - var baseUrl = string.Empty; - try - { - //Blazor tiered -- mode - var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); - baseUrl = remoteServiceConfig.BaseUrl; - client.BaseAddress = new Uri(baseUrl); - AddHeaders(requestMessage); - await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, - requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty)); - } - catch (AbpException) // Blazor-Server mode. + //Blazor tiered -- mode + var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); + baseUrl = remoteServiceConfig.BaseUrl; + client.BaseAddress = new Uri(baseUrl); + AddHeaders(requestMessage); + await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, + requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty)); + } + catch (AbpException) // Blazor-Server mode. + { + baseUrl = NavigationManager.BaseUri; + client.BaseAddress = new Uri(baseUrl); + foreach (var header in HttpContextAccessor.HttpContext.Request.Headers) { - baseUrl = NavigationManager.BaseUri; - client.BaseAddress = new Uri(baseUrl); - foreach (var header in HttpContextAccessor.HttpContext.Request.Headers) - { - requestMessage.Headers.Add(header.Key, header.Value.ToArray()); - } + requestMessage.Headers.Add(header.Key, header.Value.ToArray()); } } - - var response = await client.SendAsync(requestMessage); - return await response.Content.ReadAsStringAsync(); } - protected virtual void AddHeaders(HttpRequestMessage requestMessage) + var response = await client.SendAsync(requestMessage); + return await response.Content.ReadAsStringAsync(); + } + + protected virtual void AddHeaders(HttpRequestMessage requestMessage) + { + if (CurrentTenant.Id.HasValue) { - if (CurrentTenant.Id.HasValue) - { - requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString()); - } + requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString()); + } - var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name; - if (!currentCulture.IsNullOrEmpty()) - { - requestMessage.Headers.AcceptLanguage.Add(new(currentCulture)); - } + var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name; + if (!currentCulture.IsNullOrEmpty()) + { + requestMessage.Headers.AcceptLanguage.Add(new(currentCulture)); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/AbpAspNetCoreComponentsWebThemingModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/AbpAspNetCoreComponentsWebThemingModule.cs index e5c71c8496..e2a0617b90 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/AbpAspNetCoreComponentsWebThemingModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/AbpAspNetCoreComponentsWebThemingModule.cs @@ -2,14 +2,13 @@ using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; -namespace Volo.Abp.AspNetCore.Components.Web.Theming +namespace Volo.Abp.AspNetCore.Components.Web.Theming; + +[DependsOn( + typeof(AbpBlazoriseUIModule), + typeof(AbpUiNavigationModule) + )] +public class AbpAspNetCoreComponentsWebThemingModule : AbpModule { - [DependsOn( - typeof(AbpBlazoriseUIModule), - typeof(AbpUiNavigationModule) - )] - public class AbpAspNetCoreComponentsWebThemingModule : AbpModule - { - - } -} \ No newline at end of file + +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs index 7806aa4b44..594909cd52 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageHeader.razor.cs @@ -5,69 +5,68 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; using Volo.Abp.BlazoriseUI; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Layout +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Layout; + +public partial class PageHeader : ComponentBase { - public partial class PageHeader : ComponentBase - { - protected List ToolbarItemRenders { get; set; } - - public IPageToolbarManager PageToolbarManager { get; set; } - - [Parameter] - public string Title { get; set; } + protected List ToolbarItemRenders { get; set; } - [Parameter] - public bool BreadcrumbShowHome { get; set; } = true; + public IPageToolbarManager PageToolbarManager { get; set; } - [Parameter] - public bool BreadcrumbShowCurrent { get; set; } = true; + [Parameter] + public string Title { get; set; } - [Parameter] - public RenderFragment ChildContent { get; set; } + [Parameter] + public bool BreadcrumbShowHome { get; set; } = true; - [Parameter] - public List BreadcrumbItems { get; set; } - - [Parameter] - public PageToolbar Toolbar { get; set; } + [Parameter] + public bool BreadcrumbShowCurrent { get; set; } = true; - public PageHeader() - { - BreadcrumbItems = new List(); - ToolbarItemRenders = new List(); - } + [Parameter] + public RenderFragment ChildContent { get; set; } + + [Parameter] + public List BreadcrumbItems { get; set; } + + [Parameter] + public PageToolbar Toolbar { get; set; } + + public PageHeader() + { + BreadcrumbItems = new List(); + ToolbarItemRenders = new List(); + } - protected override async Task OnParametersSetAsync() + protected override async Task OnParametersSetAsync() + { + await base.OnParametersSetAsync(); + if (Toolbar != null) { - await base.OnParametersSetAsync(); - if (Toolbar!=null) - { - var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar); - ToolbarItemRenders.Clear(); + var toolbarItems = await PageToolbarManager.GetItemsAsync(Toolbar); + ToolbarItemRenders.Clear(); - foreach (var item in toolbarItems) + foreach (var item in toolbarItems) + { + var sequence = 0; + ToolbarItemRenders.Add(builder => { - var sequence = 0; - ToolbarItemRenders.Add(builder => + builder.OpenComponent(sequence, item.ComponentType); + if (item.Arguments != null) { - builder.OpenComponent(sequence, item.ComponentType); - if (item.Arguments != null) + foreach (var argument in item.Arguments) { - foreach (var argument in item.Arguments) - { - sequence++; - builder.AddAttribute(sequence, argument.Key, argument.Value); - } + sequence++; + builder.AddAttribute(sequence, argument.Key, argument.Value); } - builder.CloseComponent(); - }); - } + } + builder.CloseComponent(); + }); } } + } - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - } + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarContributor.cs index dd04c0a1ff..426fdde4c9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarContributor.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public interface IPageToolbarContributor { - public interface IPageToolbarContributor - { - Task ContributeAsync(PageToolbarContributionContext context); - } + Task ContributeAsync(PageToolbarContributionContext context); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarManager.cs index 507fa8070b..87e256b1ce 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/IPageToolbarManager.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public interface IPageToolbarManager { - public interface IPageToolbarManager - { - Task GetItemsAsync(PageToolbar toolbar); - } + Task GetItemsAsync(PageToolbar toolbar); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbar.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbar.cs index 84a9bae7c4..f1fb792996 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbar.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbar.cs @@ -1,12 +1,11 @@ -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbar { - public class PageToolbar - { - public PageToolbarContributorList Contributors { get; set; } + public PageToolbarContributorList Contributors { get; set; } - public PageToolbar() - { - Contributors = new PageToolbarContributorList(); - } + public PageToolbar() + { + Contributors = new PageToolbarContributorList(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributionContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributionContext.cs index 5544510b71..057777cfdf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributionContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributionContext.cs @@ -1,21 +1,20 @@ using JetBrains.Annotations; using System; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbarContributionContext { - public class PageToolbarContributionContext - { - [NotNull] - public IServiceProvider ServiceProvider { get; } + [NotNull] + public IServiceProvider ServiceProvider { get; } - [NotNull] - public PageToolbarItemList Items { get; } + [NotNull] + public PageToolbarItemList Items { get; } - public PageToolbarContributionContext( - [NotNull] IServiceProvider serviceProvider) - { - ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider)); - Items = new PageToolbarItemList(); - } + public PageToolbarContributionContext( + [NotNull] IServiceProvider serviceProvider) + { + ServiceProvider = Check.NotNull(serviceProvider, nameof(serviceProvider)); + Items = new PageToolbarItemList(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributor.cs index 3c5196c449..87521c592f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributor.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public abstract class PageToolbarContributor : IPageToolbarContributor { - public abstract class PageToolbarContributor : IPageToolbarContributor - { - public abstract Task ContributeAsync(PageToolbarContributionContext context); - } + public abstract Task ContributeAsync(PageToolbarContributionContext context); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributorList.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributorList.cs index 984f4618dc..02ef1bfb00 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributorList.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarContributorList.cs @@ -1,8 +1,7 @@ using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbarContributorList : List { - public class PageToolbarContributorList : List - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarDictionary.cs index 2368ab9caf..65c2e8a25d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarDictionary.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbarDictionary : Dictionary { - public class PageToolbarDictionary : Dictionary - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs index 3879e27e3c..dd2063d0cf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarExtensions.cs @@ -5,67 +5,66 @@ using System.Threading.Tasks; using Volo.Abp.BlazoriseUI.Components; using Volo.Abp.Localization; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public static class PageToolbarExtensions { - public static class PageToolbarExtensions + public static PageToolbar AddComponent( + this PageToolbar toolbar, + Dictionary arguments = null, + int order = 0, + string requiredPolicyName = null) { - public static PageToolbar AddComponent( - this PageToolbar toolbar, - Dictionary arguments = null, - int order = 0, - string requiredPolicyName = null) - { - return toolbar.AddComponent( - typeof(TComponent), + return toolbar.AddComponent( + typeof(TComponent), + arguments, + order, + requiredPolicyName + ); + } + + public static PageToolbar AddComponent( + this PageToolbar toolbar, + Type componentType, + Dictionary arguments = null, + int order = 0, + string requiredPolicyName = null) + { + toolbar.Contributors.Add( + new SimplePageToolbarContributor( + componentType, arguments, order, requiredPolicyName - ); - } - - public static PageToolbar AddComponent( - this PageToolbar toolbar, - Type componentType, - Dictionary arguments = null, - int order = 0, - string requiredPolicyName = null) - { - toolbar.Contributors.Add( - new SimplePageToolbarContributor( - componentType, - arguments, - order, - requiredPolicyName - ) - ); + ) + ); - return toolbar; - } + return toolbar; + } - public static PageToolbar AddButton( - this PageToolbar toolbar, - string text, - Func clicked, - object icon = null, - Color color = Color.Primary, - bool disabled = false, - int order = 0, - string requiredPolicyName = null) - { - toolbar.AddComponent( - new Dictionary - { + public static PageToolbar AddButton( + this PageToolbar toolbar, + string text, + Func clicked, + object icon = null, + Color color = Color.Primary, + bool disabled = false, + int order = 0, + string requiredPolicyName = null) + { + toolbar.AddComponent( + new Dictionary + { { nameof(ToolbarButton.Color), color}, { nameof(ToolbarButton.Text), text}, { nameof(ToolbarButton.Disabled), disabled}, { nameof(ToolbarButton.Icon), icon}, { nameof(ToolbarButton.Clicked),clicked}, - }, - order, - requiredPolicyName - ); + }, + order, + requiredPolicyName + ); - return toolbar; - } + return toolbar; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs index 0e1650a803..f62d770403 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItem.cs @@ -2,26 +2,25 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbarItem { - public class PageToolbarItem - { - [NotNull] - public Type ComponentType { get; } + [NotNull] + public Type ComponentType { get; } - [CanBeNull] - public Dictionary Arguments { get; set; } + [CanBeNull] + public Dictionary Arguments { get; set; } - public int Order { get; set; } + public int Order { get; set; } - public PageToolbarItem( - [NotNull] Type componentType, - [CanBeNull] Dictionary arguments = null, - int order = 0) - { - ComponentType = Check.NotNull(componentType, nameof(componentType)); - Arguments = arguments; - Order = order; - } + public PageToolbarItem( + [NotNull] Type componentType, + [CanBeNull] Dictionary arguments = null, + int order = 0) + { + ComponentType = Check.NotNull(componentType, nameof(componentType)); + Arguments = arguments; + Order = order; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItemList.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItemList.cs index 7042b2ed05..4be5e6fab1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItemList.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarItemList.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbarItemList : List { - public class PageToolbarItemList : List - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarManager.cs index adcd72f25e..05531096d4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/PageToolbarManager.cs @@ -5,36 +5,35 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class PageToolbarManager : IPageToolbarManager, ITransientDependency { - public class PageToolbarManager : IPageToolbarManager, ITransientDependency + protected IHybridServiceScopeFactory ServiceScopeFactory { get; } + + public PageToolbarManager( + IHybridServiceScopeFactory serviceScopeFactory) { - protected IHybridServiceScopeFactory ServiceScopeFactory { get; } + ServiceScopeFactory = serviceScopeFactory; + } - public PageToolbarManager( - IHybridServiceScopeFactory serviceScopeFactory) + public virtual async Task GetItemsAsync(PageToolbar toolbar) + { + if (toolbar == null || !toolbar.Contributors.Any()) { - ServiceScopeFactory = serviceScopeFactory; + return Array.Empty(); } - public virtual async Task GetItemsAsync(PageToolbar toolbar) + using (var scope = ServiceScopeFactory.CreateScope()) { - if (toolbar == null || !toolbar.Contributors.Any()) - { - return Array.Empty(); - } + var context = new PageToolbarContributionContext(scope.ServiceProvider); - using (var scope = ServiceScopeFactory.CreateScope()) + foreach (var contributor in toolbar.Contributors) { - var context = new PageToolbarContributionContext(scope.ServiceProvider); - - foreach (var contributor in toolbar.Contributors) - { - await contributor.ContributeAsync(context); - } - - return context.Items.OrderBy(i => i.Order).ToArray(); + await contributor.ContributeAsync(context); } + + return context.Items.OrderBy(i => i.Order).ToArray(); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs index 82afe19f7f..d31b12e73c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/PageToolbars/SimplePageToolbarContributor.cs @@ -4,50 +4,49 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; + +public class SimplePageToolbarContributor : IPageToolbarContributor { - public class SimplePageToolbarContributor : IPageToolbarContributor - { - public Type ComponentType { get; } + public Type ComponentType { get; } - public Dictionary Arguments { get; set; } + public Dictionary Arguments { get; set; } - public int Order { get; } + public int Order { get; } - public string RequiredPolicyName { get; } + public string RequiredPolicyName { get; } - public SimplePageToolbarContributor( - Type componentType, - Dictionary arguments = null, - int order = 0, - string requiredPolicyName = null) - { - ComponentType = componentType; - Arguments = arguments; - Order = order; - RequiredPolicyName = requiredPolicyName; - } + public SimplePageToolbarContributor( + Type componentType, + Dictionary arguments = null, + int order = 0, + string requiredPolicyName = null) + { + ComponentType = componentType; + Arguments = arguments; + Order = order; + RequiredPolicyName = requiredPolicyName; + } - public async Task ContributeAsync(PageToolbarContributionContext context) + public async Task ContributeAsync(PageToolbarContributionContext context) + { + if (await ShouldAddComponentAsync(context)) { - if (await ShouldAddComponentAsync(context)) - { - context.Items.Add(new PageToolbarItem(ComponentType, Arguments, Order)); - } + context.Items.Add(new PageToolbarItem(ComponentType, Arguments, Order)); } + } - protected virtual async Task ShouldAddComponentAsync(PageToolbarContributionContext context) + protected virtual async Task ShouldAddComponentAsync(PageToolbarContributionContext context) + { + if (RequiredPolicyName != null) { - if (RequiredPolicyName != null) + var authorizationService = context.ServiceProvider.GetRequiredService(); + if (!await authorizationService.IsGrantedAsync(RequiredPolicyName)) { - var authorizationService = context.ServiceProvider.GetRequiredService(); - if (!await authorizationService.IsGrantedAsync(RequiredPolicyName)) - { - return false; - } + return false; } - - return true; } + + return true; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs index 9655d41186..ce3b2746e4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/AbpRouterOptions.cs @@ -1,16 +1,15 @@ using System.Reflection; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Routing +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Routing; + +public class AbpRouterOptions { - public class AbpRouterOptions - { - public Assembly AppAssembly { get; set; } + public Assembly AppAssembly { get; set; } - public RouterAssemblyList AdditionalAssemblies { get; } + public RouterAssemblyList AdditionalAssemblies { get; } - public AbpRouterOptions() - { - AdditionalAssemblies = new RouterAssemblyList(); - } + public AbpRouterOptions() + { + AdditionalAssemblies = new RouterAssemblyList(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/RouterAssemblyList.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/RouterAssemblyList.cs index ea1153ff1f..ad9d5ea404 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/RouterAssemblyList.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Routing/RouterAssemblyList.cs @@ -1,10 +1,9 @@ using System.Collections.Generic; using System.Reflection; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Routing +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Routing; + +public class RouterAssemblyList : List { - public class RouterAssemblyList : List - { - - } -} \ No newline at end of file + +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/AbpToolbarOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/AbpToolbarOptions.cs index a2bae7460d..b713386359 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/AbpToolbarOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/AbpToolbarOptions.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public class AbpToolbarOptions { - public class AbpToolbarOptions - { - [NotNull] - public List Contributors { get; } + [NotNull] + public List Contributors { get; } - public AbpToolbarOptions() - { - Contributors = new List(); - } + public AbpToolbarOptions() + { + Contributors = new List(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs index 8ebe76bcb4..e2bfaf06d0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarConfigurationContext.cs @@ -5,25 +5,24 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Localization; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public interface IToolbarConfigurationContext : IServiceProviderAccessor { - public interface IToolbarConfigurationContext : IServiceProviderAccessor - { - Toolbar Toolbar { get; } + Toolbar Toolbar { get; } - IAuthorizationService AuthorizationService { get; } + IAuthorizationService AuthorizationService { get; } - IStringLocalizerFactory StringLocalizerFactory { get; } + IStringLocalizerFactory StringLocalizerFactory { get; } - Task IsGrantedAsync(string policyName); + Task IsGrantedAsync(string policyName); - [CanBeNull] - IStringLocalizer GetDefaultLocalizer(); + [CanBeNull] + IStringLocalizer GetDefaultLocalizer(); - [NotNull] - public IStringLocalizer GetLocalizer(); + [NotNull] + public IStringLocalizer GetLocalizer(); - [NotNull] - public IStringLocalizer GetLocalizer(Type resourceType); - } + [NotNull] + public IStringLocalizer GetLocalizer(Type resourceType); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarContributor.cs index 6a5de9c1c9..c56f964265 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarContributor.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public interface IToolbarContributor { - public interface IToolbarContributor - { - Task ConfigureToolbarAsync(IToolbarConfigurationContext context); - } -} \ No newline at end of file + Task ConfigureToolbarAsync(IToolbarConfigurationContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarManager.cs index 0550ce75b6..df36b9ca32 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/IToolbarManager.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public interface IToolbarManager { - public interface IToolbarManager - { - Task GetAsync(string name); - } + Task GetAsync(string name); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/StandardToolbars.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/StandardToolbars.cs index 7cda0d8897..9c84d8165e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/StandardToolbars.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/StandardToolbars.cs @@ -1,7 +1,6 @@ -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public static class StandardToolbars { - public static class StandardToolbars - { - public const string Main = "Main"; - } -} \ No newline at end of file + public const string Main = "Main"; +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/Toolbar.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/Toolbar.cs index b25cc608b6..cd02da35c2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/Toolbar.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/Toolbar.cs @@ -1,18 +1,17 @@ using System.Collections.Generic; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public class Toolbar { - public class Toolbar - { - public string Name { get; } + public string Name { get; } - public List Items { get; } + public List Items { get; } - public Toolbar([NotNull] string name) - { - Name = Check.NotNull(name, nameof(name)); - Items = new List(); - } + public Toolbar([NotNull] string name) + { + Name = Check.NotNull(name, nameof(name)); + Items = new List(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs index fab4eb8f6c..f773ba14e1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarConfigurationContext.cs @@ -6,48 +6,47 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public class ToolbarConfigurationContext : IToolbarConfigurationContext { - public class ToolbarConfigurationContext : IToolbarConfigurationContext - { - public IServiceProvider ServiceProvider { get; } + public IServiceProvider ServiceProvider { get; } - private readonly IAbpLazyServiceProvider _lazyServiceProvider; + private readonly IAbpLazyServiceProvider _lazyServiceProvider; - public IAuthorizationService AuthorizationService => _lazyServiceProvider.LazyGetRequiredService(); + public IAuthorizationService AuthorizationService => _lazyServiceProvider.LazyGetRequiredService(); - public IStringLocalizerFactory StringLocalizerFactory => _lazyServiceProvider.LazyGetRequiredService(); + public IStringLocalizerFactory StringLocalizerFactory => _lazyServiceProvider.LazyGetRequiredService(); - public Toolbar Toolbar { get; } + public Toolbar Toolbar { get; } - public ToolbarConfigurationContext(Toolbar toolbar, IServiceProvider serviceProvider) - { - Toolbar = toolbar; - ServiceProvider = serviceProvider; - _lazyServiceProvider = ServiceProvider.GetRequiredService(); - } + public ToolbarConfigurationContext(Toolbar toolbar, IServiceProvider serviceProvider) + { + Toolbar = toolbar; + ServiceProvider = serviceProvider; + _lazyServiceProvider = ServiceProvider.GetRequiredService(); + } - public Task IsGrantedAsync(string policyName) - { - return AuthorizationService.IsGrantedAsync(policyName); - } + public Task IsGrantedAsync(string policyName) + { + return AuthorizationService.IsGrantedAsync(policyName); + } - [CanBeNull] - public IStringLocalizer GetDefaultLocalizer() - { - return StringLocalizerFactory.CreateDefaultOrNull(); - } + [CanBeNull] + public IStringLocalizer GetDefaultLocalizer() + { + return StringLocalizerFactory.CreateDefaultOrNull(); + } - [NotNull] - public IStringLocalizer GetLocalizer() - { - return StringLocalizerFactory.Create(); - } + [NotNull] + public IStringLocalizer GetLocalizer() + { + return StringLocalizerFactory.Create(); + } - [NotNull] - public IStringLocalizer GetLocalizer(Type resourceType) - { - return StringLocalizerFactory.Create(resourceType); - } + [NotNull] + public IStringLocalizer GetLocalizer(Type resourceType) + { + return StringLocalizerFactory.Create(resourceType); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs index d6bfcd1fb8..966145a4ee 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarItem.cs @@ -1,23 +1,21 @@ using System; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public class ToolbarItem { - public class ToolbarItem - { - public Type ComponentType - { - get => _componentType; - set => _componentType = Check.NotNull(value, nameof(value)); - } - private Type _componentType; + public Type ComponentType { + get => _componentType; + set => _componentType = Check.NotNull(value, nameof(value)); + } + private Type _componentType; - public int Order { get; set; } + public int Order { get; set; } - public ToolbarItem([NotNull] Type componentType, int order = 0) - { - Order = order; - ComponentType = Check.NotNull(componentType, nameof(componentType)); - } + public ToolbarItem([NotNull] Type componentType, int order = 0) + { + Order = order; + ComponentType = Check.NotNull(componentType, nameof(componentType)); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarManager.cs index 86bdfc751e..b4746fe85f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Toolbars/ToolbarManager.cs @@ -4,36 +4,35 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars +namespace Volo.Abp.AspNetCore.Components.Web.Theming.Toolbars; + +public class ToolbarManager : IToolbarManager, ITransientDependency { - public class ToolbarManager : IToolbarManager, ITransientDependency + protected AbpToolbarOptions Options { get; } + protected IServiceProvider ServiceProvider { get; } + + public ToolbarManager( + IOptions options, + IServiceProvider serviceProvider) { - protected AbpToolbarOptions Options { get; } - protected IServiceProvider ServiceProvider { get; } + ServiceProvider = serviceProvider; + Options = options.Value; + } - public ToolbarManager( - IOptions options, - IServiceProvider serviceProvider) - { - ServiceProvider = serviceProvider; - Options = options.Value; - } + public async Task GetAsync(string name) + { + var toolbar = new Toolbar(name); - public async Task GetAsync(string name) + using (var scope = ServiceProvider.CreateScope()) { - var toolbar = new Toolbar(name); + var context = new ToolbarConfigurationContext(toolbar, scope.ServiceProvider); - using (var scope = ServiceProvider.CreateScope()) + foreach (var contributor in Options.Contributors) { - var context = new ToolbarConfigurationContext(toolbar, scope.ServiceProvider); - - foreach (var contributor in Options.Contributors) - { - await contributor.ConfigureToolbarAsync(context); - } + await contributor.ConfigureToolbarAsync(context); } - - return toolbar; } + + return toolbar; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreApplicationCreationOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreApplicationCreationOptions.cs index 4eab62f819..27efa5f998 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreApplicationCreationOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreApplicationCreationOptions.cs @@ -1,13 +1,12 @@ -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public class AbpAspNetCoreApplicationCreationOptions { - public class AbpAspNetCoreApplicationCreationOptions - { - public AbpApplicationCreationOptions ApplicationCreationOptions { get; } + public AbpApplicationCreationOptions ApplicationCreationOptions { get; } - public AbpAspNetCoreApplicationCreationOptions( - AbpApplicationCreationOptions applicationCreationOptions) - { - ApplicationCreationOptions = applicationCreationOptions; - } + public AbpAspNetCoreApplicationCreationOptions( + AbpApplicationCreationOptions applicationCreationOptions) + { + ApplicationCreationOptions = applicationCreationOptions; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreComponentsWebModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreComponentsWebModule.cs index ddcd839e3d..28984ce5d0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreComponentsWebModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpAspNetCoreComponentsWebModule.cs @@ -5,22 +5,21 @@ using Volo.Abp.AspNetCore.Components.DependencyInjection; using Volo.Abp.Modularity; using Volo.Abp.UI; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +[DependsOn( + typeof(AbpUiModule), + typeof(AbpAspNetCoreComponentsModule) + )] +public class AbpAspNetCoreComponentsWebModule : AbpModule { - [DependsOn( - typeof(AbpUiModule), - typeof(AbpAspNetCoreComponentsModule) - )] - public class AbpAspNetCoreComponentsWebModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - } + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.Replace(ServiceDescriptor.Transient()); - } + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.Replace(ServiceDescriptor.Transient()); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs index 450481a646..eb8bee99bd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorClientHttpMessageHandler.cs @@ -9,90 +9,89 @@ using Microsoft.JSInterop; using Volo.Abp.AspNetCore.Components.Progression; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public class AbpBlazorClientHttpMessageHandler : DelegatingHandler, ITransientDependency { - public class AbpBlazorClientHttpMessageHandler : DelegatingHandler, ITransientDependency - { - private readonly IJSRuntime _jsRuntime; + private readonly IJSRuntime _jsRuntime; - private readonly ICookieService _cookieService; + private readonly ICookieService _cookieService; - private readonly NavigationManager _navigationManager; + private readonly NavigationManager _navigationManager; - private readonly IUiPageProgressService _uiPageProgressService; + private readonly IUiPageProgressService _uiPageProgressService; - private const string AntiForgeryCookieName = "XSRF-TOKEN"; + private const string AntiForgeryCookieName = "XSRF-TOKEN"; - private const string AntiForgeryHeaderName = "RequestVerificationToken"; + private const string AntiForgeryHeaderName = "RequestVerificationToken"; - public AbpBlazorClientHttpMessageHandler( - IJSRuntime jsRuntime, - ICookieService cookieService, - NavigationManager navigationManager, - IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) - { - _jsRuntime = jsRuntime; - _cookieService = cookieService; - _navigationManager = navigationManager; - _uiPageProgressService = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); - } + public AbpBlazorClientHttpMessageHandler( + IJSRuntime jsRuntime, + ICookieService cookieService, + NavigationManager navigationManager, + IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) + { + _jsRuntime = jsRuntime; + _cookieService = cookieService; + _navigationManager = navigationManager; + _uiPageProgressService = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); + } - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + try { - try + await _uiPageProgressService.Go(null, options => { - await _uiPageProgressService.Go(null, options => - { - options.Type = UiPageProgressType.Info; - }); + options.Type = UiPageProgressType.Info; + }); - await SetLanguageAsync(request, cancellationToken); - await SetAntiForgeryTokenAsync(request); + await SetLanguageAsync(request, cancellationToken); + await SetAntiForgeryTokenAsync(request); - return await base.SendAsync(request, cancellationToken); - } - finally - { - await _uiPageProgressService.Go(-1); - } + return await base.SendAsync(request, cancellationToken); } - - private async Task SetLanguageAsync(HttpRequestMessage request, CancellationToken cancellationToken) + finally { - var selectedLanguage = await _jsRuntime.InvokeAsync( - "localStorage.getItem", - cancellationToken, - "Abp.SelectedLanguage" - ); + await _uiPageProgressService.Go(-1); + } + } - if (!selectedLanguage.IsNullOrWhiteSpace()) - { - request.Headers.AcceptLanguage.Clear(); - request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(selectedLanguage)); - } + private async Task SetLanguageAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var selectedLanguage = await _jsRuntime.InvokeAsync( + "localStorage.getItem", + cancellationToken, + "Abp.SelectedLanguage" + ); + + if (!selectedLanguage.IsNullOrWhiteSpace()) + { + request.Headers.AcceptLanguage.Clear(); + request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(selectedLanguage)); } + } - private async Task SetAntiForgeryTokenAsync(HttpRequestMessage request) + private async Task SetAntiForgeryTokenAsync(HttpRequestMessage request) + { + if (request.Method == HttpMethod.Get || request.Method == HttpMethod.Head || + request.Method == HttpMethod.Trace || request.Method == HttpMethod.Options) { - if (request.Method == HttpMethod.Get || request.Method == HttpMethod.Head || - request.Method == HttpMethod.Trace || request.Method == HttpMethod.Options) - { - return; - } + return; + } - var selfUri = new Uri(_navigationManager.Uri); + var selfUri = new Uri(_navigationManager.Uri); - if (request.RequestUri.Host != selfUri.Host || request.RequestUri.Port != selfUri.Port) - { - return; - } + if (request.RequestUri.Host != selfUri.Host || request.RequestUri.Port != selfUri.Port) + { + return; + } - var token = await _cookieService.GetAsync(AntiForgeryCookieName); + var token = await _cookieService.GetAsync(AntiForgeryCookieName); - if (!token.IsNullOrWhiteSpace()) - { - request.Headers.Add(AntiForgeryHeaderName, token); - } + if (!token.IsNullOrWhiteSpace()) + { + request.Headers.Add(AntiForgeryHeaderName, token); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs index 5b5a838e17..52efbc6d11 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpBlazorMessageLocalizerHelper.cs @@ -3,46 +3,45 @@ using System.Linq; using JetBrains.Annotations; using Microsoft.Extensions.Localization; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public class AbpBlazorMessageLocalizerHelper { - public class AbpBlazorMessageLocalizerHelper + private readonly IStringLocalizer stringLocalizer; + + public AbpBlazorMessageLocalizerHelper(IStringLocalizer stringLocalizer) { - private readonly IStringLocalizer stringLocalizer; + this.stringLocalizer = stringLocalizer; + } - public AbpBlazorMessageLocalizerHelper(IStringLocalizer stringLocalizer) + public string Localize(string message, [CanBeNull] IEnumerable arguments) + { + try { - this.stringLocalizer = stringLocalizer; + return arguments?.Count() > 0 + ? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()] + : stringLocalizer[message]; } - - public string Localize(string message, [CanBeNull] IEnumerable arguments) + catch { - try - { - return arguments?.Count() > 0 - ? stringLocalizer[message, LocalizeMessageArguments(arguments)?.ToArray()] - : stringLocalizer[message]; - } - catch - { - return stringLocalizer[message]; - } + return stringLocalizer[message]; } + } - private IEnumerable LocalizeMessageArguments(IEnumerable arguments) + private IEnumerable LocalizeMessageArguments(IEnumerable arguments) + { + foreach (var argument in arguments) { - foreach (var argument in arguments) - { - // first try to localize with "DisplayName:{Name}" - var localization = stringLocalizer[$"DisplayName:{argument}"]; + // first try to localize with "DisplayName:{Name}" + var localization = stringLocalizer[$"DisplayName:{argument}"]; - if (localization.ResourceNotFound) - { - // then try to localize with just "{Name}" - localization = stringLocalizer[argument]; - } - - yield return localization; + if (localization.ResourceNotFound) + { + // then try to localize with just "{Name}" + localization = stringLocalizer[argument]; } + + yield return localization; } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpUtilsService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpUtilsService.cs index b80e927154..082dd7c32f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpUtilsService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/AbpUtilsService.cs @@ -2,50 +2,49 @@ using Microsoft.JSInterop; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public class AbpUtilsService : IAbpUtilsService, ITransientDependency { - public class AbpUtilsService : IAbpUtilsService, ITransientDependency - { - protected IJSRuntime JsRuntime { get; } - - public AbpUtilsService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } - - public ValueTask AddClassToTagAsync(string tagName, string className) - { - return JsRuntime.InvokeVoidAsync("abp.utils.addClassToTag", tagName, className); - } - - public ValueTask RemoveClassFromTagAsync(string tagName, string className) - { - return JsRuntime.InvokeVoidAsync("abp.utils.removeClassFromTag", tagName, className); - } - - public ValueTask HasClassOnTagAsync(string tagName, string className) - { - return JsRuntime.InvokeAsync("abp.utils.hasClassOnTag", tagName, className); - } - - public ValueTask ReplaceLinkHrefByIdAsync(string linkId, string hrefValue) - { - return JsRuntime.InvokeVoidAsync("abp.utils.replaceLinkHrefById", linkId, hrefValue); - } - - public ValueTask ToggleFullscreenAsync() - { - return JsRuntime.InvokeVoidAsync("abp.utils.toggleFullscreen"); - } - - public ValueTask RequestFullscreenAsync() - { - return JsRuntime.InvokeVoidAsync("abp.utils.requestFullscreen"); - } - - public ValueTask ExitFullscreenAsync() - { - return JsRuntime.InvokeVoidAsync("abp.utils.exitFullscreen"); - } + protected IJSRuntime JsRuntime { get; } + + public AbpUtilsService(IJSRuntime jsRuntime) + { + JsRuntime = jsRuntime; + } + + public ValueTask AddClassToTagAsync(string tagName, string className) + { + return JsRuntime.InvokeVoidAsync("abp.utils.addClassToTag", tagName, className); + } + + public ValueTask RemoveClassFromTagAsync(string tagName, string className) + { + return JsRuntime.InvokeVoidAsync("abp.utils.removeClassFromTag", tagName, className); + } + + public ValueTask HasClassOnTagAsync(string tagName, string className) + { + return JsRuntime.InvokeAsync("abp.utils.hasClassOnTag", tagName, className); + } + + public ValueTask ReplaceLinkHrefByIdAsync(string linkId, string hrefValue) + { + return JsRuntime.InvokeVoidAsync("abp.utils.replaceLinkHrefById", linkId, hrefValue); + } + + public ValueTask ToggleFullscreenAsync() + { + return JsRuntime.InvokeVoidAsync("abp.utils.toggleFullscreen"); + } + + public ValueTask RequestFullscreenAsync() + { + return JsRuntime.InvokeVoidAsync("abp.utils.requestFullscreen"); + } + + public ValueTask ExitFullscreenAsync() + { + return JsRuntime.InvokeVoidAsync("abp.utils.exitFullscreen"); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Alerts/AlertManager.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Alerts/AlertManager.cs index aef46b97dd..218e3cbdea 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Alerts/AlertManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Alerts/AlertManager.cs @@ -1,15 +1,14 @@ using Volo.Abp.AspNetCore.Components.Alerts; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Alerts +namespace Volo.Abp.AspNetCore.Components.Web.Alerts; + +public class AlertManager : IAlertManager, IScopedDependency { - public class AlertManager : IAlertManager, IScopedDependency - { - public AlertList Alerts { get; } + public AlertList Alerts { get; } - public AlertManager() - { - Alerts = new AlertList(); - } + public AlertManager() + { + Alerts = new AlertList(); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/ICurrentApplicationConfigurationCacheResetService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/ICurrentApplicationConfigurationCacheResetService.cs index b1da30825d..c3e33a9e41 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/ICurrentApplicationConfigurationCacheResetService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/ICurrentApplicationConfigurationCacheResetService.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Configuration +namespace Volo.Abp.AspNetCore.Components.Web.Configuration; + +public interface ICurrentApplicationConfigurationCacheResetService { - public interface ICurrentApplicationConfigurationCacheResetService - { - Task ResetAsync(); - } -} \ No newline at end of file + Task ResetAsync(); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/NullCurrentApplicationConfigurationCacheResetService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/NullCurrentApplicationConfigurationCacheResetService.cs index 6eeb0e9471..bb91d70775 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/NullCurrentApplicationConfigurationCacheResetService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Configuration/NullCurrentApplicationConfigurationCacheResetService.cs @@ -1,13 +1,12 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Configuration +namespace Volo.Abp.AspNetCore.Components.Web.Configuration; + +public class NullCurrentApplicationConfigurationCacheResetService : ICurrentApplicationConfigurationCacheResetService, ISingletonDependency { - public class NullCurrentApplicationConfigurationCacheResetService : ICurrentApplicationConfigurationCacheResetService, ISingletonDependency + public Task ResetAsync() { - public Task ResetAsync() - { - return Task.CompletedTask; - } + return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs index 2781d9ead3..283f665642 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieOptions.cs @@ -1,11 +1,10 @@ using System; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public class CookieOptions { - public class CookieOptions - { - public DateTimeOffset? ExpireDate { get; set; } - public string Path { get; set; } - public bool Secure { get; set; } - } -} \ No newline at end of file + public DateTimeOffset? ExpireDate { get; set; } + public string Path { get; set; } + public bool Secure { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs index ed682261a3..1b61acb459 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/CookieService.cs @@ -2,31 +2,30 @@ using Microsoft.JSInterop; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +[Dependency(ReplaceServices = true)] +public class CookieService : ICookieService, ITransientDependency { - [Dependency(ReplaceServices = true)] - public class CookieService : ICookieService, ITransientDependency - { - public IJSRuntime JsRuntime { get; } + public IJSRuntime JsRuntime { get; } - public CookieService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } + public CookieService(IJSRuntime jsRuntime) + { + JsRuntime = jsRuntime; + } - public async ValueTask SetAsync(string key, string value, CookieOptions options) - { - await JsRuntime.InvokeVoidAsync("abp.utils.setCookieValue", key, value, options?.ExpireDate?.ToString("r"), options?.Path, options?.Secure); - } + public async ValueTask SetAsync(string key, string value, CookieOptions options) + { + await JsRuntime.InvokeVoidAsync("abp.utils.setCookieValue", key, value, options?.ExpireDate?.ToString("r"), options?.Path, options?.Secure); + } - public async ValueTask GetAsync(string key) - { - return await JsRuntime.InvokeAsync("abp.utils.getCookieValue", key); - } + public async ValueTask GetAsync(string key) + { + return await JsRuntime.InvokeAsync("abp.utils.getCookieValue", key); + } - public async ValueTask DeleteAsync(string key, string path = null) - { - await JsRuntime.InvokeVoidAsync("abp.utils.deleteCookie", key); - } + public async ValueTask DeleteAsync(string key, string path = null) + { + await JsRuntime.InvokeVoidAsync("abp.utils.deleteCookie", key); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs index 629a19d9f5..281ee3cd73 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DefaultServerUrlProvider.cs @@ -1,13 +1,12 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public class DefaultServerUrlProvider : IServerUrlProvider, ISingletonDependency { - public class DefaultServerUrlProvider : IServerUrlProvider, ISingletonDependency + public Task GetBaseUrlAsync(string remoteServiceName = null) { - public Task GetBaseUrlAsync(string remoteServiceName = null) - { - return Task.FromResult("/"); - } + return Task.FromResult("/"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs index 5ced9d658e..f5e07865a7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/DependencyInjection/ComponentsClientScopeServiceProviderAccessor.cs @@ -1,12 +1,11 @@ using System; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.DependencyInjection +namespace Volo.Abp.AspNetCore.Components.Web.DependencyInjection; + +public class ComponentsClientScopeServiceProviderAccessor : + IClientScopeServiceProviderAccessor, + ISingletonDependency { - public class ComponentsClientScopeServiceProviderAccessor : - IClientScopeServiceProviderAccessor, - ISingletonDependency - { - public IServiceProvider ServiceProvider { get; set; } - } + public IServiceProvider ServiceProvider { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs index 755947a481..cf66f107a0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLogger.cs @@ -3,64 +3,63 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Volo.Abp.AspNetCore.Components.ExceptionHandling; -namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling +namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling; + +public class AbpExceptionHandlingLogger : ILogger { - public class AbpExceptionHandlingLogger : ILogger + private readonly IServiceCollection _serviceCollection; + private IUserExceptionInformer _userExceptionInformer; + + public AbpExceptionHandlingLogger(IServiceCollection serviceCollection) { - private readonly IServiceCollection _serviceCollection; - private IUserExceptionInformer _userExceptionInformer; + _serviceCollection = serviceCollection; + } - public AbpExceptionHandlingLogger(IServiceCollection serviceCollection) + public virtual void Log( + LogLevel logLevel, + EventId eventId, + TState state, + Exception exception, + Func formatter) + { + if (exception == null) { - _serviceCollection = serviceCollection; + return; } - public virtual void Log( - LogLevel logLevel, - EventId eventId, - TState state, - Exception exception, - Func formatter) + if (logLevel != LogLevel.Critical && logLevel != LogLevel.Error) { - if (exception == null) - { - return; - } - - if (logLevel != LogLevel.Critical && logLevel != LogLevel.Error) - { - return; - } - - TryInitialize(); - - if (_userExceptionInformer == null) - { - return; - } - - _userExceptionInformer.Inform(new UserExceptionInformerContext(exception)); + return; } - protected virtual void TryInitialize() - { - var serviceProvider = _serviceCollection.GetServiceProviderOrNull(); - if (serviceProvider == null) - { - return; - } - - _userExceptionInformer = serviceProvider.GetRequiredService(); - } + TryInitialize(); - public virtual bool IsEnabled(LogLevel logLevel) + if (_userExceptionInformer == null) { - return logLevel == LogLevel.Critical || logLevel == LogLevel.Error; + return; } - public virtual IDisposable BeginScope(TState state) + _userExceptionInformer.Inform(new UserExceptionInformerContext(exception)); + } + + protected virtual void TryInitialize() + { + var serviceProvider = _serviceCollection.GetServiceProviderOrNull(); + if (serviceProvider == null) { - return NullDisposable.Instance; + return; } + + _userExceptionInformer = serviceProvider.GetRequiredService(); + } + + public virtual bool IsEnabled(LogLevel logLevel) + { + return logLevel == LogLevel.Critical || logLevel == LogLevel.Error; + } + + public virtual IDisposable BeginScope(TState state) + { + return NullDisposable.Instance; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs index 85b16d08ba..3f895502fa 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/AbpExceptionHandlingLoggerProvider.cs @@ -1,38 +1,37 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling +namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling; + +public class AbpExceptionHandlingLoggerProvider : ILoggerProvider { - public class AbpExceptionHandlingLoggerProvider : ILoggerProvider - { - private AbpExceptionHandlingLogger _logger; - private static readonly object SyncObj = new object(); - private readonly IServiceCollection _serviceCollection; + private AbpExceptionHandlingLogger _logger; + private static readonly object SyncObj = new object(); + private readonly IServiceCollection _serviceCollection; - public AbpExceptionHandlingLoggerProvider(IServiceCollection serviceCollection) - { - _serviceCollection = serviceCollection; - } + public AbpExceptionHandlingLoggerProvider(IServiceCollection serviceCollection) + { + _serviceCollection = serviceCollection; + } - public ILogger CreateLogger(string categoryName) + public ILogger CreateLogger(string categoryName) + { + if (_logger == null) { - if (_logger == null) + lock (SyncObj) { - lock (SyncObj) + if (_logger == null) { - if (_logger == null) - { - _logger = new AbpExceptionHandlingLogger(_serviceCollection); - } + _logger = new AbpExceptionHandlingLogger(_serviceCollection); } } - - return _logger; } - public void Dispose() - { + return _logger; + } + + public void Dispose() + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs index ecbeb16e81..0f0da11bdf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ExceptionHandling/UserExceptionInformer.cs @@ -9,65 +9,64 @@ using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.DependencyInjection; using Volo.Abp.Http; -namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling +namespace Volo.Abp.AspNetCore.Components.Web.ExceptionHandling; + +[Dependency(ReplaceServices = true)] +public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency { - [Dependency(ReplaceServices = true)] - public class UserExceptionInformer : IUserExceptionInformer, IScopedDependency + public ILogger Logger { get; set; } + protected IUiMessageService MessageService { get; } + protected IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; } + + protected AbpExceptionHandlingOptions Options { get; } + + public UserExceptionInformer( + IUiMessageService messageService, + IExceptionToErrorInfoConverter exceptionToErrorInfoConverter, + IOptions options) + { + MessageService = messageService; + ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter; + Options = options.Value; + Logger = NullLogger.Instance; + } + + public void Inform(UserExceptionInformerContext context) { - public ILogger Logger { get; set; } - protected IUiMessageService MessageService { get; } - protected IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; } + //TODO: Create sync versions of the MessageService APIs. - protected AbpExceptionHandlingOptions Options { get; } + var errorInfo = GetErrorInfo(context); - public UserExceptionInformer( - IUiMessageService messageService, - IExceptionToErrorInfoConverter exceptionToErrorInfoConverter, - IOptions options) + if (errorInfo.Details.IsNullOrEmpty()) { - MessageService = messageService; - ExceptionToErrorInfoConverter = exceptionToErrorInfoConverter; - Options = options.Value; - Logger = NullLogger.Instance; + MessageService.Error(errorInfo.Message); } - - public void Inform(UserExceptionInformerContext context) + else { - //TODO: Create sync versions of the MessageService APIs. + MessageService.Error(errorInfo.Details, errorInfo.Message); + } + } - var errorInfo = GetErrorInfo(context); + public async Task InformAsync(UserExceptionInformerContext context) + { + var errorInfo = GetErrorInfo(context); - if (errorInfo.Details.IsNullOrEmpty()) - { - MessageService.Error(errorInfo.Message); - } - else - { - MessageService.Error(errorInfo.Details, errorInfo.Message); - } + if (errorInfo.Details.IsNullOrEmpty()) + { + await MessageService.Error(errorInfo.Message); } - - public async Task InformAsync(UserExceptionInformerContext context) + else { - var errorInfo = GetErrorInfo(context); - - if (errorInfo.Details.IsNullOrEmpty()) - { - await MessageService.Error(errorInfo.Message); - } - else - { - await MessageService.Error(errorInfo.Details, errorInfo.Message); - } + await MessageService.Error(errorInfo.Details, errorInfo.Message); } + } - protected virtual RemoteServiceErrorInfo GetErrorInfo(UserExceptionInformerContext context) + protected virtual RemoteServiceErrorInfo GetErrorInfo(UserExceptionInformerContext context) + { + return ExceptionToErrorInfoConverter.Convert(context.Exception, options => { - return ExceptionToErrorInfoConverter.Convert(context.Exception, options => - { - options.SendExceptionsDetailsToClients = Options.SendExceptionsDetailsToClients; - options.SendStackTraceToClients = Options.SendStackTraceToClients; - }); - } + options.SendExceptionsDetailsToClients = Options.SendExceptionsDetailsToClients; + options.SendStackTraceToClients = Options.SendStackTraceToClients; + }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs index 61bea5c27a..2f800c7257 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityAction.cs @@ -1,20 +1,19 @@ using System; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions +namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; + +public class EntityAction : IEquatable { - public class EntityAction : IEquatable + public string Text { get; set; } + public Func Clicked { get; set; } + public Func ConfirmationMessage { get; set; } + public bool Primary { get; set; } + public object Color { get; set; } + public string Icon { get; set; } + public Func Visible { get; set; } + public bool Equals(EntityAction other) { - public string Text { get; set; } - public Func Clicked { get; set; } - public Func ConfirmationMessage { get; set; } - public bool Primary { get; set; } - public object Color { get; set; } - public string Icon { get; set; } - public Func Visible { get; set; } - public bool Equals(EntityAction other) - { - return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase); - } + return string.Equals(Text, other?.Text, StringComparison.OrdinalIgnoreCase); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs index 36117abb37..0781870b69 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/EntityActions/EntityActionDictionary.cs @@ -1,12 +1,11 @@ using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions +namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; + +public class EntityActionDictionary : Dictionary> { - public class EntityActionDictionary : Dictionary> + public List Get() { - public List Get() - { - return this.GetOrAdd(typeof(T).FullName, () => new List()); - } + return this.GetOrAdd(typeof(T).FullName, () => new List()); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/ILookupApiRequestService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/ILookupApiRequestService.cs index 2351606306..f4b3e26e47 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/ILookupApiRequestService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/ILookupApiRequestService.cs @@ -1,10 +1,9 @@ using System.Threading.Tasks; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Components.Web.Extensibility +namespace Volo.Abp.AspNetCore.Components.Web.Extensibility; + +public interface ILookupApiRequestService { - public interface ILookupApiRequestService - { - Task SendAsync([NotNull]string url); - } -} \ No newline at end of file + Task SendAsync([NotNull] string url); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs index 2121b8a128..9a6a40a17a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs @@ -4,25 +4,24 @@ using System.Collections.Generic; using System.Globalization; using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; -namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns +namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; + +public class TableColumn { - public class TableColumn - { - public string Title { get; set; } - public string Data { get; set; } - [CanBeNull] - public string DisplayFormat { get; set; } - public IFormatProvider DisplayFormatProvider { get; set; } = CultureInfo.CurrentCulture; - [CanBeNull] - public Type Component { get; set; } - public List Actions { get; set; } - [CanBeNull] - public Func ValueConverter { get; set; } - public bool Sortable { get; set; } + public string Title { get; set; } + public string Data { get; set; } + [CanBeNull] + public string DisplayFormat { get; set; } + public IFormatProvider DisplayFormatProvider { get; set; } = CultureInfo.CurrentCulture; + [CanBeNull] + public Type Component { get; set; } + public List Actions { get; set; } + [CanBeNull] + public Func ValueConverter { get; set; } + public bool Sortable { get; set; } - public TableColumn() - { - Actions = new List(); - } + public TableColumn() + { + Actions = new List(); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs index a68ad437d4..7eda70177c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumnDictionary.cs @@ -1,12 +1,11 @@ using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns +namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; + +public class TableColumnDictionary : Dictionary> { - public class TableColumnDictionary : Dictionary> + public List Get() { - public List Get() - { - return this.GetOrAdd(typeof(T).FullName, () => new List()); - } + return this.GetOrAdd(typeof(T).FullName, () => new List()); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IAbpUtilsService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IAbpUtilsService.cs index a149691ba4..732ce11b4b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IAbpUtilsService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IAbpUtilsService.cs @@ -1,21 +1,20 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public interface IAbpUtilsService { - public interface IAbpUtilsService - { - ValueTask AddClassToTagAsync(string tagName, string className); + ValueTask AddClassToTagAsync(string tagName, string className); - ValueTask RemoveClassFromTagAsync(string tagName, string className); + ValueTask RemoveClassFromTagAsync(string tagName, string className); - ValueTask HasClassOnTagAsync(string tagName, string className); + ValueTask HasClassOnTagAsync(string tagName, string className); - ValueTask ReplaceLinkHrefByIdAsync(string linkId, string hrefValue); + ValueTask ReplaceLinkHrefByIdAsync(string linkId, string hrefValue); - ValueTask ToggleFullscreenAsync(); + ValueTask ToggleFullscreenAsync(); - ValueTask RequestFullscreenAsync(); + ValueTask RequestFullscreenAsync(); - ValueTask ExitFullscreenAsync(); - } + ValueTask ExitFullscreenAsync(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs index 8f397bf554..afb124644e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/ICookieService.cs @@ -1,11 +1,10 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public interface ICookieService { - public interface ICookieService - { - public ValueTask SetAsync(string key, string value, CookieOptions options = null); - public ValueTask GetAsync(string key); - public ValueTask DeleteAsync(string key, string path = null); - } -} \ No newline at end of file + public ValueTask SetAsync(string key, string value, CookieOptions options = null); + public ValueTask GetAsync(string key); + public ValueTask DeleteAsync(string key, string path = null); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs index fffec2f606..f5266a9f18 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/IServerUrlProvider.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Web +namespace Volo.Abp.AspNetCore.Components.Web; + +public interface IServerUrlProvider { - public interface IServerUrlProvider - { - Task GetBaseUrlAsync(string remoteServiceName = null); - } -} \ No newline at end of file + Task GetBaseUrlAsync(string remoteServiceName = null); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs index cc82625b4c..647be65b41 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Messages/SimpleUiMessageService.cs @@ -4,40 +4,39 @@ using Microsoft.JSInterop; using Volo.Abp.AspNetCore.Components.Messages; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Messages +namespace Volo.Abp.AspNetCore.Components.Web.Messages; + +public class SimpleUiMessageService : IUiMessageService, ITransientDependency { - public class SimpleUiMessageService : IUiMessageService, ITransientDependency + protected IJSRuntime JsRuntime { get; } + + public SimpleUiMessageService(IJSRuntime jsRuntime) + { + JsRuntime = jsRuntime; + } + + public async Task Info(string message, string title = null, Action options = null) + { + await JsRuntime.InvokeVoidAsync("alert", message); + } + + public async Task Success(string message, string title = null, Action options = null) + { + await JsRuntime.InvokeVoidAsync("alert", message); + } + + public async Task Warn(string message, string title = null, Action options = null) + { + await JsRuntime.InvokeVoidAsync("alert", message); + } + + public async Task Error(string message, string title = null, Action options = null) + { + await JsRuntime.InvokeVoidAsync("alert", message); + } + + public async Task Confirm(string message, string title = null, Action options = null) { - protected IJSRuntime JsRuntime { get; } - - public SimpleUiMessageService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } - - public async Task Info(string message, string title = null, Action options = null) - { - await JsRuntime.InvokeVoidAsync("alert", message); - } - - public async Task Success(string message, string title = null, Action options = null) - { - await JsRuntime.InvokeVoidAsync("alert", message); - } - - public async Task Warn(string message, string title = null, Action options = null) - { - await JsRuntime.InvokeVoidAsync("alert", message); - } - - public async Task Error(string message, string title = null, Action options = null) - { - await JsRuntime.InvokeVoidAsync("alert", message); - } - - public async Task Confirm(string message, string title = null, Action options = null) - { - return await JsRuntime.InvokeAsync("confirm", message); - } + return await JsRuntime.InvokeAsync("confirm", message); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs index 787bf5cb6e..bb053eac21 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Security/AbpComponentsClaimsCache.cs @@ -5,39 +5,38 @@ using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Web.Security +namespace Volo.Abp.AspNetCore.Components.Web.Security; + +[ExposeServices( + typeof(AbpComponentsClaimsCache), + typeof(IAsyncInitialize) +)] +public class AbpComponentsClaimsCache : IScopedDependency, IAsyncInitialize { - [ExposeServices( - typeof(AbpComponentsClaimsCache), - typeof(IAsyncInitialize) - )] - public class AbpComponentsClaimsCache : IScopedDependency, IAsyncInitialize - { - public ClaimsPrincipal Principal { get; private set; } + public ClaimsPrincipal Principal { get; private set; } - [CanBeNull] - private readonly AuthenticationStateProvider _authenticationStateProvider; + [CanBeNull] + private readonly AuthenticationStateProvider _authenticationStateProvider; - public AbpComponentsClaimsCache( - IClientScopeServiceProviderAccessor serviceProviderAccessor) + public AbpComponentsClaimsCache( + IClientScopeServiceProviderAccessor serviceProviderAccessor) + { + _authenticationStateProvider = serviceProviderAccessor.ServiceProvider.GetService(); + if (_authenticationStateProvider != null) { - _authenticationStateProvider = serviceProviderAccessor.ServiceProvider.GetService(); - if (_authenticationStateProvider != null) + _authenticationStateProvider.AuthenticationStateChanged += async (task) => { - _authenticationStateProvider.AuthenticationStateChanged += async (task) => - { - Principal = (await task).User; - }; - } + Principal = (await task).User; + }; } + } - public virtual async Task InitializeAsync() + public virtual async Task InitializeAsync() + { + if (_authenticationStateProvider != null) { - if (_authenticationStateProvider != null) - { - var authenticationState = await _authenticationStateProvider.GetAuthenticationStateAsync(); - Principal = authenticationState.User; - } + var authenticationState = await _authenticationStateProvider.GetAuthenticationStateAsync(); + Principal = authenticationState.User; } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/AbpAspNetCoreComponentsWebAssemblyThemingModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/AbpAspNetCoreComponentsWebAssemblyThemingModule.cs index a19df06bc7..38eff974b8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/AbpAspNetCoreComponentsWebAssemblyThemingModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/AbpAspNetCoreComponentsWebAssemblyThemingModule.cs @@ -1,14 +1,13 @@ using Volo.Abp.AspNetCore.Components.Web.Theming; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming; + +[DependsOn( + typeof(AbpAspNetCoreComponentsWebThemingModule), + typeof(AbpAspNetCoreComponentsWebAssemblyModule) +)] +public class AbpAspNetCoreComponentsWebAssemblyThemingModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreComponentsWebThemingModule), - typeof(AbpAspNetCoreComponentsWebAssemblyModule) - )] - public class AbpAspNetCoreComponentsWebAssemblyThemingModule : AbpModule - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/ComponentsComponentsBundleContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/ComponentsComponentsBundleContributor.cs index 69933bd95f..61f42e8222 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/ComponentsComponentsBundleContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/ComponentsComponentsBundleContributor.cs @@ -1,31 +1,30 @@ using Volo.Abp.Bundling; -namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Theming; + +public class ComponentsComponentsBundleContributor : IBundleContributor { - public class ComponentsComponentsBundleContributor : IBundleContributor + public void AddScripts(BundleContext context) { - public void AddScripts(BundleContext context) - { - context.Add("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"); - context.Add("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); - context.Add("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js"); - } + context.Add("_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"); + context.Add("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/abp.js"); + context.Add("_content/Volo.Abp.AspNetCore.Components.Web/libs/abp/js/lang-utils.js"); + } - public void AddStyles(BundleContext context) + public void AddStyles(BundleContext context) + { + context.BundleDefinitions.Insert(0, new BundleDefinition + { + Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.min.css" + }); + context.BundleDefinitions.Insert(1, new BundleDefinition { - context.BundleDefinitions.Insert(0, new BundleDefinition - { - Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.min.css" - }); - context.BundleDefinitions.Insert(1, new BundleDefinition - { - Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/fontawesome/css/all.css" - }); + Source = "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/fontawesome/css/all.css" + }); - context.Add("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/flag-icon/css/flag-icon.css"); - context.Add("_content/Blazorise/blazorise.css"); - context.Add("_content/Blazorise.Bootstrap5/blazorise.bootstrap5.css"); - context.Add("_content/Blazorise.Snackbar/blazorise.snackbar.css"); - } + context.Add("_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/flag-icon/css/flag-icon.css"); + context.Add("_content/Blazorise/blazorise.css"); + context.Add("_content/Blazorise.Bootstrap5/blazorise.bootstrap5.css"); + context.Add("_content/Blazorise.Snackbar/blazorise.snackbar.css"); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs index f05feacae8..cb104533cb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs @@ -13,74 +13,73 @@ using Volo.Abp.AspNetCore.Mvc.Client; using Volo.Abp.DependencyInjection; using Volo.Abp.Modularity; -namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting +namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting; + +public static class AbpWebAssemblyHostBuilderExtensions { - public static class AbpWebAssemblyHostBuilderExtensions + public static IAbpApplicationWithExternalServiceProvider AddApplication( + [NotNull] this WebAssemblyHostBuilder builder, + Action options) + where TStartupModule : IAbpModule { - public static IAbpApplicationWithExternalServiceProvider AddApplication( - [NotNull] this WebAssemblyHostBuilder builder, - Action options) - where TStartupModule : IAbpModule - { - Check.NotNull(builder, nameof(builder)); + Check.NotNull(builder, nameof(builder)); - // Related this commit(https://github.com/dotnet/aspnetcore/commit/b99d805bc037fcac56afb79abeb7d5a43141c85e) - // Microsoft.AspNetCore.Blazor.BuildTools has been removed in net 5.0. - // This call may be removed when we find a suitable solution. - // System.Runtime.CompilerServices.AsyncStateMachineAttribute - Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(); + // Related this commit(https://github.com/dotnet/aspnetcore/commit/b99d805bc037fcac56afb79abeb7d5a43141c85e) + // Microsoft.AspNetCore.Blazor.BuildTools has been removed in net 5.0. + // This call may be removed when we find a suitable solution. + // System.Runtime.CompilerServices.AsyncStateMachineAttribute + Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(); - builder.Services.AddSingleton(builder.Configuration); - builder.Services.AddSingleton(builder); + builder.Services.AddSingleton(builder.Configuration); + builder.Services.AddSingleton(builder); - var application = builder.Services.AddApplication(opts => - { - options?.Invoke(new AbpWebAssemblyApplicationCreationOptions(builder, opts)); - }); + var application = builder.Services.AddApplication(opts => + { + options?.Invoke(new AbpWebAssemblyApplicationCreationOptions(builder, opts)); + }); - return application; - } + return application; + } - public static async Task InitializeAsync( - [NotNull] this IAbpApplicationWithExternalServiceProvider application, - [NotNull] IServiceProvider serviceProvider) - { - Check.NotNull(application, nameof(application)); - Check.NotNull(serviceProvider, nameof(serviceProvider)); + public static async Task InitializeAsync( + [NotNull] this IAbpApplicationWithExternalServiceProvider application, + [NotNull] IServiceProvider serviceProvider) + { + Check.NotNull(application, nameof(application)); + Check.NotNull(serviceProvider, nameof(serviceProvider)); - ((ComponentsClientScopeServiceProviderAccessor) serviceProvider - .GetRequiredService()).ServiceProvider = serviceProvider; + ((ComponentsClientScopeServiceProviderAccessor)serviceProvider + .GetRequiredService()).ServiceProvider = serviceProvider; - application.Initialize(serviceProvider); - await InitializeModulesAsync(serviceProvider); - await SetCurrentLanguageAsync(serviceProvider); - } + application.Initialize(serviceProvider); + await InitializeModulesAsync(serviceProvider); + await SetCurrentLanguageAsync(serviceProvider); + } - private static async Task InitializeModulesAsync(IServiceProvider serviceProvider) + private static async Task InitializeModulesAsync(IServiceProvider serviceProvider) + { + foreach (var service in serviceProvider.GetServices()) { - foreach (var service in serviceProvider.GetServices()) - { - await service.InitializeAsync(); - } + await service.InitializeAsync(); } + } - private static async Task SetCurrentLanguageAsync(IServiceProvider serviceProvider) + private static async Task SetCurrentLanguageAsync(IServiceProvider serviceProvider) + { + var configurationClient = serviceProvider.GetRequiredService(); + var utilsService = serviceProvider.GetRequiredService(); + var configuration = await configurationClient.GetAsync(); + var cultureName = configuration.Localization?.CurrentCulture?.CultureName; + if (!cultureName.IsNullOrEmpty()) { - var configurationClient = serviceProvider.GetRequiredService(); - var utilsService = serviceProvider.GetRequiredService(); - var configuration = await configurationClient.GetAsync(); - var cultureName = configuration.Localization?.CurrentCulture?.CultureName; - if (!cultureName.IsNullOrEmpty()) - { - var culture = new CultureInfo(cultureName); - CultureInfo.DefaultThreadCurrentCulture = culture; - CultureInfo.DefaultThreadCurrentUICulture = culture; - } + var culture = new CultureInfo(cultureName); + CultureInfo.DefaultThreadCurrentCulture = culture; + CultureInfo.DefaultThreadCurrentUICulture = culture; + } - if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft) - { - await utilsService.AddClassToTagAsync("body", "rtl"); - } + if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft) + { + await utilsService.AddClassToTagAsync("body", "rtl"); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/AbpWebAssemblyServiceCollectionExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/AbpWebAssemblyServiceCollectionExtensions.cs index 2f541265d1..bbcf1d5a83 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/AbpWebAssemblyServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/Extensions/DependencyInjection/AbpWebAssemblyServiceCollectionExtensions.cs @@ -2,16 +2,15 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Volo.Abp; -namespace Microsoft.Extensions.DependencyInjection +namespace Microsoft.Extensions.DependencyInjection; + +public static class AbpWebAssemblyServiceCollectionExtensions { - public static class AbpWebAssemblyServiceCollectionExtensions + public static WebAssemblyHostBuilder GetHostBuilder( + [NotNull] this IServiceCollection services) { - public static WebAssemblyHostBuilder GetHostBuilder( - [NotNull] this IServiceCollection services) - { - Check.NotNull(services, nameof(services)); + Check.NotNull(services, nameof(services)); - return services.GetSingletonInstance(); - } + return services.GetSingletonInstance(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs index 170bd9c327..56dd8106a3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs @@ -7,31 +7,30 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.UI; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +[DependsOn( + typeof(AbpAspNetCoreMvcClientCommonModule), + typeof(AbpUiModule), + typeof(AbpAspNetCoreComponentsWebModule) + )] +public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreMvcClientCommonModule), - typeof(AbpUiModule), - typeof(AbpAspNetCoreComponentsWebModule) - )] - public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(options => { - PreConfigure(options => + options.ProxyClientBuildActions.Add((_, builder) => { - options.ProxyClientBuildActions.Add((_, builder) => - { - builder.AddHttpMessageHandler(); - }); + builder.AddHttpMessageHandler(); }); - } + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services - .GetHostBuilder().Logging - .AddProvider(new AbpExceptionHandlingLoggerProvider(context.Services)); - } + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services + .GetHostBuilder().Logging + .AddProvider(new AbpExceptionHandlingLoggerProvider(context.Services)); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyApplicationCreationOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyApplicationCreationOptions.cs index 54fdf7edb4..6ffe5fe17e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyApplicationCreationOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpWebAssemblyApplicationCreationOptions.cs @@ -1,19 +1,18 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +public class AbpWebAssemblyApplicationCreationOptions { - public class AbpWebAssemblyApplicationCreationOptions - { - public WebAssemblyHostBuilder HostBuilder { get; } + public WebAssemblyHostBuilder HostBuilder { get; } - public AbpApplicationCreationOptions ApplicationCreationOptions { get; } + public AbpApplicationCreationOptions ApplicationCreationOptions { get; } - public AbpWebAssemblyApplicationCreationOptions( - WebAssemblyHostBuilder hostBuilder, - AbpApplicationCreationOptions applicationCreationOptions) - { - HostBuilder = hostBuilder; - ApplicationCreationOptions = applicationCreationOptions; - } + public AbpWebAssemblyApplicationCreationOptions( + WebAssemblyHostBuilder hostBuilder, + AbpApplicationCreationOptions applicationCreationOptions) + { + HostBuilder = hostBuilder; + ApplicationCreationOptions = applicationCreationOptions; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs index ffbcf4e973..b55d8d8a56 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/ApplicationConfigurationCache.cs @@ -1,20 +1,19 @@ using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +public class ApplicationConfigurationCache : ISingletonDependency { - public class ApplicationConfigurationCache : ISingletonDependency - { - protected ApplicationConfigurationDto Configuration { get; set; } + protected ApplicationConfigurationDto Configuration { get; set; } - public virtual ApplicationConfigurationDto Get() - { - return Configuration; - } + public virtual ApplicationConfigurationDto Get() + { + return Configuration; + } - public void Set(ApplicationConfigurationDto configuration) - { - Configuration = configuration; - } + public void Set(ApplicationConfigurationDto configuration) + { + Configuration = configuration; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Extensibility/WebAssemblyLookupApiRequestService.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Extensibility/WebAssemblyLookupApiRequestService.cs index 594aa32bae..b8eadacdd6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Extensibility/WebAssemblyLookupApiRequestService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/Extensibility/WebAssemblyLookupApiRequestService.cs @@ -11,57 +11,56 @@ using Volo.Abp.Http.Client; using Microsoft.Extensions.Options; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.Components.WebAssembly.Extensibility +namespace Volo.Abp.AspNetCore.Components.WebAssembly.Extensibility; + +public class WebAssemblyLookupApiRequestService : ILookupApiRequestService, ITransientDependency { - public class WebAssemblyLookupApiRequestService : ILookupApiRequestService, ITransientDependency + public IHttpClientFactory HttpClientFactory { get; } + public IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; } + public IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; } + public ICurrentTenant CurrentTenant { get; } + + public WebAssemblyLookupApiRequestService(IHttpClientFactory httpClientFactory, + IRemoteServiceHttpClientAuthenticator httpClientAuthenticator, + ICurrentTenant currentTenant, + IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + { + HttpClientFactory = httpClientFactory; + HttpClientAuthenticator = httpClientAuthenticator; + CurrentTenant = currentTenant; + RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; + } + + public async Task SendAsync(string url) { - public IHttpClientFactory HttpClientFactory { get; } - public IRemoteServiceHttpClientAuthenticator HttpClientAuthenticator { get; } - public IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; } - public ICurrentTenant CurrentTenant { get; } + var client = HttpClientFactory.CreateClient(); + var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); + AddHeaders(requestMessage); - public WebAssemblyLookupApiRequestService(IHttpClientFactory httpClientFactory, - IRemoteServiceHttpClientAuthenticator httpClientAuthenticator, - ICurrentTenant currentTenant, - IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + var uri = new Uri(url, UriKind.RelativeOrAbsolute); + if (!uri.IsAbsoluteUri) { - HttpClientFactory = httpClientFactory; - HttpClientAuthenticator = httpClientAuthenticator; - CurrentTenant = currentTenant; - RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; + var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); + client.BaseAddress = new Uri(remoteServiceConfig.BaseUrl); + await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration(remoteServiceConfig.BaseUrl), string.Empty)); } - public async Task SendAsync(string url) - { - var client = HttpClientFactory.CreateClient(); - var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); - AddHeaders(requestMessage); + var response = await client.SendAsync(requestMessage); - var uri = new Uri(url, UriKind.RelativeOrAbsolute); - if (!uri.IsAbsoluteUri) - { - var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); - client.BaseAddress = new Uri(remoteServiceConfig.BaseUrl); - await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration(remoteServiceConfig.BaseUrl), string.Empty)); - } + return await response.Content.ReadAsStringAsync(); + } - var response = await client.SendAsync(requestMessage); - - return await response.Content.ReadAsStringAsync(); - } - - protected virtual void AddHeaders(HttpRequestMessage requestMessage) + protected virtual void AddHeaders(HttpRequestMessage requestMessage) + { + if (CurrentTenant.Id.HasValue) { - if (CurrentTenant.Id.HasValue) - { - requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString()); - } + requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString()); + } - var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name; - if (!currentCulture.IsNullOrEmpty()) - { - requestMessage.Headers.AcceptLanguage.Add(new (currentCulture)); - } + var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name; + if (!currentCulture.IsNullOrEmpty()) + { + requestMessage.Headers.AcceptLanguage.Add(new(currentCulture)); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs index c7b659a859..4dbd188a47 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs @@ -5,63 +5,62 @@ using Volo.Abp.AspNetCore.Mvc.Client; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +[ExposeServices( + typeof(WebAssemblyCachedApplicationConfigurationClient), + typeof(ICachedApplicationConfigurationClient), + typeof(IAsyncInitialize) + )] +public class WebAssemblyCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency { - [ExposeServices( - typeof(WebAssemblyCachedApplicationConfigurationClient), - typeof(ICachedApplicationConfigurationClient), - typeof(IAsyncInitialize) - )] - public class WebAssemblyCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency - { - protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } + protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } - protected ApplicationConfigurationCache Cache { get; } + protected ApplicationConfigurationCache Cache { get; } - protected ICurrentTenantAccessor CurrentTenantAccessor { get; } + protected ICurrentTenantAccessor CurrentTenantAccessor { get; } - public WebAssemblyCachedApplicationConfigurationClient( - AbpApplicationConfigurationClientProxy applicationConfigurationAppService, - ApplicationConfigurationCache cache, - ICurrentTenantAccessor currentTenantAccessor) - { - ApplicationConfigurationAppService = applicationConfigurationAppService; - Cache = cache; - CurrentTenantAccessor = currentTenantAccessor; - } + public WebAssemblyCachedApplicationConfigurationClient( + AbpApplicationConfigurationClientProxy applicationConfigurationAppService, + ApplicationConfigurationCache cache, + ICurrentTenantAccessor currentTenantAccessor) + { + ApplicationConfigurationAppService = applicationConfigurationAppService; + Cache = cache; + CurrentTenantAccessor = currentTenantAccessor; + } - public virtual async Task InitializeAsync() - { - var configurationDto = await ApplicationConfigurationAppService.GetAsync(); + public virtual async Task InitializeAsync() + { + var configurationDto = await ApplicationConfigurationAppService.GetAsync(); - Cache.Set(configurationDto); + Cache.Set(configurationDto); - CurrentTenantAccessor.Current = new BasicTenantInfo( - configurationDto.CurrentTenant.Id, - configurationDto.CurrentTenant.Name - ); - } + CurrentTenantAccessor.Current = new BasicTenantInfo( + configurationDto.CurrentTenant.Id, + configurationDto.CurrentTenant.Name + ); + } - public virtual Task GetAsync() - { - return Task.FromResult(GetConfigurationByChecking()); - } + public virtual Task GetAsync() + { + return Task.FromResult(GetConfigurationByChecking()); + } - public virtual ApplicationConfigurationDto Get() - { - return GetConfigurationByChecking(); - } + public virtual ApplicationConfigurationDto Get() + { + return GetConfigurationByChecking(); + } - private ApplicationConfigurationDto GetConfigurationByChecking() + private ApplicationConfigurationDto GetConfigurationByChecking() + { + var configuration = Cache.Get(); + if (configuration == null) { - var configuration = Cache.Get(); - if (configuration == null) - { - throw new AbpException( - $"{nameof(WebAssemblyCachedApplicationConfigurationClient)} should be initialized before using it."); - } - - return configuration; + throw new AbpException( + $"{nameof(WebAssemblyCachedApplicationConfigurationClient)} should be initialized before using it."); } + + return configuration; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentPrincipalAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentPrincipalAccessor.cs index 36438871c1..9f1eb5d0b9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentPrincipalAccessor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentPrincipalAccessor.cs @@ -4,21 +4,20 @@ using Volo.Abp.AspNetCore.Components.Web.Security; using Volo.Abp.DependencyInjection; using Volo.Abp.Security.Claims; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +public class WebAssemblyCurrentPrincipalAccessor : CurrentPrincipalAccessorBase, ITransientDependency { - public class WebAssemblyCurrentPrincipalAccessor : CurrentPrincipalAccessorBase, ITransientDependency - { - protected AbpComponentsClaimsCache ClaimsCache { get; } + protected AbpComponentsClaimsCache ClaimsCache { get; } - public WebAssemblyCurrentPrincipalAccessor( - IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) - { - ClaimsCache = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); - } + public WebAssemblyCurrentPrincipalAccessor( + IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) + { + ClaimsCache = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); + } - protected override ClaimsPrincipal GetClaimsPrincipal() - { - return ClaimsCache.Principal; - } + protected override ClaimsPrincipal GetClaimsPrincipal() + { + return ClaimsCache.Principal; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs index eb0ee781ad..e24746f85a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCurrentTenantAccessor.cs @@ -1,11 +1,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +[Dependency(ReplaceServices = true)] +public class WebAssemblyCurrentTenantAccessor : ICurrentTenantAccessor, ISingletonDependency { - [Dependency(ReplaceServices = true)] - public class WebAssemblyCurrentTenantAccessor : ICurrentTenantAccessor, ISingletonDependency - { - public BasicTenantInfo Current { get; set; } - } + public BasicTenantInfo Current { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs index 477dba5418..2fb133a10d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyServerUrlProvider.cs @@ -4,26 +4,25 @@ using Volo.Abp.AspNetCore.Components.Web; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client; -namespace Volo.Abp.AspNetCore.Components.WebAssembly +namespace Volo.Abp.AspNetCore.Components.WebAssembly; + +[Dependency(ReplaceServices = true)] +public class WebAssemblyServerUrlProvider : IServerUrlProvider, ITransientDependency { - [Dependency(ReplaceServices = true)] - public class WebAssemblyServerUrlProvider : IServerUrlProvider, ITransientDependency + protected IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; } + + public WebAssemblyServerUrlProvider( + IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + { + RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; + } + + public async Task GetBaseUrlAsync(string remoteServiceName = null) { - protected IRemoteServiceConfigurationProvider RemoteServiceConfigurationProvider { get; } + var remoteServiceConfiguration = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync( + remoteServiceName ?? RemoteServiceConfigurationDictionary.DefaultName + ); - public WebAssemblyServerUrlProvider( - IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) - { - RemoteServiceConfigurationProvider = remoteServiceConfigurationProvider; - } - - public async Task GetBaseUrlAsync(string remoteServiceName = null) - { - var remoteServiceConfiguration = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync( - remoteServiceName ?? RemoteServiceConfigurationDictionary.DefaultName - ); - - return remoteServiceConfiguration.BaseUrl.EnsureEndsWith('/'); - } + return remoteServiceConfiguration.BaseUrl.EnsureEndsWith('/'); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpAspNetCoreComponentsModule.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpAspNetCoreComponentsModule.cs index 08c7ed8e9f..677f9d8cca 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpAspNetCoreComponentsModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpAspNetCoreComponentsModule.cs @@ -7,19 +7,18 @@ using Volo.Abp.Modularity; using Volo.Abp.ObjectMapping; using Volo.Abp.Security; -namespace Volo.Abp.AspNetCore.Components +namespace Volo.Abp.AspNetCore.Components; + +[DependsOn( + typeof(AbpObjectMappingModule), + typeof(AbpSecurityModule), + typeof(AbpLocalizationModule) + )] +public class AbpAspNetCoreComponentsModule : AbpModule { - [DependsOn( - typeof(AbpObjectMappingModule), - typeof(AbpSecurityModule), - typeof(AbpLocalizationModule) - )] - public class AbpAspNetCoreComponentsModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - DynamicProxyIgnoreTypes.Add(); - context.Services.AddConventionalRegistrar(new AbpWebAssemblyConventionalRegistrar()); - } + DynamicProxyIgnoreTypes.Add(); + context.Services.AddConventionalRegistrar(new AbpWebAssemblyConventionalRegistrar()); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs index 163b2217fa..b9c97b30b4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs @@ -14,164 +14,157 @@ using Volo.Abp.Localization; using Volo.Abp.ObjectMapping; using Volo.Abp.Users; -namespace Volo.Abp.AspNetCore.Components +namespace Volo.Abp.AspNetCore.Components; + +public abstract class AbpComponentBase : OwningComponentBase { - public abstract class AbpComponentBase : OwningComponentBase - { - protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); - private IStringLocalizerFactory _stringLocalizerFactory; + protected IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); + private IStringLocalizerFactory _stringLocalizerFactory; - protected IStringLocalizer L - { - get + protected IStringLocalizer L { + get { + if (_localizer == null) { - if (_localizer == null) - { - _localizer = CreateLocalizer(); - } - - return _localizer; + _localizer = CreateLocalizer(); } - } - private IStringLocalizer _localizer; - protected Type LocalizationResource - { - get => _localizationResource; - set - { - _localizationResource = value; - _localizer = null; - } + return _localizer; } - private Type _localizationResource = typeof(DefaultResource); + } + private IStringLocalizer _localizer; - protected ILogger Logger => _lazyLogger.Value; - private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true); + protected Type LocalizationResource { + get => _localizationResource; + set { + _localizationResource = value; + _localizer = null; + } + } + private Type _localizationResource = typeof(DefaultResource); - protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory); - private ILoggerFactory _loggerFactory; + protected ILogger Logger => _lazyLogger.Value; + private Lazy _lazyLogger => new Lazy(() => LoggerFactory?.CreateLogger(GetType().FullName) ?? NullLogger.Instance, true); - protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService); - private IAuthorizationService _authorizationService; + protected ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory); + private ILoggerFactory _loggerFactory; - protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser); - private ICurrentUser _currentUser; - - protected IUiMessageService Message => LazyGetNonScopedRequiredService(ref _message); - private IUiMessageService _message; + protected IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService); + private IAuthorizationService _authorizationService; - protected IUiNotificationService Notify => LazyGetNonScopedRequiredService(ref _notify); - private IUiNotificationService _notify; - - protected IUserExceptionInformer UserExceptionInformer => LazyGetNonScopedRequiredService(ref _userExceptionInformer); - private IUserExceptionInformer _userExceptionInformer; + protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser); + private ICurrentUser _currentUser; - protected IAlertManager AlertManager => LazyGetNonScopedRequiredService(ref _alertManager); - private IAlertManager _alertManager; + protected IUiMessageService Message => LazyGetNonScopedRequiredService(ref _message); + private IUiMessageService _message; - protected AlertList Alerts => AlertManager.Alerts; + protected IUiNotificationService Notify => LazyGetNonScopedRequiredService(ref _notify); + private IUiNotificationService _notify; - protected IObjectMapper ObjectMapper - { - get - { - if (_objectMapper != null) - { - return _objectMapper; - } - - if (ObjectMapperContext == null) - { - return LazyGetRequiredService(ref _objectMapper); - } - - return LazyGetRequiredService( - typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext), - ref _objectMapper - ); - } - } + protected IUserExceptionInformer UserExceptionInformer => LazyGetNonScopedRequiredService(ref _userExceptionInformer); + private IUserExceptionInformer _userExceptionInformer; - private IObjectMapper _objectMapper; + protected IAlertManager AlertManager => LazyGetNonScopedRequiredService(ref _alertManager); + private IAlertManager _alertManager; - protected Type ObjectMapperContext { get; set; } + protected AlertList Alerts => AlertManager.Alerts; - protected TService LazyGetRequiredService(ref TService reference) => LazyGetRequiredService(typeof(TService), ref reference); - - protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference) - { - if (reference == null) + protected IObjectMapper ObjectMapper { + get { + if (_objectMapper != null) { - reference = (TRef)ScopedServices.GetRequiredService(serviceType); + return _objectMapper; } - return reference; - } - - protected TService LazyGetService(ref TService reference) => LazyGetService(typeof(TService), ref reference); - - protected TRef LazyGetService(Type serviceType, ref TRef reference) - { - if (reference == null) + if (ObjectMapperContext == null) { - reference = (TRef)ScopedServices.GetService(serviceType); + return LazyGetRequiredService(ref _objectMapper); } - return reference; + return LazyGetRequiredService( + typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext), + ref _objectMapper + ); } + } - protected TService LazyGetNonScopedRequiredService(ref TService reference) => LazyGetNonScopedRequiredService(typeof(TService), ref reference); + private IObjectMapper _objectMapper; - protected TRef LazyGetNonScopedRequiredService(Type serviceType, ref TRef reference) - { - if (reference == null) - { - reference = (TRef)NonScopedServices.GetRequiredService(serviceType); - } + protected Type ObjectMapperContext { get; set; } - return reference; + protected TService LazyGetRequiredService(ref TService reference) => LazyGetRequiredService(typeof(TService), ref reference); + + protected TRef LazyGetRequiredService(Type serviceType, ref TRef reference) + { + if (reference == null) + { + reference = (TRef)ScopedServices.GetRequiredService(serviceType); } - - protected TService LazyGetNonScopedService(ref TService reference) => LazyGetNonScopedService(typeof(TService), ref reference); - protected TRef LazyGetNonScopedService(Type serviceType, ref TRef reference) + return reference; + } + + protected TService LazyGetService(ref TService reference) => LazyGetService(typeof(TService), ref reference); + + protected TRef LazyGetService(Type serviceType, ref TRef reference) + { + if (reference == null) { - if (reference == null) - { - reference = (TRef)NonScopedServices.GetService(serviceType); - } + reference = (TRef)ScopedServices.GetService(serviceType); + } + + return reference; + } + + protected TService LazyGetNonScopedRequiredService(ref TService reference) => LazyGetNonScopedRequiredService(typeof(TService), ref reference); - return reference; + protected TRef LazyGetNonScopedRequiredService(Type serviceType, ref TRef reference) + { + if (reference == null) + { + reference = (TRef)NonScopedServices.GetRequiredService(serviceType); } - [Inject] - protected IServiceProvider NonScopedServices { get; set; } + return reference; + } + + protected TService LazyGetNonScopedService(ref TService reference) => LazyGetNonScopedService(typeof(TService), ref reference); - protected virtual IStringLocalizer CreateLocalizer() + protected TRef LazyGetNonScopedService(Type serviceType, ref TRef reference) + { + if (reference == null) { - if (LocalizationResource != null) - { - return StringLocalizerFactory.Create(LocalizationResource); - } + reference = (TRef)NonScopedServices.GetService(serviceType); + } - var localizer = StringLocalizerFactory.CreateDefaultOrNull(); - if (localizer == null) - { - throw new AbpException($"Set {nameof(LocalizationResource)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); - } + return reference; + } - return localizer; + [Inject] + protected IServiceProvider NonScopedServices { get; set; } + + protected virtual IStringLocalizer CreateLocalizer() + { + if (LocalizationResource != null) + { + return StringLocalizerFactory.Create(LocalizationResource); } - - protected async Task HandleErrorAsync(Exception exception) + + var localizer = StringLocalizerFactory.CreateDefaultOrNull(); + if (localizer == null) { - Logger.LogException(exception); - await InvokeAsync(async () => - { - await UserExceptionInformer.InformAsync(new UserExceptionInformerContext(exception)); - StateHasChanged(); - }); + throw new AbpException($"Set {nameof(LocalizationResource)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!"); } + + return localizer; + } + + protected async Task HandleErrorAsync(Exception exception) + { + Logger.LogException(exception); + await InvokeAsync(async () => + { + await UserExceptionInformer.InformAsync(new UserExceptionInformerContext(exception)); + StateHasChanged(); + }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs index 866095a9b9..6ea0031352 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertList.cs @@ -5,33 +5,32 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Alerts +namespace Volo.Abp.AspNetCore.Components.Alerts; + +public class AlertList : ObservableCollection { - public class AlertList : ObservableCollection + public void Add(AlertType type, string text, string title = null, bool dismissible = true) { - public void Add(AlertType type, string text, string title = null, bool dismissible = true) - { - Add(new AlertMessage(type, text, title, dismissible)); - } + Add(new AlertMessage(type, text, title, dismissible)); + } - public void Info(string text, string title = null, bool dismissible = true) - { - Add(new AlertMessage(AlertType.Info, text, title, dismissible)); - } + public void Info(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Info, text, title, dismissible)); + } - public void Warning(string text, string title = null, bool dismissible = true) - { - Add(new AlertMessage(AlertType.Warning, text, title, dismissible)); - } + public void Warning(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Warning, text, title, dismissible)); + } - public void Danger(string text, string title = null, bool dismissible = true) - { - Add(new AlertMessage(AlertType.Danger, text, title, dismissible)); - } + public void Danger(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Danger, text, title, dismissible)); + } - public void Success(string text, string title = null, bool dismissible = true) - { - Add(new AlertMessage(AlertType.Success, text, title, dismissible)); - } + public void Success(string text, string title = null, bool dismissible = true) + { + Add(new AlertMessage(AlertType.Success, text, title, dismissible)); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs index 1b6a7dd21d..7a38e422a0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertMessage.cs @@ -1,30 +1,28 @@ using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Components.Alerts +namespace Volo.Abp.AspNetCore.Components.Alerts; + +public class AlertMessage { - public class AlertMessage - { - [NotNull] - public string Text - { - get => _text; - set => _text = Check.NotNullOrWhiteSpace(value, nameof(value)); - } - private string _text; + [NotNull] + public string Text { + get => _text; + set => _text = Check.NotNullOrWhiteSpace(value, nameof(value)); + } + private string _text; - public AlertType Type { get; set; } + public AlertType Type { get; set; } - [CanBeNull] - public string Title { get; set; } + [CanBeNull] + public string Title { get; set; } - public bool Dismissible { get; set; } + public bool Dismissible { get; set; } - public AlertMessage(AlertType type, [NotNull] string text, string title = null, bool dismissible = true) - { - Type = type; - Text = Check.NotNullOrWhiteSpace(text, nameof(text)); - Title = title; - Dismissible = dismissible; - } + public AlertMessage(AlertType type, [NotNull] string text, string title = null, bool dismissible = true) + { + Type = type; + Text = Check.NotNullOrWhiteSpace(text, nameof(text)); + Title = title; + Dismissible = dismissible; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertType.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertType.cs index 4703158b12..6149f9bb24 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/AlertType.cs @@ -4,18 +4,17 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Alerts +namespace Volo.Abp.AspNetCore.Components.Alerts; + +public enum AlertType { - public enum AlertType - { - Default, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark - } + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/IAlertManager.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/IAlertManager.cs index 542b576b01..0e6344baaf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/IAlertManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Alerts/IAlertManager.cs @@ -4,10 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Alerts +namespace Volo.Abp.AspNetCore.Components.Alerts; + +public interface IAlertManager { - public interface IAlertManager - { - AlertList Alerts { get; } - } + AlertList Alerts { get; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/AbpWebAssemblyConventionalRegistrar.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/AbpWebAssemblyConventionalRegistrar.cs index 3929f6c4cc..776c80108a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/AbpWebAssemblyConventionalRegistrar.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/AbpWebAssemblyConventionalRegistrar.cs @@ -3,23 +3,22 @@ using Microsoft.AspNetCore.Components; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.DependencyInjection +namespace Volo.Abp.AspNetCore.Components.DependencyInjection; + +public class AbpWebAssemblyConventionalRegistrar : DefaultConventionalRegistrar { - public class AbpWebAssemblyConventionalRegistrar : DefaultConventionalRegistrar + protected override bool IsConventionalRegistrationDisabled(Type type) { - protected override bool IsConventionalRegistrationDisabled(Type type) - { - return !IsComponent(type) || base.IsConventionalRegistrationDisabled(type); - } + return !IsComponent(type) || base.IsConventionalRegistrationDisabled(type); + } - private static bool IsComponent(Type type) - { - return typeof(ComponentBase).IsAssignableFrom(type); - } + private static bool IsComponent(Type type) + { + return typeof(ComponentBase).IsAssignableFrom(type); + } - protected override ServiceLifetime? GetDefaultLifeTimeOrNull(Type type) - { - return ServiceLifetime.Transient; - } + protected override ServiceLifetime? GetDefaultLifeTimeOrNull(Type type) + { + return ServiceLifetime.Transient; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/ServiceProviderComponentActivator.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/ServiceProviderComponentActivator.cs index 3841f48c4a..001659395e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/ServiceProviderComponentActivator.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/DependencyInjection/ServiceProviderComponentActivator.cs @@ -1,32 +1,31 @@ using System; using Microsoft.AspNetCore.Components; -namespace Volo.Abp.AspNetCore.Components.DependencyInjection +namespace Volo.Abp.AspNetCore.Components.DependencyInjection; + +public class ServiceProviderComponentActivator : IComponentActivator { - public class ServiceProviderComponentActivator : IComponentActivator + public IServiceProvider ServiceProvider { get; } + + public ServiceProviderComponentActivator(IServiceProvider serviceProvider) + { + ServiceProvider = serviceProvider; + } + + public IComponent CreateInstance(Type componentType) { - public IServiceProvider ServiceProvider { get; } + var instance = ServiceProvider.GetService(componentType); - public ServiceProviderComponentActivator(IServiceProvider serviceProvider) + if (instance == null) { - ServiceProvider = serviceProvider; + instance = Activator.CreateInstance(componentType); } - public IComponent CreateInstance(Type componentType) + if (!(instance is IComponent component)) { - var instance = ServiceProvider.GetService(componentType); - - if (instance == null) - { - instance = Activator.CreateInstance(componentType); - } - - if (!(instance is IComponent component)) - { - throw new ArgumentException($"The type {componentType.FullName} does not implement {nameof(IComponent)}.", nameof(componentType)); - } - - return component; + throw new ArgumentException($"The type {componentType.FullName} does not implement {nameof(IComponent)}.", nameof(componentType)); } + + return component; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/IUserExceptionInformer.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/IUserExceptionInformer.cs index aaab5057eb..26b04b805e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/IUserExceptionInformer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/IUserExceptionInformer.cs @@ -1,11 +1,10 @@ using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.ExceptionHandling +namespace Volo.Abp.AspNetCore.Components.ExceptionHandling; + +public interface IUserExceptionInformer { - public interface IUserExceptionInformer - { - void Inform(UserExceptionInformerContext context); - - Task InformAsync(UserExceptionInformerContext context); - } + void Inform(UserExceptionInformerContext context); + + Task InformAsync(UserExceptionInformerContext context); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/NullUserExceptionInformer.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/NullUserExceptionInformer.cs index 56522bef01..3a23390f51 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/NullUserExceptionInformer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/NullUserExceptionInformer.cs @@ -1,18 +1,17 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.ExceptionHandling +namespace Volo.Abp.AspNetCore.Components.ExceptionHandling; + +public class NullUserExceptionInformer : IUserExceptionInformer, ISingletonDependency { - public class NullUserExceptionInformer : IUserExceptionInformer, ISingletonDependency + public void Inform(UserExceptionInformerContext context) { - public void Inform(UserExceptionInformerContext context) - { - - } - public Task InformAsync(UserExceptionInformerContext context) - { - return Task.CompletedTask; - } } -} \ No newline at end of file + + public Task InformAsync(UserExceptionInformerContext context) + { + return Task.CompletedTask; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/UserExceptionInformerContext.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/UserExceptionInformerContext.cs index d174a98488..978e6b82e9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/UserExceptionInformerContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/ExceptionHandling/UserExceptionInformerContext.cs @@ -1,16 +1,15 @@ using System; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Components.ExceptionHandling +namespace Volo.Abp.AspNetCore.Components.ExceptionHandling; + +public class UserExceptionInformerContext { - public class UserExceptionInformerContext - { - [NotNull] - public Exception Exception { get; } + [NotNull] + public Exception Exception { get; } - public UserExceptionInformerContext(Exception exception) - { - Exception = exception; - } + public UserExceptionInformerContext(Exception exception) + { + Exception = exception; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs index 4f43cb90d6..86e878d2a9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/IUiMessageService.cs @@ -1,18 +1,17 @@ using System; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Messages +namespace Volo.Abp.AspNetCore.Components.Messages; + +public interface IUiMessageService { - public interface IUiMessageService - { - Task Info(string message, string title = null, Action options = null); + Task Info(string message, string title = null, Action options = null); - Task Success(string message, string title = null, Action options = null); + Task Success(string message, string title = null, Action options = null); - Task Warn(string message, string title = null, Action options = null); + Task Warn(string message, string title = null, Action options = null); - Task Error(string message, string title = null, Action options = null); + Task Error(string message, string title = null, Action options = null); - Task Confirm(string message, string title = null, Action options = null); - } + Task Confirm(string message, string title = null, Action options = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs index 51ef8ed558..4d73fb2812 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageEventArgs.cs @@ -1,35 +1,34 @@ using System; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Messages +namespace Volo.Abp.AspNetCore.Components.Messages; + +public class UiMessageEventArgs : EventArgs { - public class UiMessageEventArgs : EventArgs + public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options) { - public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options) - { - MessageType = messageType; - Message = message; - Title = title; - Options = options; - } + MessageType = messageType; + Message = message; + Title = title; + Options = options; + } - public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options, TaskCompletionSource callback) - { - MessageType = messageType; - Message = message; - Title = title; - Options = options; - Callback = callback; - } + public UiMessageEventArgs(UiMessageType messageType, string message, string title, UiMessageOptions options, TaskCompletionSource callback) + { + MessageType = messageType; + Message = message; + Title = title; + Options = options; + Callback = callback; + } - public UiMessageType MessageType { get; set; } + public UiMessageType MessageType { get; set; } - public string Message { get; } + public string Message { get; } - public string Title { get; } + public string Title { get; } - public UiMessageOptions Options { get; } + public UiMessageOptions Options { get; } - public TaskCompletionSource Callback { get; } - } + public TaskCompletionSource Callback { get; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs index 9da4bcad60..5cb8e56eee 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageOptions.cs @@ -1,53 +1,52 @@ -namespace Volo.Abp.AspNetCore.Components.Messages +namespace Volo.Abp.AspNetCore.Components.Messages; + +/// +/// Options to override message dialog appearance. +/// +public class UiMessageOptions { /// - /// Options to override message dialog appearance. - /// - public class UiMessageOptions - { - /// - /// If true, the message dialogue will be centered on the screen. - /// - public bool CenterMessage { get; set; } - - /// - /// If true, the message dialogue will show the large icon for the current message type. - /// - public bool ShowMessageIcon { get; set; } - - /// - /// Overrides the build-in message icon. - /// - public object MessageIcon { get; set; } - - /// - /// Custom text for the Ok button. - /// - public string OkButtonText { get; set; } - - /// - /// Custom icon for the Ok button. - /// - public object OkButtonIcon { get; set; } - - /// - /// Custom text for the Confirmation button. - /// - public string ConfirmButtonText { get; set; } - - /// - /// Custom icon for the Confirmation button. - /// - public object ConfirmButtonIcon { get; set; } - - /// - /// Custom text for the Cancel button. - /// - public string CancelButtonText { get; set; } - - /// - /// Custom icon for the Cancel button. - /// - public object CancelButtonIcon { get; set; } - } + /// If true, the message dialogue will be centered on the screen. + /// + public bool CenterMessage { get; set; } + + /// + /// If true, the message dialogue will show the large icon for the current message type. + /// + public bool ShowMessageIcon { get; set; } + + /// + /// Overrides the build-in message icon. + /// + public object MessageIcon { get; set; } + + /// + /// Custom text for the Ok button. + /// + public string OkButtonText { get; set; } + + /// + /// Custom icon for the Ok button. + /// + public object OkButtonIcon { get; set; } + + /// + /// Custom text for the Confirmation button. + /// + public string ConfirmButtonText { get; set; } + + /// + /// Custom icon for the Confirmation button. + /// + public object ConfirmButtonIcon { get; set; } + + /// + /// Custom text for the Cancel button. + /// + public string CancelButtonText { get; set; } + + /// + /// Custom icon for the Cancel button. + /// + public object CancelButtonIcon { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageType.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageType.cs index 677297055e..0f8264ecd1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Messages/UiMessageType.cs @@ -1,14 +1,13 @@ -namespace Volo.Abp.AspNetCore.Components.Messages +namespace Volo.Abp.AspNetCore.Components.Messages; + +/// +/// Defines the possible ui message types with predefined actions. +/// +public enum UiMessageType { - /// - /// Defines the possible ui message types with predefined actions. - /// - public enum UiMessageType - { - Info, - Success, - Warning, - Error, - Confirmation, - } + Info, + Success, + Warning, + Error, + Confirmation, } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs index dfbde9b1eb..394fdec2a7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/IUiNotificationService.cs @@ -1,16 +1,15 @@ using System; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Notifications +namespace Volo.Abp.AspNetCore.Components.Notifications; + +public interface IUiNotificationService { - public interface IUiNotificationService - { - Task Info(string message, string title = null, Action options = null); - - Task Success(string message, string title = null, Action options = null); - - Task Warn(string message, string title = null, Action options = null); - - Task Error(string message, string title = null, Action options = null); - } + Task Info(string message, string title = null, Action options = null); + + Task Success(string message, string title = null, Action options = null); + + Task Warn(string message, string title = null, Action options = null); + + Task Error(string message, string title = null, Action options = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs index ed8217348e..6c47586325 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/NullUiNotificationService.cs @@ -2,27 +2,26 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Notifications +namespace Volo.Abp.AspNetCore.Components.Notifications; + +public class NullUiNotificationService : IUiNotificationService, ITransientDependency { - public class NullUiNotificationService : IUiNotificationService, ITransientDependency + public Task Info(string message, string title = null, Action options = null) { - public Task Info(string message, string title = null, Action options = null) - { - return Task.CompletedTask; - } + return Task.CompletedTask; + } - public Task Success(string message, string title = null, Action options = null) - { - return Task.CompletedTask; - } + public Task Success(string message, string title = null, Action options = null) + { + return Task.CompletedTask; + } - public Task Warn(string message, string title = null, Action options = null) - { - return Task.CompletedTask; - } - public Task Error(string message, string title = null, Action options = null) - { - return Task.CompletedTask; - } + public Task Warn(string message, string title = null, Action options = null) + { + return Task.CompletedTask; + } + public Task Error(string message, string title = null, Action options = null) + { + return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs index 30d497d2ab..554450d025 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationEventArgs.cs @@ -1,23 +1,22 @@ using System; -namespace Volo.Abp.AspNetCore.Components.Notifications +namespace Volo.Abp.AspNetCore.Components.Notifications; + +public class UiNotificationEventArgs : EventArgs { - public class UiNotificationEventArgs : EventArgs + public UiNotificationEventArgs(UiNotificationType notificationType, string message, string title, UiNotificationOptions options) { - public UiNotificationEventArgs(UiNotificationType notificationType, string message, string title, UiNotificationOptions options) - { - NotificationType = notificationType; - Message = message; - Title = title; - Options = options; - } + NotificationType = notificationType; + Message = message; + Title = title; + Options = options; + } - public UiNotificationType NotificationType { get; set; } + public UiNotificationType NotificationType { get; set; } - public string Message { get; } + public string Message { get; } - public string Title { get; } + public string Title { get; } - public UiNotificationOptions Options { get; } - } + public UiNotificationOptions Options { get; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs index eb1c5d7102..c3f6a74fa5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationOptions.cs @@ -1,20 +1,19 @@ using Volo.Abp.Localization; -namespace Volo.Abp.AspNetCore.Components.Notifications +namespace Volo.Abp.AspNetCore.Components.Notifications; + +/// +/// Options to override notification appearance. +/// +public class UiNotificationOptions { /// - /// Options to override notification appearance. + /// Custom text for the Ok button. /// - public class UiNotificationOptions - { - /// - /// Custom text for the Ok button. - /// - public ILocalizableString OkButtonText { get; set; } + public ILocalizableString OkButtonText { get; set; } - /// - /// Custom icon for the Ok button. - /// - public object OkButtonIcon { get; set; } - } + /// + /// Custom icon for the Ok button. + /// + public object OkButtonIcon { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationType.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationType.cs index 3547d451e9..bd31445558 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Notifications/UiNotificationType.cs @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Components.Notifications +namespace Volo.Abp.AspNetCore.Components.Notifications; + +public enum UiNotificationType { - public enum UiNotificationType - { - Info, - Success, - Warning, - Error, - } + Info, + Success, + Warning, + Error, } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs index fa9781e2d9..156c763722 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/IUiPageProgressService.cs @@ -1,21 +1,20 @@ using System; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Components.Progression +namespace Volo.Abp.AspNetCore.Components.Progression; + +public interface IUiPageProgressService { - public interface IUiPageProgressService - { - /// - /// An event raised after the notification is received. - /// - public event EventHandler ProgressChanged; + /// + /// An event raised after the notification is received. + /// + public event EventHandler ProgressChanged; - /// - /// Sets the progress percentage. - /// - /// Value of the progress from 0 to 100, or null for indeterminate progress. - /// Additional options. - /// Awaitable task. - Task Go(int? percentage, Action options = null); - } + /// + /// Sets the progress percentage. + /// + /// Value of the progress from 0 to 100, or null for indeterminate progress. + /// Additional options. + /// Awaitable task. + Task Go(int? percentage, Action options = null); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs index 5c375e2b40..2277122418 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/NullUiPageProgressService.cs @@ -2,15 +2,14 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Components.Progression +namespace Volo.Abp.AspNetCore.Components.Progression; + +public class NullUiPageProgressService : IUiPageProgressService, ISingletonDependency { - public class NullUiPageProgressService : IUiPageProgressService, ISingletonDependency - { - public event EventHandler ProgressChanged; + public event EventHandler ProgressChanged; - public Task Go(int? percentage, Action options = null) - { - return Task.CompletedTask; - } + public Task Go(int? percentage, Action options = null) + { + return Task.CompletedTask; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs index 74af5cb971..adb4b73a64 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressEventArgs.cs @@ -1,17 +1,16 @@ using System; -namespace Volo.Abp.AspNetCore.Components.Progression +namespace Volo.Abp.AspNetCore.Components.Progression; + +public class UiPageProgressEventArgs : EventArgs { - public class UiPageProgressEventArgs : EventArgs + public UiPageProgressEventArgs(int? percentage, UiPageProgressOptions options) { - public UiPageProgressEventArgs(int? percentage, UiPageProgressOptions options) - { - Percentage = percentage; - Options = options; - } + Percentage = percentage; + Options = options; + } - public int? Percentage { get; } + public int? Percentage { get; } - public UiPageProgressOptions Options { get; } - } + public UiPageProgressOptions Options { get; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs index 0ce243552d..d747e60d03 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressOptions.cs @@ -1,13 +1,12 @@ -namespace Volo.Abp.AspNetCore.Components.Progression +namespace Volo.Abp.AspNetCore.Components.Progression; + +/// +/// Options to override page progress appearance. +/// +public class UiPageProgressOptions { /// - /// Options to override page progress appearance. + /// Type or color, of the page progress. /// - public class UiPageProgressOptions - { - /// - /// Type or color, of the page progress. - /// - public UiPageProgressType Type { get; set; } - } + public UiPageProgressType Type { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs index db1d00932d..fe9c02b98e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/Progression/UiPageProgressType.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Components.Progression +namespace Volo.Abp.AspNetCore.Components.Progression; + +public enum UiPageProgressType { - public enum UiPageProgressType - { - Default, - Info, - Success, - Warning, - Error, - } + Default, + Info, + Success, + Warning, + Error, } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Microsoft/AspNetCore/Builder/AbpAspNetCoreMultiTenancyApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Microsoft/AspNetCore/Builder/AbpAspNetCoreMultiTenancyApplicationBuilderExtensions.cs index afc05f9233..ceb872e5c3 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Microsoft/AspNetCore/Builder/AbpAspNetCoreMultiTenancyApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Microsoft/AspNetCore/Builder/AbpAspNetCoreMultiTenancyApplicationBuilderExtensions.cs @@ -1,13 +1,12 @@ using Volo.Abp.AspNetCore.MultiTenancy; -namespace Microsoft.AspNetCore.Builder +namespace Microsoft.AspNetCore.Builder; + +public static class AbpAspNetCoreMultiTenancyApplicationBuilderExtensions { - public static class AbpAspNetCoreMultiTenancyApplicationBuilderExtensions + public static IApplicationBuilder UseMultiTenancy(this IApplicationBuilder app) { - public static IApplicationBuilder UseMultiTenancy(this IApplicationBuilder app) - { - return app - .UseMiddleware(); - } + return app + .UseMiddleware(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyModule.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyModule.cs index 1d0268556f..ad36cf0f11 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyModule.cs @@ -2,24 +2,23 @@ using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +[DependsOn( + typeof(AbpMultiTenancyModule), + typeof(AbpAspNetCoreModule) + )] +public class AbpAspNetCoreMultiTenancyModule : AbpModule { - [DependsOn( - typeof(AbpMultiTenancyModule), - typeof(AbpAspNetCoreModule) - )] - public class AbpAspNetCoreMultiTenancyModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.TenantResolvers.Add(new QueryStringTenantResolveContributor()); - options.TenantResolvers.Add(new FormTenantResolveContributor()); - options.TenantResolvers.Add(new RouteTenantResolveContributor()); - options.TenantResolvers.Add(new HeaderTenantResolveContributor()); - options.TenantResolvers.Add(new CookieTenantResolveContributor()); - }); - } + options.TenantResolvers.Add(new QueryStringTenantResolveContributor()); + options.TenantResolvers.Add(new FormTenantResolveContributor()); + options.TenantResolvers.Add(new RouteTenantResolveContributor()); + options.TenantResolvers.Add(new HeaderTenantResolveContributor()); + options.TenantResolvers.Add(new CookieTenantResolveContributor()); + }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs index b2ecf708c5..4f89ef7b97 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpAspNetCoreMultiTenancyOptions.cs @@ -5,35 +5,34 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class AbpAspNetCoreMultiTenancyOptions { - public class AbpAspNetCoreMultiTenancyOptions - { - /// - /// Default: . - /// - public string TenantKey { get; set; } + /// + /// Default: . + /// + public string TenantKey { get; set; } - public Func MultiTenancyMiddlewareErrorPageBuilder { get; set; } + public Func MultiTenancyMiddlewareErrorPageBuilder { get; set; } - public AbpAspNetCoreMultiTenancyOptions() + public AbpAspNetCoreMultiTenancyOptions() + { + TenantKey = TenantResolverConsts.DefaultTenantKey; + MultiTenancyMiddlewareErrorPageBuilder = async (context, exception) => { - TenantKey = TenantResolverConsts.DefaultTenantKey; - MultiTenancyMiddlewareErrorPageBuilder = async (context, exception)=> - { - context.Response.StatusCode = (int) HttpStatusCode.InternalServerError;; - context.Response.ContentType = "text/html"; + context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; ; + context.Response.ContentType = "text/html"; - var message = exception.Message; - var details = exception is BusinessException businessException ? businessException.Details : string.Empty; + var message = exception.Message; + var details = exception is BusinessException businessException ? businessException.Details : string.Empty; - await context.Response.WriteAsync($"\r\n"); - await context.Response.WriteAsync($"

{message}

{details}
\r\n"); - await context.Response.WriteAsync("\r\n"); + await context.Response.WriteAsync($"\r\n"); + await context.Response.WriteAsync($"

{message}

{details}
\r\n"); + await context.Response.WriteAsync("\r\n"); // Note the 500 spaces are to work around an IE 'feature' await context.Response.WriteAsync(new string(' ', 500)); - }; - } + }; } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpMultiTenancyCookieHelper.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpMultiTenancyCookieHelper.cs index 2c2b2de0e9..d4a91f3b12 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpMultiTenancyCookieHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/AbpMultiTenancyCookieHelper.cs @@ -1,33 +1,32 @@ using System; using Microsoft.AspNetCore.Http; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public static class AbpMultiTenancyCookieHelper { - public static class AbpMultiTenancyCookieHelper + public static void SetTenantCookie( + HttpContext context, + Guid? tenantId, + string tenantKey) { - public static void SetTenantCookie( - HttpContext context, - Guid? tenantId, - string tenantKey) + if (tenantId != null) + { + context.Response.Cookies.Append( + tenantKey, + tenantId.ToString(), + new CookieOptions + { + Path = "/", + HttpOnly = false, + IsEssential = true, + Expires = DateTimeOffset.Now.AddYears(10) + } + ); + } + else { - if (tenantId != null) - { - context.Response.Cookies.Append( - tenantKey, - tenantId.ToString(), - new CookieOptions - { - Path = "/", - HttpOnly = false, - IsEssential = true, - Expires = DateTimeOffset.Now.AddYears(10) - } - ); - } - else - { - context.Response.Cookies.Delete(tenantKey); - } + context.Response.Cookies.Delete(tenantKey); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs index dd7ca5685e..1eabd3ebfb 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/CookieTenantResolveContributor.cs @@ -2,17 +2,16 @@ using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class CookieTenantResolveContributor : HttpTenantResolveContributorBase { - public class CookieTenantResolveContributor : HttpTenantResolveContributorBase - { - public const string ContributorName = "Cookie"; + public const string ContributorName = "Cookie"; - public override string Name => ContributorName; + public override string Name => ContributorName; - protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) - { - return Task.FromResult(httpContext.Request.Cookies[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]); - } + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + { + return Task.FromResult(httpContext.Request.Cookies[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]); } } 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 255e0ac89b..78f92ac20e 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 @@ -4,38 +4,37 @@ using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; using Volo.Abp.Text.Formatting; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +//TODO: Create a better domain format. We can accept regex for example. + +public class DomainTenantResolveContributor : HttpTenantResolveContributorBase { - //TODO: Create a better domain format. We can accept regex for example. + public const string ContributorName = "Domain"; - public class DomainTenantResolveContributor : HttpTenantResolveContributorBase - { - public const string ContributorName = "Domain"; + public override string Name => ContributorName; - public override string Name => ContributorName; + private static readonly string[] ProtocolPrefixes = { "http://", "https://" }; - private static readonly string[] ProtocolPrefixes = { "http://", "https://" }; + private readonly string _domainFormat; - private readonly string _domainFormat; + public DomainTenantResolveContributor(string domainFormat) + { + _domainFormat = domainFormat.RemovePreFix(ProtocolPrefixes); + } - public DomainTenantResolveContributor(string domainFormat) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + { + if (!httpContext.Request.Host.HasValue) { - _domainFormat = domainFormat.RemovePreFix(ProtocolPrefixes); + return Task.FromResult(null); } - protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) - { - 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); + var hostName = httpContext.Request.Host.Value.RemovePreFix(ProtocolPrefixes); + var extractResult = FormattedStringValueExtracter.Extract(hostName, _domainFormat, ignoreCase: true); - context.Handled = true; + context.Handled = true; - return Task.FromResult(extractResult.IsMatch ? extractResult.Matches[0].Value : null); - } + return Task.FromResult(extractResult.IsMatch ? extractResult.Matches[0].Value : null); } } 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 77c12bef7b..67ef0a4c2c 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 @@ -3,23 +3,22 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class FormTenantResolveContributor : HttpTenantResolveContributorBase { - public class FormTenantResolveContributor : HttpTenantResolveContributorBase - { - public const string ContributorName = "Form"; + public const string ContributorName = "Form"; - public override string Name => ContributorName; + public override string Name => ContributorName; - protected override async Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + protected override async Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + { + if (!httpContext.Request.HasFormContentType) { - if (!httpContext.Request.HasFormContentType) - { - return null; - } - - var form = await httpContext.Request.ReadFormAsync(); - return form[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]; + return null; } + + var form = await httpContext.Request.ReadFormAsync(); + return form[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey]; } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs index a6a52290be..a0bec0d606 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HeaderTenantResolveContributor.cs @@ -6,43 +6,42 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class HeaderTenantResolveContributor : HttpTenantResolveContributorBase { - public class HeaderTenantResolveContributor : HttpTenantResolveContributorBase - { - public const string ContributorName = "Header"; + public const string ContributorName = "Header"; - public override string Name => ContributorName; + public override string Name => ContributorName; - protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + { + if (httpContext.Request.Headers.IsNullOrEmpty()) { - if (httpContext.Request.Headers.IsNullOrEmpty()) - { - return Task.FromResult((string)null); - } - - var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; - - var tenantIdHeader = httpContext.Request.Headers[tenantIdKey]; - if (tenantIdHeader == string.Empty || tenantIdHeader.Count < 1) - { - return Task.FromResult((string)null); - } + return Task.FromResult((string)null); + } - if (tenantIdHeader.Count > 1) - { - Log(context, $"HTTP request includes more than one {tenantIdKey} header value. First one will be used. All of them: {tenantIdHeader.JoinAsString(", ")}"); - } + var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; - return Task.FromResult(tenantIdHeader.First()); + var tenantIdHeader = httpContext.Request.Headers[tenantIdKey]; + if (tenantIdHeader == string.Empty || tenantIdHeader.Count < 1) + { + return Task.FromResult((string)null); } - protected virtual void Log(ITenantResolveContext context, string text) + if (tenantIdHeader.Count > 1) { - context - .ServiceProvider - .GetRequiredService>() - .LogWarning(text); + Log(context, $"HTTP request includes more than one {tenantIdKey} header value. First one will be used. All of them: {tenantIdHeader.JoinAsString(", ")}"); } + + return Task.FromResult(tenantIdHeader.First()); + } + + protected virtual void Log(ITenantResolveContext context, string text) + { + context + .ServiceProvider + .GetRequiredService>() + .LogWarning(text); } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpContextTenantResolveResultAccessor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpContextTenantResolveResultAccessor.cs index 593d9a7024..1197e16baa 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpContextTenantResolveResultAccessor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpContextTenantResolveResultAccessor.cs @@ -2,32 +2,29 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +[Dependency(ReplaceServices = true)] +public class HttpContextTenantResolveResultAccessor : ITenantResolveResultAccessor, ITransientDependency { - [Dependency(ReplaceServices = true)] - public class HttpContextTenantResolveResultAccessor : ITenantResolveResultAccessor, ITransientDependency - { - public const string HttpContextItemName = "__AbpTenantResolveResult"; + public const string HttpContextItemName = "__AbpTenantResolveResult"; - public TenantResolveResult Result - { - get => _httpContextAccessor.HttpContext?.Items[HttpContextItemName] as TenantResolveResult; - set + public TenantResolveResult Result { + get => _httpContextAccessor.HttpContext?.Items[HttpContextItemName] as TenantResolveResult; + set { + if (_httpContextAccessor.HttpContext == null) { - if (_httpContextAccessor.HttpContext == null) - { - return; - } - - _httpContextAccessor.HttpContext.Items[HttpContextItemName] = value; + return; } + + _httpContextAccessor.HttpContext.Items[HttpContextItemName] = value; } + } - private readonly IHttpContextAccessor _httpContextAccessor; + private readonly IHttpContextAccessor _httpContextAccessor; - public HttpContextTenantResolveResultAccessor(IHttpContextAccessor httpContextAccessor) - { - _httpContextAccessor = httpContextAccessor; - } + public HttpContextTenantResolveResultAccessor(IHttpContextAccessor httpContextAccessor) + { + _httpContextAccessor = httpContextAccessor; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributorBase.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributorBase.cs index 3b454b5ef9..b0900c899f 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributorBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/HttpTenantResolveContributorBase.cs @@ -6,39 +6,38 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public abstract class HttpTenantResolveContributorBase : TenantResolveContributorBase { - public abstract class HttpTenantResolveContributorBase : TenantResolveContributorBase + public override async Task ResolveAsync(ITenantResolveContext context) { - public override async Task ResolveAsync(ITenantResolveContext context) + var httpContext = context.GetHttpContext(); + if (httpContext == null) { - var httpContext = context.GetHttpContext(); - if (httpContext == null) - { - return; - } - - try - { - await ResolveFromHttpContextAsync(context, httpContext); - } - catch (Exception e) - { - context.ServiceProvider - .GetRequiredService>() - .LogWarning(e.ToString()); - } + return; } - protected virtual async Task ResolveFromHttpContextAsync(ITenantResolveContext context, HttpContext httpContext) + try { - var tenantIdOrName = await GetTenantIdOrNameFromHttpContextOrNullAsync(context, httpContext); - if (!tenantIdOrName.IsNullOrEmpty()) - { - context.TenantIdOrName = tenantIdOrName; - } + await ResolveFromHttpContextAsync(context, httpContext); } + catch (Exception e) + { + context.ServiceProvider + .GetRequiredService>() + .LogWarning(e.ToString()); + } + } - protected abstract Task GetTenantIdOrNameFromHttpContextOrNullAsync([NotNull] ITenantResolveContext context, [NotNull] HttpContext httpContext); + protected virtual async Task ResolveFromHttpContextAsync(ITenantResolveContext context, HttpContext httpContext) + { + var tenantIdOrName = await GetTenantIdOrNameFromHttpContextOrNullAsync(context, httpContext); + if (!tenantIdOrName.IsNullOrEmpty()) + { + context.TenantIdOrName = tenantIdOrName; + } } + + protected abstract Task GetTenantIdOrNameFromHttpContextOrNullAsync([NotNull] ITenantResolveContext context, [NotNull] HttpContext httpContext); } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs index f3d21a804b..9cd89272f4 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs @@ -11,112 +11,111 @@ using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; using Volo.Abp.Settings; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class MultiTenancyMiddleware : IMiddleware, ITransientDependency { - public class MultiTenancyMiddleware : IMiddleware, ITransientDependency + private readonly ITenantConfigurationProvider _tenantConfigurationProvider; + private readonly ICurrentTenant _currentTenant; + private readonly AbpAspNetCoreMultiTenancyOptions _options; + private readonly ITenantResolveResultAccessor _tenantResolveResultAccessor; + + public MultiTenancyMiddleware( + ITenantConfigurationProvider tenantConfigurationProvider, + ICurrentTenant currentTenant, + IOptions options, + ITenantResolveResultAccessor tenantResolveResultAccessor) { - private readonly ITenantConfigurationProvider _tenantConfigurationProvider; - private readonly ICurrentTenant _currentTenant; - private readonly AbpAspNetCoreMultiTenancyOptions _options; - private readonly ITenantResolveResultAccessor _tenantResolveResultAccessor; + _tenantConfigurationProvider = tenantConfigurationProvider; + _currentTenant = currentTenant; + _tenantResolveResultAccessor = tenantResolveResultAccessor; + _options = options.Value; + } - public MultiTenancyMiddleware( - ITenantConfigurationProvider tenantConfigurationProvider, - ICurrentTenant currentTenant, - IOptions options, - ITenantResolveResultAccessor tenantResolveResultAccessor) + public async Task InvokeAsync(HttpContext context, RequestDelegate next) + { + TenantConfiguration tenant; + try { - _tenantConfigurationProvider = tenantConfigurationProvider; - _currentTenant = currentTenant; - _tenantResolveResultAccessor = tenantResolveResultAccessor; - _options = options.Value; + tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult: true); } - - public async Task InvokeAsync(HttpContext context, RequestDelegate next) + catch (Exception e) { - TenantConfiguration tenant; - try - { - tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult: true); - } - catch (Exception e) - { - await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e); - return; - } + await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e); + return; + } - if (tenant?.Id != _currentTenant.Id) + if (tenant?.Id != _currentTenant.Id) + { + using (_currentTenant.Change(tenant?.Id, tenant?.Name)) { - using (_currentTenant.Change(tenant?.Id, tenant?.Name)) + if (_tenantResolveResultAccessor.Result != null && + _tenantResolveResultAccessor.Result.AppliedResolvers.Contains(QueryStringTenantResolveContributor.ContributorName)) { - if (_tenantResolveResultAccessor.Result != null && - _tenantResolveResultAccessor.Result.AppliedResolvers.Contains(QueryStringTenantResolveContributor.ContributorName)) - { - AbpMultiTenancyCookieHelper.SetTenantCookie(context, _currentTenant.Id, _options.TenantKey); - } - - var requestCulture = await TryGetRequestCultureAsync(context); - if (requestCulture != null) - { - CultureInfo.CurrentCulture = requestCulture.Culture; - CultureInfo.CurrentUICulture = requestCulture.UICulture; - AbpRequestCultureCookieHelper.SetCultureCookie( - context, - requestCulture - ); - context.Items[AbpRequestLocalizationMiddleware.HttpContextItemName] = true; - } + AbpMultiTenancyCookieHelper.SetTenantCookie(context, _currentTenant.Id, _options.TenantKey); + } - await next(context); + var requestCulture = await TryGetRequestCultureAsync(context); + if (requestCulture != null) + { + CultureInfo.CurrentCulture = requestCulture.Culture; + CultureInfo.CurrentUICulture = requestCulture.UICulture; + AbpRequestCultureCookieHelper.SetCultureCookie( + context, + requestCulture + ); + context.Items[AbpRequestLocalizationMiddleware.HttpContextItemName] = true; } - } - else - { + await next(context); } } - - private async Task TryGetRequestCultureAsync(HttpContext httpContext) + else { - var requestCultureFeature = httpContext.Features.Get(); + await next(context); + } + } - /* If requestCultureFeature == null, that means the RequestLocalizationMiddleware was not used - * and we don't want to set the culture. */ - if (requestCultureFeature == null) - { - return null; - } + private async Task TryGetRequestCultureAsync(HttpContext httpContext) + { + var requestCultureFeature = httpContext.Features.Get(); - /* If requestCultureFeature.Provider is not null, that means RequestLocalizationMiddleware - * already picked a language, so we don't need to set the default. */ - if (requestCultureFeature.Provider != null) - { - return null; - } + /* If requestCultureFeature == null, that means the RequestLocalizationMiddleware was not used + * and we don't want to set the culture. */ + if (requestCultureFeature == null) + { + return null; + } - var settingProvider = httpContext.RequestServices.GetRequiredService(); - var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); - if (defaultLanguage.IsNullOrWhiteSpace()) - { - return null; - } + /* If requestCultureFeature.Provider is not null, that means RequestLocalizationMiddleware + * already picked a language, so we don't need to set the default. */ + if (requestCultureFeature.Provider != null) + { + return null; + } - string culture; - string uiCulture; + var settingProvider = httpContext.RequestServices.GetRequiredService(); + var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); + if (defaultLanguage.IsNullOrWhiteSpace()) + { + return null; + } - if (defaultLanguage.Contains(';')) - { - var splitted = defaultLanguage.Split(';'); - culture = splitted[0]; - uiCulture = splitted[1]; - } - else - { - culture = defaultLanguage; - uiCulture = defaultLanguage; - } + string culture; + string uiCulture; - return new RequestCulture(culture, uiCulture); + if (defaultLanguage.Contains(';')) + { + var splitted = defaultLanguage.Split(';'); + culture = splitted[0]; + uiCulture = splitted[1]; } + else + { + culture = defaultLanguage; + uiCulture = defaultLanguage; + } + + return new RequestCulture(culture, uiCulture); } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs index 2edcac0eaf..f4f2cf8cb6 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs @@ -3,33 +3,32 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class QueryStringTenantResolveContributor : HttpTenantResolveContributorBase { - public class QueryStringTenantResolveContributor : HttpTenantResolveContributorBase - { - public const string ContributorName = "QueryString"; + public const string ContributorName = "QueryString"; - public override string Name => ContributorName; + public override string Name => ContributorName; - protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + { + if (httpContext.Request.QueryString.HasValue) { - if (httpContext.Request.QueryString.HasValue) + var tenantKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; + if (httpContext.Request.Query.ContainsKey(tenantKey)) { - var tenantKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey; - if (httpContext.Request.Query.ContainsKey(tenantKey)) + var tenantValue = httpContext.Request.Query[tenantKey].ToString(); + if (tenantValue.IsNullOrWhiteSpace()) { - var tenantValue = httpContext.Request.Query[tenantKey].ToString(); - if (tenantValue.IsNullOrWhiteSpace()) - { - context.Handled = true; - return Task.FromResult(null); - } - - return Task.FromResult(tenantValue); + context.Handled = true; + return Task.FromResult(null); } - } - return Task.FromResult(null); + return Task.FromResult(tenantValue); + } } + + return Task.FromResult(null); } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs index 7ac3943c84..06e7972aa1 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/RouteTenantResolveContributor.cs @@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public class RouteTenantResolveContributor : HttpTenantResolveContributorBase { - public class RouteTenantResolveContributor : HttpTenantResolveContributorBase - { - public const string ContributorName = "Route"; + public const string ContributorName = "Route"; - public override string Name => ContributorName; + public override string Name => ContributorName; - protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) - { - var tenantId = httpContext.GetRouteValue(context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey); - return Task.FromResult(tenantId != null ? Convert.ToString(tenantId) : null); - } + protected override Task GetTenantIdOrNameFromHttpContextOrNullAsync(ITenantResolveContext context, HttpContext httpContext) + { + var tenantId = httpContext.GetRouteValue(context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey); + return Task.FromResult(tenantId != null ? Convert.ToString(tenantId) : null); } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/TenantResolveContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/TenantResolveContextExtensions.cs index 701833bc70..a4a8669304 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/TenantResolveContextExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/TenantResolveContextExtensions.cs @@ -2,13 +2,12 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.MultiTenancy; -namespace Volo.Abp.AspNetCore.MultiTenancy +namespace Volo.Abp.AspNetCore.MultiTenancy; + +public static class TenantResolveContextExtensions { - public static class TenantResolveContextExtensions + public static AbpAspNetCoreMultiTenancyOptions GetAbpAspNetCoreMultiTenancyOptions(this ITenantResolveContext context) { - public static AbpAspNetCoreMultiTenancyOptions GetAbpAspNetCoreMultiTenancyOptions(this ITenantResolveContext context) - { - return context.ServiceProvider.GetRequiredService>().Value; - } + return context.ServiceProvider.GetRequiredService>().Value; } } diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyOptionsExtensions.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyOptionsExtensions.cs index aa6f0fdb0e..8ec02c027a 100644 --- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyOptionsExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyOptionsExtensions.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; using Volo.Abp.AspNetCore.MultiTenancy; -namespace Volo.Abp.MultiTenancy +namespace Volo.Abp.MultiTenancy; + +public static class AbpMultiTenancyOptionsExtensions { - public static class AbpMultiTenancyOptionsExtensions + public static void AddDomainTenantResolver(this AbpTenantResolveOptions options, string domainFormat) { - public static void AddDomainTenantResolver(this AbpTenantResolveOptions options, string domainFormat) - { - options.TenantResolvers.InsertAfter( - r => r is CurrentUserTenantResolveContributor, - new DomainTenantResolveContributor(domainFormat) - ); - } + options.TenantResolvers.InsertAfter( + r => r is CurrentUserTenantResolveContributor, + new DomainTenantResolveContributor(domainFormat) + ); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.Generated.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.Generated.cs index 9d1c472bc7..198cfce711 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.Generated.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.Generated.cs @@ -9,15 +9,14 @@ using Volo.Abp.Http.Client.ClientProxying; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; // ReSharper disable once CheckNamespace -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationClientProxy))] +public partial class AbpApplicationConfigurationClientProxy : ClientProxyBase, IAbpApplicationConfigurationAppService { - [Dependency(ReplaceServices = true)] - [ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationClientProxy))] - public partial class AbpApplicationConfigurationClientProxy : ClientProxyBase, IAbpApplicationConfigurationAppService + public virtual async Task GetAsync() { - public virtual async Task GetAsync() - { - return await RequestAsync(nameof(GetAsync)); - } + return await RequestAsync(nameof(GetAsync)); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.cs index 41c1031556..62b582b01b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpApplicationConfigurationClientProxy.cs @@ -3,11 +3,10 @@ using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies; + +[RemoteService(false)] +[DisableConventionalRegistration] +public partial class AbpApplicationConfigurationClientProxy { - [RemoteService(false)] - [DisableConventionalRegistration] - public partial class AbpApplicationConfigurationClientProxy - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.Generated.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.Generated.cs index 8984abfc4c..291a6e95d1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.Generated.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.Generated.cs @@ -9,26 +9,25 @@ using Volo.Abp.Http.Client.ClientProxying; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; // ReSharper disable once CheckNamespace -namespace Pages.Abp.MultiTenancy.ClientProxies +namespace Pages.Abp.MultiTenancy.ClientProxies; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IAbpTenantAppService), typeof(AbpTenantClientProxy))] +public partial class AbpTenantClientProxy : ClientProxyBase, IAbpTenantAppService { - [Dependency(ReplaceServices = true)] - [ExposeServices(typeof(IAbpTenantAppService), typeof(AbpTenantClientProxy))] - public partial class AbpTenantClientProxy : ClientProxyBase, IAbpTenantAppService + public virtual async Task FindTenantByNameAsync(string name) { - public virtual async Task FindTenantByNameAsync(string name) + return await RequestAsync(nameof(FindTenantByNameAsync), new ClientProxyRequestTypeValue { - return await RequestAsync(nameof(FindTenantByNameAsync), new ClientProxyRequestTypeValue - { - { typeof(string), name } - }); - } + { typeof(string), name } + }); + } - public virtual async Task FindTenantByIdAsync(Guid id) + public virtual async Task FindTenantByIdAsync(Guid id) + { + return await RequestAsync(nameof(FindTenantByIdAsync), new ClientProxyRequestTypeValue { - return await RequestAsync(nameof(FindTenantByIdAsync), new ClientProxyRequestTypeValue - { - { typeof(Guid), id } - }); - } + { typeof(Guid), id } + }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.cs index e73b05b573..8ca24d1317 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/ClientProxies/AbpTenantClientProxy.cs @@ -4,11 +4,11 @@ using Volo.Abp; using Volo.Abp.DependencyInjection; -namespace Pages.Abp.MultiTenancy.ClientProxies +namespace Pages.Abp.MultiTenancy.ClientProxies; + +[RemoteService(false)] +[DisableConventionalRegistration] +public partial class AbpTenantClientProxy { - [RemoteService(false)] - [DisableConventionalRegistration] - public partial class AbpTenantClientProxy - { - } } + 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 e48a63c86c..d3734e7c66 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,4 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Pages.Abp.MultiTenancy.ClientProxies; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies; using Volo.Abp.Authorization; @@ -9,37 +9,36 @@ using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +[DependsOn( + typeof(AbpHttpClientModule), + typeof(AbpAspNetCoreMvcContractsModule), + typeof(AbpCachingModule), + typeof(AbpLocalizationModule), + typeof(AbpAuthorizationModule), + typeof(AbpFeaturesModule), + typeof(AbpVirtualFileSystemModule) +)] +public class AbpAspNetCoreMvcClientCommonModule : AbpModule { - [DependsOn( - typeof(AbpHttpClientModule), - typeof(AbpAspNetCoreMvcContractsModule), - typeof(AbpCachingModule), - typeof(AbpLocalizationModule), - typeof(AbpAuthorizationModule), - typeof(AbpFeaturesModule), - typeof(AbpVirtualFileSystemModule) - )] - public class AbpAspNetCoreMvcClientCommonModule : AbpModule + public const string RemoteServiceName = "AbpMvcClient"; + + public override void ConfigureServices(ServiceConfigurationContext context) { - public const string RemoteServiceName = "AbpMvcClient"; + context.Services.AddStaticHttpClientProxies(typeof(AbpAspNetCoreMvcContractsModule).Assembly, RemoteServiceName); - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - context.Services.AddStaticHttpClientProxies(typeof(AbpAspNetCoreMvcContractsModule).Assembly, RemoteServiceName); + options.FileSets.AddEmbedded(); + }); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - - Configure(options => - { - options.GlobalContributors.Add(); - }); + Configure(options => + { + options.GlobalContributors.Add(); + }); - context.Services.AddTransient(); - context.Services.AddTransient(); - } + context.Services.AddTransient(); + context.Services.AddTransient(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/ICachedApplicationConfigurationClient.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/ICachedApplicationConfigurationClient.cs index 80e6c4e054..f173082fa3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/ICachedApplicationConfigurationClient.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/ICachedApplicationConfigurationClient.cs @@ -1,12 +1,11 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public interface ICachedApplicationConfigurationClient : IAsyncInitialize { - public interface ICachedApplicationConfigurationClient : IAsyncInitialize - { - Task GetAsync(); + Task GetAsync(); - ApplicationConfigurationDto Get(); - } + ApplicationConfigurationDto Get(); } 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 f769f512a5..d3969e7888 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 @@ -2,21 +2,20 @@ using System.Threading.Tasks; using Volo.Abp.Features; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class RemoteFeatureChecker : FeatureCheckerBase { - public class RemoteFeatureChecker : FeatureCheckerBase - { - protected ICachedApplicationConfigurationClient ConfigurationClient { get; } + protected ICachedApplicationConfigurationClient ConfigurationClient { get; } - public RemoteFeatureChecker(ICachedApplicationConfigurationClient configurationClient) - { - ConfigurationClient = configurationClient; - } + public RemoteFeatureChecker(ICachedApplicationConfigurationClient configurationClient) + { + ConfigurationClient = configurationClient; + } - public override async Task GetOrNullAsync(string name) - { - var configuration = await ConfigurationClient.GetAsync(); - return configuration.Features.Values.GetOrDefault(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.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs index 02c97c0598..cb6b76ad74 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs @@ -3,21 +3,20 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Localization; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class RemoteLanguageProvider : ILanguageProvider, ITransientDependency { - public class RemoteLanguageProvider : ILanguageProvider, ITransientDependency - { - protected ICachedApplicationConfigurationClient ConfigurationClient { get; } + protected ICachedApplicationConfigurationClient ConfigurationClient { get; } - public RemoteLanguageProvider(ICachedApplicationConfigurationClient configurationClient) - { - ConfigurationClient = configurationClient; - } + public RemoteLanguageProvider(ICachedApplicationConfigurationClient configurationClient) + { + ConfigurationClient = configurationClient; + } - public async Task> GetLanguagesAsync() - { - var configuration = await ConfigurationClient.GetAsync(); - return configuration.Localization.Languages; - } + public async Task> GetLanguagesAsync() + { + var configuration = await ConfigurationClient.GetAsync(); + return configuration.Localization.Languages; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLocalizationContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLocalizationContributor.cs index f8502fce78..c01fc6a1af 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLocalizationContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteLocalizationContributor.cs @@ -5,67 +5,66 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Localization; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class RemoteLocalizationContributor : ILocalizationResourceContributor { - public class RemoteLocalizationContributor : ILocalizationResourceContributor + private LocalizationResource _resource; + private ICachedApplicationConfigurationClient _applicationConfigurationClient; + private ILogger _logger; + + public void Initialize(LocalizationResourceInitializationContext context) { - private LocalizationResource _resource; - private ICachedApplicationConfigurationClient _applicationConfigurationClient; - private ILogger _logger; + _resource = context.Resource; + _applicationConfigurationClient = context.ServiceProvider.GetRequiredService(); + _logger = context.ServiceProvider.GetService>() + ?? NullLogger.Instance; + } - public void Initialize(LocalizationResourceInitializationContext context) + public LocalizedString GetOrNull(string cultureName, string name) + { + var resource = GetResourceOrNull(); + if (resource == null) { - _resource = context.Resource; - _applicationConfigurationClient = context.ServiceProvider.GetRequiredService(); - _logger = context.ServiceProvider.GetService>() - ?? NullLogger.Instance; + return null; } - public LocalizedString GetOrNull(string cultureName, string name) + var value = resource.GetOrDefault(name); + if (value == null) { - var resource = GetResourceOrNull(); - if (resource == null) - { - return null; - } - - var value = resource.GetOrDefault(name); - if (value == null) - { - return null; - } - - return new LocalizedString(name, value); + return null; } - public void Fill(string cultureName, Dictionary dictionary) - { - var resource = GetResourceOrNull(); - if (resource == null) - { - return; - } + return new LocalizedString(name, value); + } - foreach (var keyValue in resource) - { - dictionary[keyValue.Key] = new LocalizedString(keyValue.Key, keyValue.Value); - } + public void Fill(string cultureName, Dictionary dictionary) + { + var resource = GetResourceOrNull(); + if (resource == null) + { + return; } - private Dictionary GetResourceOrNull() + foreach (var keyValue in resource) { - var applicationConfigurationDto = _applicationConfigurationClient.Get(); + dictionary[keyValue.Key] = new LocalizedString(keyValue.Key, keyValue.Value); + } + } - var resource = applicationConfigurationDto - .Localization.Values - .GetOrDefault(_resource.ResourceName); + private Dictionary GetResourceOrNull() + { + var applicationConfigurationDto = _applicationConfigurationClient.Get(); - if (resource == null) - { - _logger.LogWarning($"Could not find the localization resource {_resource.ResourceName} on the remote server!"); - } + var resource = applicationConfigurationDto + .Localization.Values + .GetOrDefault(_resource.ResourceName); - return resource; + if (resource == null) + { + _logger.LogWarning($"Could not find the localization resource {_resource.ResourceName} on the remote server!"); } + + return resource; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs index 5ce1ea9edc..3274c5010c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs @@ -3,48 +3,47 @@ using System.Threading.Tasks; using Volo.Abp.Authorization.Permissions; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class RemotePermissionChecker : IPermissionChecker, ITransientDependency { - public class RemotePermissionChecker : IPermissionChecker, ITransientDependency + protected ICachedApplicationConfigurationClient ConfigurationClient { get; } + + public RemotePermissionChecker(ICachedApplicationConfigurationClient configurationClient) { - protected ICachedApplicationConfigurationClient ConfigurationClient { get; } + ConfigurationClient = configurationClient; + } - public RemotePermissionChecker(ICachedApplicationConfigurationClient configurationClient) - { - ConfigurationClient = configurationClient; - } + public async Task IsGrantedAsync(string name) + { + var configuration = await ConfigurationClient.GetAsync(); - public async Task IsGrantedAsync(string name) - { - var configuration = await ConfigurationClient.GetAsync(); + return configuration.Auth.GrantedPolicies.ContainsKey(name); + } - return configuration.Auth.GrantedPolicies.ContainsKey(name); - } + public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name) + { + /* This provider always works for the current principal. */ + return await IsGrantedAsync(name); + } - public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name) + public async Task IsGrantedAsync(string[] names) + { + var result = new MultiplePermissionGrantResult(); + var configuration = await ConfigurationClient.GetAsync(); + foreach (var name in names) { - /* This provider always works for the current principal. */ - return await IsGrantedAsync(name); + result.Result.Add(name, configuration.Auth.GrantedPolicies.ContainsKey(name) ? + PermissionGrantResult.Granted : + PermissionGrantResult.Undefined); } - public async Task IsGrantedAsync(string[] names) - { - var result = new MultiplePermissionGrantResult(); - var configuration = await ConfigurationClient.GetAsync(); - foreach (var name in names) - { - result.Result.Add(name, configuration.Auth.GrantedPolicies.ContainsKey(name) ? - PermissionGrantResult.Granted : - PermissionGrantResult.Undefined); - } - - return result; - } + return result; + } - public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string[] names) - { - /* This provider always works for the current principal. */ - return await IsGrantedAsync(names); - } + public async Task IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string[] names) + { + /* This provider always works for the current principal. */ + return await IsGrantedAsync(names); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteSettingProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteSettingProvider.cs index 89db44b43d..2599df1ef6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteSettingProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client.Common/Volo/Abp/AspNetCore/Mvc/Client/RemoteSettingProvider.cs @@ -4,36 +4,35 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Settings; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class RemoteSettingProvider : ISettingProvider, ITransientDependency { - public class RemoteSettingProvider : ISettingProvider, ITransientDependency - { - protected ICachedApplicationConfigurationClient ConfigurationClient { get; } + protected ICachedApplicationConfigurationClient ConfigurationClient { get; } - public RemoteSettingProvider(ICachedApplicationConfigurationClient configurationClient) - { - ConfigurationClient = configurationClient; - } + public RemoteSettingProvider(ICachedApplicationConfigurationClient configurationClient) + { + ConfigurationClient = configurationClient; + } - public async Task GetOrNullAsync(string name) - { - var configuration = await ConfigurationClient.GetAsync(); - return configuration.Setting.Values.GetOrDefault(name); - } + public async Task GetOrNullAsync(string name) + { + var configuration = await ConfigurationClient.GetAsync(); + return configuration.Setting.Values.GetOrDefault(name); + } - public async Task> GetAllAsync(string[] names) - { - var configuration = await ConfigurationClient.GetAsync(); - return names.Select(x => new SettingValue(x, configuration.Setting.Values.GetOrDefault(x))).ToList(); - } + public async Task> GetAllAsync(string[] names) + { + var configuration = await ConfigurationClient.GetAsync(); + return names.Select(x => new SettingValue(x, configuration.Setting.Values.GetOrDefault(x))).ToList(); + } - public async Task> GetAllAsync() - { - var configuration = await ConfigurationClient.GetAsync(); - return configuration - .Setting.Values - .Select(s => new SettingValue(s.Key, s.Value)) - .ToList(); - } + public async Task> GetAllAsync() + { + var configuration = await ConfigurationClient.GetAsync(); + return configuration + .Setting.Values + .Select(s => new SettingValue(s.Key, s.Value)) + .ToList(); } } 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 48e2461167..a7dc58f82a 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,13 +1,12 @@ using Volo.Abp.EventBus; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +[DependsOn( + typeof(AbpAspNetCoreMvcClientCommonModule), + typeof(AbpEventBusModule) + )] +public class AbpAspNetCoreMvcClientModule : AbpModule { - [DependsOn( - 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 6c67031da9..92152ac807 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 @@ -9,82 +9,81 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Threading; using Volo.Abp.Users; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +[ExposeServices( + typeof(MvcCachedApplicationConfigurationClient), + typeof(ICachedApplicationConfigurationClient), + typeof(IAsyncInitialize) + )] +public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency { - [ExposeServices( - typeof(MvcCachedApplicationConfigurationClient), - typeof(ICachedApplicationConfigurationClient), - typeof(IAsyncInitialize) - )] - public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency + protected IHttpContextAccessor HttpContextAccessor { get; } + protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } + protected ICurrentUser CurrentUser { get; } + protected IDistributedCache Cache { get; } + + public MvcCachedApplicationConfigurationClient( + IDistributedCache cache, + AbpApplicationConfigurationClientProxy applicationConfigurationAppService, + ICurrentUser currentUser, + IHttpContextAccessor httpContextAccessor) { - protected IHttpContextAccessor HttpContextAccessor { get; } - protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } - protected ICurrentUser CurrentUser { get; } - protected IDistributedCache Cache { get; } + ApplicationConfigurationAppService = applicationConfigurationAppService; + CurrentUser = currentUser; + HttpContextAccessor = httpContextAccessor; + Cache = cache; + } - public MvcCachedApplicationConfigurationClient( - IDistributedCache cache, - AbpApplicationConfigurationClientProxy applicationConfigurationAppService, - ICurrentUser currentUser, - IHttpContextAccessor httpContextAccessor) - { - ApplicationConfigurationAppService = applicationConfigurationAppService; - CurrentUser = currentUser; - HttpContextAccessor = httpContextAccessor; - Cache = cache; - } + public async Task InitializeAsync() + { + await GetAsync(); + } - public async Task InitializeAsync() - { - await GetAsync(); - } + public async Task GetAsync() + { + var cacheKey = CreateCacheKey(); + var httpContext = HttpContextAccessor?.HttpContext; - public async Task GetAsync() + if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) { - var cacheKey = CreateCacheKey(); - var httpContext = HttpContextAccessor?.HttpContext; - - if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) - { - - return configuration; - } - - - configuration = await Cache.GetOrAddAsync( - cacheKey, - async () => await ApplicationConfigurationAppService.GetAsync(), - () => new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable. - } - ); - - if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest) - { - httpContext.Items[cacheKey] = configuration; - } return configuration; } - public ApplicationConfigurationDto Get() - { - var cacheKey = CreateCacheKey(); - var httpContext = HttpContextAccessor?.HttpContext; - if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) + configuration = await Cache.GetOrAddAsync( + cacheKey, + async () => await ApplicationConfigurationAppService.GetAsync(), + () => new DistributedCacheEntryOptions { - return configuration; - } + AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable. + } + ); - return AsyncHelper.RunSync(GetAsync); + if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest) + { + httpContext.Items[cacheKey] = configuration; } - protected virtual string CreateCacheKey() + return configuration; + } + + public ApplicationConfigurationDto Get() + { + var cacheKey = CreateCacheKey(); + var httpContext = HttpContextAccessor?.HttpContext; + + if (httpContext != null && !httpContext.WebSockets.IsWebSocketRequest && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) { - return MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser); + return configuration; } + + return AsyncHelper.RunSync(GetAsync); + } + + protected virtual string CreateCacheKey() + { + 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 index ae013c4343..740a79c884 100644 --- 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 @@ -1,14 +1,13 @@ using System.Globalization; using Volo.Abp.Users; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +internal static class MvcCachedApplicationConfigurationClientHelper { - internal static class MvcCachedApplicationConfigurationClientHelper + public static string CreateCacheKey(ICurrentUser currentUser) { - public static string CreateCacheKey(ICurrentUser currentUser) - { - var userKey = currentUser.Id?.ToString("N") ?? "Anonymous"; - return $"ApplicationConfiguration_{userKey}_{CultureInfo.CurrentUICulture.Name}"; - } + var userKey = currentUser.Id?.ToString("N") ?? "Anonymous"; + return $"ApplicationConfiguration_{userKey}_{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 index e8f5b201da..8bd3971779 100644 --- 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 @@ -5,30 +5,29 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus; using Volo.Abp.Users; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class MvcCurrentApplicationConfigurationCacheResetEventHandler : + ILocalEventHandler, + ITransientDependency { - public class MvcCurrentApplicationConfigurationCacheResetEventHandler : - ILocalEventHandler, - ITransientDependency - { - protected ICurrentUser CurrentUser { get; } - protected IDistributedCache Cache { get; } + protected ICurrentUser CurrentUser { get; } + protected IDistributedCache Cache { get; } - public MvcCurrentApplicationConfigurationCacheResetEventHandler(ICurrentUser currentUser, - IDistributedCache cache) - { - CurrentUser = currentUser; - Cache = cache; - } + public MvcCurrentApplicationConfigurationCacheResetEventHandler(ICurrentUser currentUser, + IDistributedCache cache) + { + CurrentUser = currentUser; + Cache = cache; + } - public virtual async Task HandleEventAsync(CurrentApplicationConfigurationCacheResetEventData eventData) - { - await Cache.RemoveAsync(CreateCacheKey()); - } + public virtual async Task HandleEventAsync(CurrentApplicationConfigurationCacheResetEventData eventData) + { + await Cache.RemoveAsync(CreateCacheKey()); + } - protected virtual string CreateCacheKey() - { - return MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser); - } + protected virtual string CreateCacheKey() + { + return MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs index f4744ca587..dd4411255e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs @@ -9,154 +9,153 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; using Volo.Abp.Threading; -namespace Volo.Abp.AspNetCore.Mvc.Client +namespace Volo.Abp.AspNetCore.Mvc.Client; + +public class MvcRemoteTenantStore : ITenantStore, ITransientDependency { - public class MvcRemoteTenantStore : ITenantStore, ITransientDependency + protected AbpTenantClientProxy TenantAppService { get; } + protected IHttpContextAccessor HttpContextAccessor { get; } + protected IDistributedCache Cache { get; } + + public MvcRemoteTenantStore( + AbpTenantClientProxy tenantAppService, + IHttpContextAccessor httpContextAccessor, + IDistributedCache cache) { - protected AbpTenantClientProxy TenantAppService { get; } - protected IHttpContextAccessor HttpContextAccessor { get; } - protected IDistributedCache Cache { get; } - - public MvcRemoteTenantStore( - AbpTenantClientProxy tenantAppService, - IHttpContextAccessor httpContextAccessor, - IDistributedCache cache) - { - TenantAppService = tenantAppService; - HttpContextAccessor = httpContextAccessor; - Cache = cache; - } + TenantAppService = tenantAppService; + HttpContextAccessor = httpContextAccessor; + Cache = cache; + } - public async Task FindAsync(string name) + public async Task FindAsync(string name) + { + var cacheKey = CreateCacheKey(name); + var httpContext = HttpContextAccessor?.HttpContext; + + if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) { - var cacheKey = CreateCacheKey(name); - var httpContext = HttpContextAccessor?.HttpContext; + return tenantConfiguration; + } - if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) + tenantConfiguration = await Cache.GetOrAddAsync( + cacheKey, + async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name)), + () => new DistributedCacheEntryOptions { - return tenantConfiguration; - } - - tenantConfiguration = await Cache.GetOrAddAsync( - cacheKey, - async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name)), - () => new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = - TimeSpan.FromMinutes(5) //TODO: Should be configurable. + AbsoluteExpirationRelativeToNow = + TimeSpan.FromMinutes(5) //TODO: Should be configurable. } - ); - - if (httpContext != null) - { - httpContext.Items[cacheKey] = tenantConfiguration; - } + ); - return tenantConfiguration; - } - - public async Task FindAsync(Guid id) + if (httpContext != null) { - var cacheKey = CreateCacheKey(id); - var httpContext = HttpContextAccessor?.HttpContext; + httpContext.Items[cacheKey] = tenantConfiguration; + } - if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) - { - return tenantConfiguration; - } - - tenantConfiguration = await Cache.GetOrAddAsync( - cacheKey, - async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id)), - () => new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = - TimeSpan.FromMinutes(5) //TODO: Should be configurable. - } - ); + return tenantConfiguration; + } - if (httpContext != null) - { - httpContext.Items[cacheKey] = tenantConfiguration; - } + public async Task FindAsync(Guid id) + { + var cacheKey = CreateCacheKey(id); + var httpContext = HttpContextAccessor?.HttpContext; + if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) + { return tenantConfiguration; } - public TenantConfiguration Find(string name) - { - var cacheKey = CreateCacheKey(name); - var httpContext = HttpContextAccessor?.HttpContext; - - if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) + tenantConfiguration = await Cache.GetOrAddAsync( + cacheKey, + async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id)), + () => new DistributedCacheEntryOptions { - return tenantConfiguration; - } - - tenantConfiguration = Cache.GetOrAdd( - cacheKey, - () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name))), - () => new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = - TimeSpan.FromMinutes(5) //TODO: Should be configurable. + AbsoluteExpirationRelativeToNow = + TimeSpan.FromMinutes(5) //TODO: Should be configurable. } - ); - - if (httpContext != null) - { - httpContext.Items[cacheKey] = tenantConfiguration; - } + ); - return tenantConfiguration; + if (httpContext != null) + { + httpContext.Items[cacheKey] = tenantConfiguration; } - public TenantConfiguration Find(Guid id) + return tenantConfiguration; + } + + public TenantConfiguration Find(string name) + { + var cacheKey = CreateCacheKey(name); + var httpContext = HttpContextAccessor?.HttpContext; + + if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) { - var cacheKey = CreateCacheKey(id); - var httpContext = HttpContextAccessor?.HttpContext; + return tenantConfiguration; + } - if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) + tenantConfiguration = Cache.GetOrAdd( + cacheKey, + () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByNameAsync(name))), + () => new DistributedCacheEntryOptions { - return tenantConfiguration; - } - - tenantConfiguration = Cache.GetOrAdd( - cacheKey, - () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id))), - () => new DistributedCacheEntryOptions - { - AbsoluteExpirationRelativeToNow = - TimeSpan.FromMinutes(5) //TODO: Should be configurable. + AbsoluteExpirationRelativeToNow = + TimeSpan.FromMinutes(5) //TODO: Should be configurable. } - ); + ); - if (httpContext != null) - { - httpContext.Items[cacheKey] = tenantConfiguration; - } + if (httpContext != null) + { + httpContext.Items[cacheKey] = tenantConfiguration; + } + + return tenantConfiguration; + } + public TenantConfiguration Find(Guid id) + { + var cacheKey = CreateCacheKey(id); + var httpContext = HttpContextAccessor?.HttpContext; + + if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) + { return tenantConfiguration; } - protected virtual TenantConfiguration CreateTenantConfiguration(FindTenantResultDto tenantResultDto) - { - if (!tenantResultDto.Success || tenantResultDto.TenantId == null) + tenantConfiguration = Cache.GetOrAdd( + cacheKey, + () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await TenantAppService.FindTenantByIdAsync(id))), + () => new DistributedCacheEntryOptions { - return null; - } - - return new TenantConfiguration(tenantResultDto.TenantId.Value, tenantResultDto.Name); - } + AbsoluteExpirationRelativeToNow = + TimeSpan.FromMinutes(5) //TODO: Should be configurable. + } + ); - protected virtual string CreateCacheKey(string tenantName) + if (httpContext != null) { - return $"RemoteTenantStore_Name_{tenantName}"; + httpContext.Items[cacheKey] = tenantConfiguration; } - protected virtual string CreateCacheKey(Guid tenantId) + return tenantConfiguration; + } + + protected virtual TenantConfiguration CreateTenantConfiguration(FindTenantResultDto tenantResultDto) + { + if (!tenantResultDto.Success || tenantResultDto.TenantId == null) { - return $"RemoteTenantStore_Id_{tenantId:N}"; + return null; } + + return new TenantConfiguration(tenantResultDto.TenantId.Value, tenantResultDto.Name); + } + + protected virtual string CreateCacheKey(string tenantName) + { + return $"RemoteTenantStore_Name_{tenantName}"; + } + + protected virtual string CreateCacheKey(Guid tenantId) + { + return $"RemoteTenantStore_Id_{tenantId:N}"; } } 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 3bf299437c..278fe6eb21 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 @@ -1,13 +1,12 @@ using Volo.Abp.Application; using Volo.Abp.Modularity; -namespace Volo.Abp.AspNetCore.Mvc +namespace Volo.Abp.AspNetCore.Mvc; + +[DependsOn( + typeof(AbpDddApplicationContractsModule) + )] +public class AbpAspNetCoreMvcContractsModule : AbpModule { - [DependsOn( - typeof(AbpDddApplicationContractsModule) - )] - public class AbpAspNetCoreMvcContractsModule : AbpModule - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs index 39b3ca394b..be5a022b01 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs @@ -1,19 +1,18 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +[Serializable] +public class ApplicationAuthConfigurationDto { - [Serializable] - public class ApplicationAuthConfigurationDto - { - public Dictionary Policies { get; set; } + public Dictionary Policies { get; set; } - public Dictionary GrantedPolicies { get; set; } + public Dictionary GrantedPolicies { get; set; } - public ApplicationAuthConfigurationDto() - { - Policies = new Dictionary(); - GrantedPolicies = new Dictionary(); - } + public ApplicationAuthConfigurationDto() + { + Policies = new Dictionary(); + GrantedPolicies = new Dictionary(); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs index 6a4aa49a1b..9b6a66992f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs @@ -2,29 +2,28 @@ using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +[Serializable] +public class ApplicationConfigurationDto { - [Serializable] - public class ApplicationConfigurationDto - { - public ApplicationLocalizationConfigurationDto Localization { get; set; } + public ApplicationLocalizationConfigurationDto Localization { get; set; } - public ApplicationAuthConfigurationDto Auth { get; set; } + public ApplicationAuthConfigurationDto Auth { get; set; } - public ApplicationSettingConfigurationDto Setting { get; set; } + public ApplicationSettingConfigurationDto Setting { get; set; } - public CurrentUserDto CurrentUser { get; set; } + public CurrentUserDto CurrentUser { get; set; } - public ApplicationFeatureConfigurationDto Features { get; set; } + public ApplicationFeatureConfigurationDto Features { get; set; } - public MultiTenancyInfoDto MultiTenancy { get; set; } + public MultiTenancyInfoDto MultiTenancy { get; set; } - public CurrentTenantDto CurrentTenant { get; set; } + public CurrentTenantDto CurrentTenant { get; set; } - public TimingDto Timing { get; set; } + public TimingDto Timing { get; set; } - public ClockDto Clock { get; set; } + public ClockDto Clock { get; set; } - public ObjectExtensionsDto ObjectExtensions { get; set; } - } + public ObjectExtensionsDto ObjectExtensions { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs index 4972d2242d..9215a46616 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs @@ -1,16 +1,15 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +[Serializable] +public class ApplicationFeatureConfigurationDto { - [Serializable] - public class ApplicationFeatureConfigurationDto - { - public Dictionary Values { get; set; } + public Dictionary Values { get; set; } - public ApplicationFeatureConfigurationDto() - { - Values = new Dictionary(); - } + public ApplicationFeatureConfigurationDto() + { + Values = new Dictionary(); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs index 5f53694177..0b229235fa 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs @@ -2,28 +2,27 @@ using System.Collections.Generic; using Volo.Abp.Localization; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +[Serializable] +public class ApplicationLocalizationConfigurationDto { - [Serializable] - public class ApplicationLocalizationConfigurationDto - { - //TODO: Rename to Texts? - public Dictionary> Values { get; set; } + //TODO: Rename to Texts? + public Dictionary> Values { get; set; } - public List Languages { get; set; } + public List Languages { get; set; } - public CurrentCultureDto CurrentCulture { get; set; } + public CurrentCultureDto CurrentCulture { get; set; } - public string DefaultResourceName { get; set; } + public string DefaultResourceName { get; set; } - public Dictionary> LanguagesMap { get; set; } + public Dictionary> LanguagesMap { get; set; } - public Dictionary> LanguageFilesMap { get; set; } + public Dictionary> LanguageFilesMap { get; set; } - public ApplicationLocalizationConfigurationDto() - { - Values = new Dictionary>(); - Languages = new List(); - } + public ApplicationLocalizationConfigurationDto() + { + Values = new Dictionary>(); + Languages = new List(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationSettingConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationSettingConfigurationDto.cs index 40cbd89fd1..a1fbba2bbf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationSettingConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationSettingConfigurationDto.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +[Serializable] +public class ApplicationSettingConfigurationDto { - [Serializable] - public class ApplicationSettingConfigurationDto - { - public Dictionary Values { get; set; } - } -} \ No newline at end of file + public Dictionary Values { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs index 2cff97f814..5112ac80ed 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs @@ -1,7 +1,6 @@ -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class ClockDto { - public class ClockDto - { - public string Kind { get; set; } - } + public string Kind { get; set; } } 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 index e84e96d9dd..a50cb7b136 100644 --- 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 @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +/// +/// This event is used to invalidate current user's cached configuration. +/// +public class CurrentApplicationConfigurationCacheResetEventData { - /// - /// This event is used to invalidate current user's cached configuration. - /// - public class CurrentApplicationConfigurationCacheResetEventData - { - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentCultureDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentCultureDto.cs index b225fac8f0..8f1896e31f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentCultureDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentCultureDto.cs @@ -1,23 +1,22 @@ -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class CurrentCultureDto { - public class CurrentCultureDto - { - public string DisplayName { get; set; } + public string DisplayName { get; set; } - public string EnglishName { get; set; } + public string EnglishName { get; set; } - public string ThreeLetterIsoLanguageName { get; set; } + public string ThreeLetterIsoLanguageName { get; set; } - public string TwoLetterIsoLanguageName { get; set; } + public string TwoLetterIsoLanguageName { get; set; } - public bool IsRightToLeft { get; set; } + public bool IsRightToLeft { get; set; } - public string CultureName { get; set; } + public string CultureName { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public string NativeName { get; set; } + public string NativeName { get; set; } - public DateTimeFormatDto DateTimeFormat { get; set; } - } -} \ No newline at end of file + public DateTimeFormatDto DateTimeFormat { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs index b1b97c4b91..534ca68d80 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs @@ -1,34 +1,33 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +[Serializable] +public class CurrentUserDto { - [Serializable] - public class CurrentUserDto - { - public bool IsAuthenticated { get; set; } + public bool IsAuthenticated { get; set; } - public Guid? Id { get; set; } + public Guid? Id { get; set; } - public Guid? TenantId { get; set; } + public Guid? TenantId { get; set; } - public Guid? ImpersonatorUserId { get; set; } + public Guid? ImpersonatorUserId { get; set; } - public Guid? ImpersonatorTenantId { get; set; } + public Guid? ImpersonatorTenantId { get; set; } - public string UserName { get; set; } + public string UserName { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public string SurName { get; set; } + public string SurName { get; set; } - public string Email { get; set; } + public string Email { get; set; } - public bool EmailVerified { get; set; } + public bool EmailVerified { get; set; } - public string PhoneNumber { get; set; } + public string PhoneNumber { get; set; } - public bool PhoneNumberVerified { get; set; } + public bool PhoneNumberVerified { get; set; } - public string[] Roles { get; set; } - } + public string[] Roles { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/DateTimeFormatDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/DateTimeFormatDto.cs index 259dff1da6..5f5ad14a5a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/DateTimeFormatDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/DateTimeFormatDto.cs @@ -1,19 +1,18 @@ -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class DateTimeFormatDto { - public class DateTimeFormatDto - { - public string CalendarAlgorithmType { get; set; } + public string CalendarAlgorithmType { get; set; } - public string DateTimeFormatLong { get; set; } + public string DateTimeFormatLong { get; set; } - public string ShortDatePattern { get; set; } + public string ShortDatePattern { get; set; } - public string FullDateTimePattern { get; set; } + public string FullDateTimePattern { get; set; } - public string DateSeparator { get; set; } + public string DateSeparator { get; set; } - public string ShortTimePattern { get; set; } + public string ShortTimePattern { get; set; } - public string LongTimePattern { get; set; } - } -} \ No newline at end of file + public string LongTimePattern { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IAbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IAbpApplicationConfigurationAppService.cs index 4c521b9efc..9c8fd3d414 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IAbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/IAbpApplicationConfigurationAppService.cs @@ -1,10 +1,9 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public interface IAbpApplicationConfigurationAppService : IApplicationService { - public interface IAbpApplicationConfigurationAppService : IApplicationService - { - Task GetAsync(); - } -} \ No newline at end of file + Task GetAsync(); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs index d15870e7c1..742da779f6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/EntityExtensionDto.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class EntityExtensionDto { - [Serializable] - public class EntityExtensionDto - { - public Dictionary Properties { get; set; } + public Dictionary Properties { get; set; } - public Dictionary Configuration { get; set; } - } -} \ No newline at end of file + public Dictionary Configuration { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumDto.cs index 4f2dc526eb..24e9ec9a2f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumDto.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionEnumDto { - [Serializable] - public class ExtensionEnumDto - { - public List Fields { get; set; } + public List Fields { get; set; } - public string LocalizationResource { get; set; } - } -} \ No newline at end of file + public string LocalizationResource { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumFieldDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumFieldDto.cs index ddc7c349d4..13728d8409 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumFieldDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionEnumFieldDto.cs @@ -1,12 +1,11 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionEnumFieldDto { - [Serializable] - public class ExtensionEnumFieldDto - { - public string Name { get; set; } + public string Name { get; set; } - public object Value { get; set; } - } -} \ No newline at end of file + public object Value { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs index a2a588a358..9179ce7e2e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiCreateDto.cs @@ -1,13 +1,12 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyApiCreateDto { - [Serializable] - public class ExtensionPropertyApiCreateDto - { - /// - /// Default: true. - /// - public bool IsAvailable { get; set; } = true; - } -} \ No newline at end of file + /// + /// Default: true. + /// + public bool IsAvailable { get; set; } = true; +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs index a9b4ec5b24..920e66141a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiDto.cs @@ -1,23 +1,22 @@ using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +public class ExtensionPropertyApiDto { - public class ExtensionPropertyApiDto - { - [NotNull] - public ExtensionPropertyApiGetDto OnGet { get; set; } + [NotNull] + public ExtensionPropertyApiGetDto OnGet { get; set; } - [NotNull] - public ExtensionPropertyApiCreateDto OnCreate { get; set; } + [NotNull] + public ExtensionPropertyApiCreateDto OnCreate { get; set; } - [NotNull] - public ExtensionPropertyApiUpdateDto OnUpdate { get; set; } + [NotNull] + public ExtensionPropertyApiUpdateDto OnUpdate { get; set; } - public ExtensionPropertyApiDto() - { - OnGet = new ExtensionPropertyApiGetDto(); - OnCreate = new ExtensionPropertyApiCreateDto(); - OnUpdate = new ExtensionPropertyApiUpdateDto(); - } + public ExtensionPropertyApiDto() + { + OnGet = new ExtensionPropertyApiGetDto(); + OnCreate = new ExtensionPropertyApiCreateDto(); + OnUpdate = new ExtensionPropertyApiUpdateDto(); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs index e50a45d15a..2a9f71295c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiGetDto.cs @@ -1,13 +1,12 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyApiGetDto { - [Serializable] - public class ExtensionPropertyApiGetDto - { - /// - /// Default: true. - /// - public bool IsAvailable { get; set; } = true; - } -} \ No newline at end of file + /// + /// Default: true. + /// + public bool IsAvailable { get; set; } = true; +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs index a517b258da..d234fe37b0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyApiUpdateDto.cs @@ -1,13 +1,12 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyApiUpdateDto { - [Serializable] - public class ExtensionPropertyApiUpdateDto - { - /// - /// Default: true. - /// - public bool IsAvailable { get; set; } = true; - } -} \ No newline at end of file + /// + /// Default: true. + /// + public bool IsAvailable { get; set; } = true; +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs index 12941a3b89..492756168d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyAttributeDto.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyAttributeDto { - [Serializable] - public class ExtensionPropertyAttributeDto - { - public string TypeSimple { get; set; } + public string TypeSimple { get; set; } - public Dictionary Config { get; set; } - } -} \ No newline at end of file + public Dictionary Config { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs index b1ba6f7ea9..a1fb628e1a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyDto.cs @@ -2,26 +2,25 @@ using System.Collections.Generic; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyDto { - [Serializable] - public class ExtensionPropertyDto - { - public string Type { get; set; } + public string Type { get; set; } + + public string TypeSimple { get; set; } + + [CanBeNull] + public LocalizableStringDto DisplayName { get; set; } - public string TypeSimple { get; set; } + public ExtensionPropertyApiDto Api { get; set; } - [CanBeNull] - public LocalizableStringDto DisplayName { get; set; } + public ExtensionPropertyUiDto Ui { get; set; } - public ExtensionPropertyApiDto Api { get; set; } - - public ExtensionPropertyUiDto Ui { get; set; } + public List Attributes { get; set; } - public List Attributes { get; set; } + public Dictionary Configuration { get; set; } - public Dictionary Configuration { get; set; } - - public object DefaultValue { get; set; } - } -} \ No newline at end of file + public object DefaultValue { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs index caa5d67957..cd43df5446 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs @@ -1,13 +1,12 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyUiDto { - [Serializable] - public class ExtensionPropertyUiDto - { - public ExtensionPropertyUiTableDto OnTable { get; set; } - public ExtensionPropertyUiFormDto OnCreateForm { get; set; } - public ExtensionPropertyUiFormDto OnEditForm { get; set; } - public ExtensionPropertyUiLookupDto Lookup { get; set; } - } -} \ No newline at end of file + public ExtensionPropertyUiTableDto OnTable { get; set; } + public ExtensionPropertyUiFormDto OnCreateForm { get; set; } + public ExtensionPropertyUiFormDto OnEditForm { get; set; } + public ExtensionPropertyUiLookupDto Lookup { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs index c4f6f5211c..2eb506c13d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiFormDto.cs @@ -1,10 +1,9 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyUiFormDto { - [Serializable] - public class ExtensionPropertyUiFormDto - { - public bool IsVisible { get; set; } - } -} \ No newline at end of file + public bool IsVisible { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs index 035178df1e..b9bc94399c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs @@ -1,14 +1,13 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyUiLookupDto { - [Serializable] - public class ExtensionPropertyUiLookupDto - { - public string Url { get; set; } - public string ResultListPropertyName { get; set; } - public string DisplayPropertyName { get; set; } - public string ValuePropertyName { get; set; } - public string FilterParamName { get; set; } - } -} \ No newline at end of file + public string Url { get; set; } + public string ResultListPropertyName { get; set; } + public string DisplayPropertyName { get; set; } + public string ValuePropertyName { get; set; } + public string FilterParamName { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs index 4c9e4a7ce0..cba33fb2f8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiTableDto.cs @@ -1,10 +1,9 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ExtensionPropertyUiTableDto { - [Serializable] - public class ExtensionPropertyUiTableDto - { - public bool IsVisible { get; set; } - } -} \ No newline at end of file + public bool IsVisible { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs index b80352d791..8127a90bd7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizableStringDto.cs @@ -1,21 +1,20 @@ using System; using JetBrains.Annotations; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class LocalizableStringDto { - [Serializable] - public class LocalizableStringDto - { - [NotNull] - public string Name { get; private set; } + [NotNull] + public string Name { get; private set; } - [CanBeNull] - public string Resource { get; set; } + [CanBeNull] + public string Resource { get; set; } - public LocalizableStringDto([NotNull] string name, string resource = null) - { - Name = Check.NotNullOrEmpty(name, nameof(name)); - Resource = resource; - } + public LocalizableStringDto([NotNull] string name, string resource = null) + { + Name = Check.NotNullOrEmpty(name, nameof(name)); + Resource = resource; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleExtensionDto.cs index e077596f59..aadd08cd28 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleExtensionDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleExtensionDto.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ModuleExtensionDto { - [Serializable] - public class ModuleExtensionDto - { - public Dictionary Entities { get; set; } + public Dictionary Entities { get; set; } - public Dictionary Configuration { get; set; } - } -} \ No newline at end of file + public Dictionary Configuration { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs index 0338bbd4dc..f63935847b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; + +[Serializable] +public class ObjectExtensionsDto { - [Serializable] - public class ObjectExtensionsDto - { - public Dictionary Modules { get; set; } - - public Dictionary Enums { get; set; } - } -} \ No newline at end of file + public Dictionary Modules { get; set; } + + public Dictionary Enums { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs index bd95bfba0d..ca03407ee5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs @@ -1,24 +1,23 @@ -namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; + +public class TimingDto { - public class TimingDto - { - public TimeZone TimeZone { get; set; } - } + public TimeZone TimeZone { get; set; } +} - public class TimeZone - { - public IanaTimeZone Iana { get; set; } +public class TimeZone +{ + public IanaTimeZone Iana { get; set; } - public WindowsTimeZone Windows { get; set; } - } + public WindowsTimeZone Windows { get; set; } +} - public class WindowsTimeZone - { - public string TimeZoneId { get; set; } - } +public class WindowsTimeZone +{ + public string TimeZoneId { get; set; } +} - public class IanaTimeZone - { - public string TimeZoneName { get; set; } - } +public class IanaTimeZone +{ + public string TimeZoneName { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/CurrentTenantDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/CurrentTenantDto.cs index 06b24f1235..b8b361e7c8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/CurrentTenantDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/CurrentTenantDto.cs @@ -2,14 +2,13 @@ using System.Collections.Generic; using System.Text; -namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy +namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy; + +public class CurrentTenantDto { - public class CurrentTenantDto - { - public Guid? Id { get; set; } + public Guid? Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public bool IsAvailable { get; set; } - } + public bool IsAvailable { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs index 6f834b18ea..64bcc77554 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/FindTenantResultDto.cs @@ -1,16 +1,15 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy +namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy; + +[Serializable] +public class FindTenantResultDto { - [Serializable] - public class FindTenantResultDto - { - public bool Success { get; set; } + public bool Success { get; set; } - public Guid? TenantId { get; set; } + public Guid? TenantId { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public bool IsActive { get; set; } - } + public bool IsActive { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/IAbpTenantAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/IAbpTenantAppService.cs index eb02e84ceb..feb4fc4af7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/IAbpTenantAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/IAbpTenantAppService.cs @@ -2,12 +2,11 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy +namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy; + +public interface IAbpTenantAppService : IApplicationService { - public interface IAbpTenantAppService : IApplicationService - { - Task FindTenantByNameAsync(string name); + Task FindTenantByNameAsync(string name); - Task FindTenantByIdAsync(Guid id); - } -} \ No newline at end of file + Task FindTenantByIdAsync(Guid id); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/MultiTenancyInfoDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/MultiTenancyInfoDto.cs index 165a0e5c21..c08e4ab60d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/MultiTenancyInfoDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/MultiTenancy/MultiTenancyInfoDto.cs @@ -2,10 +2,9 @@ using System.Collections.Generic; using System.Text; -namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy +namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy; + +public class MultiTenancyInfoDto { - public class MultiTenancyInfoDto - { - public bool IsEnabled { get; set; } - } + public bool IsEnabled { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs index 889ffdc96e..fe06c4e084 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs @@ -1,17 +1,16 @@ using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; + +[DependsOn(typeof(AbpAspNetCoreMvcUiModule))] +public class AbpAspNetCoreMvcUiBootstrapModule : AbpModule { - [DependsOn(typeof(AbpAspNetCoreMvcUiModule))] - public class AbpAspNetCoreMvcUiBootstrapModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded("Volo.Abp.AspNetCore.Mvc.UI.Bootstrap"); - }); - } + options.FileSets.AddEmbedded("Volo.Abp.AspNetCore.Mvc.UI.Bootstrap"); + }); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/Microsoft/AspNetCore/Razor/TagHelpers/AbpTagHelperAttributeListExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/Microsoft/AspNetCore/Razor/TagHelpers/AbpTagHelperAttributeListExtensions.cs index ae6684a6a6..81aefb7382 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/Microsoft/AspNetCore/Razor/TagHelpers/AbpTagHelperAttributeListExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/Microsoft/AspNetCore/Razor/TagHelpers/AbpTagHelperAttributeListExtensions.cs @@ -4,54 +4,54 @@ using System.Linq; using Microsoft.AspNetCore.Razor.TagHelpers; namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers //TODO: Move to AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers namespace +; + +public static class AbpTagHelperAttributeListExtensions { - public static class AbpTagHelperAttributeListExtensions + public static void AddClass(this TagHelperAttributeList attributes, string className) { - public static void AddClass(this TagHelperAttributeList attributes, string className) + if (string.IsNullOrWhiteSpace(className)) { - if (string.IsNullOrWhiteSpace(className)) - { - return; - } - - var classAttribute = attributes["class"]; - if (classAttribute == null) - { - attributes.Add("class", className); - } - else - { - var existingClasses = classAttribute.Value.ToString().Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - existingClasses.AddIfNotContains(className); - attributes.SetAttribute("class", string.Join(" ", existingClasses)); - } + return; } - public static void RemoveClass(this TagHelperAttributeList attributes, string className) + var classAttribute = attributes["class"]; + if (classAttribute == null) { - if (string.IsNullOrWhiteSpace(className)) - { - return; - } - - var classAttribute = attributes["class"]; - if (classAttribute == null) - { - return; - } + attributes.Add("class", className); + } + else + { + var existingClasses = classAttribute.Value.ToString().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + existingClasses.AddIfNotContains(className); + attributes.SetAttribute("class", string.Join(" ", existingClasses)); + } + } - var classList = classAttribute.Value.ToString().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - classList.RemoveAll(c => c == className); + public static void RemoveClass(this TagHelperAttributeList attributes, string className) + { + if (string.IsNullOrWhiteSpace(className)) + { + return; + } - attributes.SetAttribute("class", classList.JoinAsString(" ")); + var classAttribute = attributes["class"]; + if (classAttribute == null) + { + return; } - public static void AddIfNotContains(this TagHelperAttributeList attributes, string name, object value) + var classList = classAttribute.Value.ToString().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + classList.RemoveAll(c => c == className); + + attributes.SetAttribute("class", classList.JoinAsString(" ")); + } + + public static void AddIfNotContains(this TagHelperAttributeList attributes, string name, object value) + { + if (!attributes.ContainsName(name)) { - if (!attributes.ContainsName(name)) - { - attributes.Add(name, value); - } + attributes.Add(name, value); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelper.cs index 1188d68056..5b9c1430f2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelper.cs @@ -6,44 +6,43 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.DependencyInjection; using Volo.Abp.Threading; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; + +public abstract class AbpTagHelper : TagHelper, ITransientDependency { - public abstract class AbpTagHelper : TagHelper, ITransientDependency + +} + +public abstract class AbpTagHelper : AbpTagHelper + where TTagHelper : AbpTagHelper + where TService : class, IAbpTagHelperService +{ + protected TService Service { get; } + + public override int Order => Service.Order; + + [HtmlAttributeNotBound] + [ViewContext] + public ViewContext ViewContext { get; set; } + + protected AbpTagHelper(TService service) + { + Service = service; + Service.As>().TagHelper = (TTagHelper)this; + } + + public override void Init(TagHelperContext context) { + Service.Init(context); + } + public override void Process(TagHelperContext context, TagHelperOutput output) + { + Service.Process(context, output); } - public abstract class AbpTagHelper : AbpTagHelper - where TTagHelper : AbpTagHelper - where TService : class, IAbpTagHelperService + public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - protected TService Service { get; } - - public override int Order => Service.Order; - - [HtmlAttributeNotBound] - [ViewContext] - public ViewContext ViewContext { get; set; } - - protected AbpTagHelper(TService service) - { - Service = service; - Service.As>().TagHelper = (TTagHelper)this; - } - - public override void Init(TagHelperContext context) - { - Service.Init(context); - } - - public override void Process(TagHelperContext context, TagHelperOutput output) - { - Service.Process(context, output); - } - - public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - return Service.ProcessAsync(context, output); - } + return Service.ProcessAsync(context, output); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs index 700a5f4ee9..c4314134be 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperLocalizer.cs @@ -6,45 +6,44 @@ using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc.Localization; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; + +public class AbpTagHelperLocalizer : IAbpTagHelperLocalizer { - public class AbpTagHelperLocalizer : IAbpTagHelperLocalizer - { - private readonly IStringLocalizerFactory _stringLocalizerFactory; - private readonly AbpMvcDataAnnotationsLocalizationOptions _options; + private readonly IStringLocalizerFactory _stringLocalizerFactory; + private readonly AbpMvcDataAnnotationsLocalizationOptions _options; - public AbpTagHelperLocalizer(IOptions options, IStringLocalizerFactory stringLocalizerFactory) - { - _stringLocalizerFactory = stringLocalizerFactory; - _options = options.Value; - } + public AbpTagHelperLocalizer(IOptions options, IStringLocalizerFactory stringLocalizerFactory) + { + _stringLocalizerFactory = stringLocalizerFactory; + _options = options.Value; + } - public string GetLocalizedText(string text, ModelExplorer explorer) - { - var localizer = GetLocalizerOrNull(explorer); - return localizer == null - ? text - : localizer[text].Value; - } + public string GetLocalizedText(string text, ModelExplorer explorer) + { + var localizer = GetLocalizerOrNull(explorer); + return localizer == null + ? text + : localizer[text].Value; + } - public IStringLocalizer GetLocalizerOrNull(ModelExplorer explorer) - { - return GetLocalizerOrNull(explorer.Container.ModelType.Assembly); - } + public IStringLocalizer GetLocalizerOrNull(ModelExplorer explorer) + { + return GetLocalizerOrNull(explorer.Container.ModelType.Assembly); + } - public IStringLocalizer GetLocalizerOrNull(Assembly assembly) - { - var resourceType = GetResourceType(assembly); - return resourceType == null - ? _stringLocalizerFactory.CreateDefaultOrNull() - : _stringLocalizerFactory.Create(resourceType); - } + public IStringLocalizer GetLocalizerOrNull(Assembly assembly) + { + var resourceType = GetResourceType(assembly); + return resourceType == null + ? _stringLocalizerFactory.CreateDefaultOrNull() + : _stringLocalizerFactory.Create(resourceType); + } - private Type GetResourceType(Assembly assembly) - { - return _options - .AssemblyResources - .GetOrDefault(assembly); - } + private Type GetResourceType(Assembly assembly) + { + return _options + .AssemblyResources + .GetOrDefault(assembly); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs index b53b2b4d56..b9c3aa92e6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/AbpTagHelperService.cs @@ -1,46 +1,45 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; + +//TODO: Refactor this class, extract bootstrap functionality! +public abstract class AbpTagHelperService : IAbpTagHelperService + where TTagHelper : TagHelper { - //TODO: Refactor this class, extract bootstrap functionality! - public abstract class AbpTagHelperService : IAbpTagHelperService - where TTagHelper : TagHelper + protected const string FormGroupContents = "FormGroupContents"; + protected const string TabItems = "TabItems"; + protected const string AccordionItems = "AccordionItems"; + protected const string BreadcrumbItemsContent = "BreadcrumbItemsContent"; + protected const string CarouselItemsContent = "CarouselItemsContent"; + protected const string TabItemsDataTogglePlaceHolder = "{_data_toggle_Placeholder_}"; + protected const string TabItemNamePlaceHolder = "{_Tab_Tag_Name_Placeholder_}"; + protected const string AbpFormContentPlaceHolder = "{_AbpFormContentPlaceHolder_}"; + protected const string AbpTabItemActivePlaceholder = "{_Tab_Active_Placeholder_}"; + protected const string AbpTabDropdownItemsActivePlaceholder = "{_Tab_DropDown_Items_Placeholder_}"; + protected const string AbpTabItemShowActivePlaceholder = "{_Tab_Show_Active_Placeholder_}"; + protected const string AbpBreadcrumbItemActivePlaceholder = "{_Breadcrumb_Active_Placeholder_}"; + protected const string AbpCarouselItemActivePlaceholder = "{_CarouselItem_Active_Placeholder_}"; + protected const string AbpTabItemSelectedPlaceholder = "{_Tab_Selected_Placeholder_}"; + protected const string AbpAccordionParentIdPlaceholder = "{_Parent_Accordion_Id_}"; + + public TTagHelper TagHelper { get; internal set; } + + public virtual int Order { get; } + + public virtual void Init(TagHelperContext context) + { + + } + + public virtual void Process(TagHelperContext context, TagHelperOutput output) + { + + } + + public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - protected const string FormGroupContents = "FormGroupContents"; - protected const string TabItems = "TabItems"; - protected const string AccordionItems = "AccordionItems"; - protected const string BreadcrumbItemsContent = "BreadcrumbItemsContent"; - protected const string CarouselItemsContent = "CarouselItemsContent"; - protected const string TabItemsDataTogglePlaceHolder = "{_data_toggle_Placeholder_}"; - protected const string TabItemNamePlaceHolder = "{_Tab_Tag_Name_Placeholder_}"; - protected const string AbpFormContentPlaceHolder = "{_AbpFormContentPlaceHolder_}"; - protected const string AbpTabItemActivePlaceholder = "{_Tab_Active_Placeholder_}"; - protected const string AbpTabDropdownItemsActivePlaceholder = "{_Tab_DropDown_Items_Placeholder_}"; - protected const string AbpTabItemShowActivePlaceholder = "{_Tab_Show_Active_Placeholder_}"; - protected const string AbpBreadcrumbItemActivePlaceholder = "{_Breadcrumb_Active_Placeholder_}"; - protected const string AbpCarouselItemActivePlaceholder = "{_CarouselItem_Active_Placeholder_}"; - protected const string AbpTabItemSelectedPlaceholder = "{_Tab_Selected_Placeholder_}"; - protected const string AbpAccordionParentIdPlaceholder = "{_Parent_Accordion_Id_}"; - - public TTagHelper TagHelper { get; internal set; } - - public virtual int Order { get; } - - public virtual void Init(TagHelperContext context) - { - - } - - public virtual void Process(TagHelperContext context, TagHelperOutput output) - { - - } - - public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - Process(context, output); - return Task.CompletedTask; - } + Process(context, output); + return Task.CompletedTask; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelper.cs index b32acb7b1b..d86ef557fa 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelper.cs @@ -1,19 +1,18 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert; + +[HtmlTargetElement("h1", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] +[HtmlTargetElement("h2", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] +[HtmlTargetElement("h3", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] +[HtmlTargetElement("h4", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] +[HtmlTargetElement("h5", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] +[HtmlTargetElement("h6", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] +public class AbpAlertHeaderTagHelper : AbpTagHelper { - [HtmlTargetElement("h1", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] - [HtmlTargetElement("h2", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] - [HtmlTargetElement("h3", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] - [HtmlTargetElement("h4", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] - [HtmlTargetElement("h5", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] - [HtmlTargetElement("h6", ParentTag = "abp-alert", TagStructure = TagStructure.NormalOrSelfClosing)] - public class AbpAlertHeaderTagHelper : AbpTagHelper + public AbpAlertHeaderTagHelper(AbpAlertHeaderTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpAlertHeaderTagHelper(AbpAlertHeaderTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelperService.cs index 1e3b9e7c2a..46d3bbf5ef 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertHeaderTagHelperService.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert; + +public class AbpAlertHeaderTagHelperService : AbpTagHelperService { - public class AbpAlertHeaderTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("alert-heading"); - } + output.Attributes.AddClass("alert-heading"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelper.cs index 17e9a335b9..af659ac401 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelper.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert; + +[HtmlTargetElement("a", Attributes = "abp-alert-link", TagStructure = TagStructure.NormalOrSelfClosing)] +public class AbpAlertLinkTagHelper : AbpTagHelper { - [HtmlTargetElement("a", Attributes = "abp-alert-link", TagStructure = TagStructure.NormalOrSelfClosing)] - public class AbpAlertLinkTagHelper : AbpTagHelper + public AbpAlertLinkTagHelper(AbpAlertLinkTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpAlertLinkTagHelper(AbpAlertLinkTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelperService.cs index 79372688c3..40746eac6c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertLinkTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert; + +public class AbpAlertLinkTagHelperService : AbpTagHelperService { - public class AbpAlertLinkTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("alert-link"); - output.Attributes.RemoveAll("abp-alert-link"); - } + output.Attributes.AddClass("alert-link"); + output.Attributes.RemoveAll("abp-alert-link"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelper.cs index f4d0c33ced..19728a99b3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelper.cs @@ -1,17 +1,16 @@ using Volo.Abp.AspNetCore.Mvc.UI.Alerts; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert; + +public class AbpAlertTagHelper : AbpTagHelper { - public class AbpAlertTagHelper : AbpTagHelper - { - public AlertType AlertType { get; set; } = AlertType.Default; + public AlertType AlertType { get; set; } = AlertType.Default; - public bool? Dismissible { get; set; } + public bool? Dismissible { get; set; } - public AbpAlertTagHelper(AbpAlertTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpAlertTagHelper(AbpAlertTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelperService.cs index a8d2342978..6d465f4bb4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Alert/AbpAlertTagHelperService.cs @@ -3,48 +3,47 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Alerts; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert; + +public class AbpAlertTagHelperService : AbpTagHelperService { - public class AbpAlertTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.TagMode = TagMode.StartTagAndEndTag; + output.TagName = "div"; + output.TagMode = TagMode.StartTagAndEndTag; + + AddClasses(context, output); + AddDismissButtonIfDismissible(context, output); + } + + protected virtual void AddClasses(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.Add("role", "alert"); + output.Attributes.AddClass("alert"); - AddClasses(context, output); - AddDismissButtonIfDismissible(context, output); + if (TagHelper.AlertType != AlertType.Default) + { + output.Attributes.AddClass("alert-" + TagHelper.AlertType.ToString().ToLowerInvariant()); } - protected virtual void AddClasses(TagHelperContext context, TagHelperOutput output) + if (TagHelper.Dismissible ?? false) { - output.Attributes.Add("role", "alert"); - output.Attributes.AddClass("alert"); - - if (TagHelper.AlertType != AlertType.Default) - { - output.Attributes.AddClass("alert-" + TagHelper.AlertType.ToString().ToLowerInvariant()); - } - - if (TagHelper.Dismissible ?? false) - { - output.Attributes.AddClass("alert-dismissible"); - output.Attributes.AddClass("fade"); - output.Attributes.AddClass("show"); - } + output.Attributes.AddClass("alert-dismissible"); + output.Attributes.AddClass("fade"); + output.Attributes.AddClass("show"); } + } - protected virtual void AddDismissButtonIfDismissible(TagHelperContext context, TagHelperOutput output) + protected virtual void AddDismissButtonIfDismissible(TagHelperContext context, TagHelperOutput output) + { + if (!TagHelper.Dismissible ?? true) { - if (!TagHelper.Dismissible ?? true) - { - return; - } + return; + } - var buttonAsHtml = - ""; + var buttonAsHtml = + ""; - output.PostContent.SetHtmlContent(buttonAsHtml); - } + output.PostContent.SetHtmlContent(buttonAsHtml); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelper.cs index bfb83f7363..82da24d088 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelper.cs @@ -1,24 +1,22 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Badge -{ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Badge; - [HtmlTargetElement("a", Attributes = "abp-badge")] - [HtmlTargetElement("span", Attributes = "abp-badge")] - [HtmlTargetElement("a", Attributes = "abp-badge-pill")] - [HtmlTargetElement("span", Attributes = "abp-badge-pill")] - public class AbpBadgeTagHelper : AbpTagHelper - { - [HtmlAttributeName("abp-badge")] - public AbpBadgeType BadgeType { get; set; } = AbpBadgeType._; +[HtmlTargetElement("a", Attributes = "abp-badge")] +[HtmlTargetElement("span", Attributes = "abp-badge")] +[HtmlTargetElement("a", Attributes = "abp-badge-pill")] +[HtmlTargetElement("span", Attributes = "abp-badge-pill")] +public class AbpBadgeTagHelper : AbpTagHelper +{ + [HtmlAttributeName("abp-badge")] + public AbpBadgeType BadgeType { get; set; } = AbpBadgeType._; - [HtmlAttributeName("abp-badge-pill")] - public AbpBadgeType BadgePillType { get; set; } = AbpBadgeType._; + [HtmlAttributeName("abp-badge-pill")] + public AbpBadgeType BadgePillType { get; set; } = AbpBadgeType._; - public AbpBadgeTagHelper(AbpBadgeTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpBadgeTagHelper(AbpBadgeTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelperService.cs index 14aeefeb25..384b7383ec 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeTagHelperService.cs @@ -1,39 +1,38 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Badge +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Badge; + +public class AbpBadgeTagHelperService : AbpTagHelperService { - public class AbpBadgeTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - SetBadgeClass(context, output); - SetBadgeStyle(context, output); - } - - protected virtual void SetBadgeStyle(TagHelperContext context, TagHelperOutput output) - { - var badgeType = GetBadgeType(context, output); + SetBadgeClass(context, output); + SetBadgeStyle(context, output); + } - if (badgeType != AbpBadgeType.Default && badgeType != AbpBadgeType._) - { - output.Attributes.AddClass("bg-" + badgeType.ToString().ToLowerInvariant()); - } - } + protected virtual void SetBadgeStyle(TagHelperContext context, TagHelperOutput output) + { + var badgeType = GetBadgeType(context, output); - protected virtual void SetBadgeClass(TagHelperContext context, TagHelperOutput output) + if (badgeType != AbpBadgeType.Default && badgeType != AbpBadgeType._) { - output.Attributes.AddClass("badge"); - - if (TagHelper.BadgePillType != AbpBadgeType._) - { - output.Attributes.AddClass("rounded-pill"); - } + output.Attributes.AddClass("bg-" + badgeType.ToString().ToLowerInvariant()); } + } + + protected virtual void SetBadgeClass(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.AddClass("badge"); - protected virtual AbpBadgeType GetBadgeType(TagHelperContext context, TagHelperOutput output) + if (TagHelper.BadgePillType != AbpBadgeType._) { - return TagHelper.BadgeType != AbpBadgeType._ ? TagHelper.BadgeType : TagHelper.BadgePillType; + output.Attributes.AddClass("rounded-pill"); } } + + protected virtual AbpBadgeType GetBadgeType(TagHelperContext context, TagHelperOutput output) + { + return TagHelper.BadgeType != AbpBadgeType._ ? TagHelper.BadgeType : TagHelper.BadgePillType; + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeType.cs index ffc78d377a..77dafac397 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Badge/AbpBadgeType.cs @@ -1,16 +1,15 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Badge +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Badge; + +public enum AbpBadgeType { - public enum AbpBadgeType - { - _, - Default, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark - } -} \ No newline at end of file + _, + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelper.cs index d4619390ef..ac3a6342c5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelper.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote; + +[HtmlTargetElement("footer", ParentTag = "blockquote")] +public class AbpBlockquoteFooterTagHelper : AbpTagHelper { - [HtmlTargetElement("footer", ParentTag = "blockquote")] - public class AbpBlockquoteFooterTagHelper : AbpTagHelper + public AbpBlockquoteFooterTagHelper(AbpBlockquoteFooterTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpBlockquoteFooterTagHelper(AbpBlockquoteFooterTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelperService.cs index 6280f5de99..55d9d0673e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteFooterTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote; + +public class AbpBlockquoteFooterTagHelperService : AbpTagHelperService { - public class AbpBlockquoteFooterTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("blockquote-footer"); - } - + output.Attributes.AddClass("blockquote-footer"); } -} \ No newline at end of file + +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelper.cs index 0e915f2a36..8734cc52e8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelper.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote; + +[HtmlTargetElement("p", ParentTag = "blockquote")] +public class AbpBlockquoteParagraphTagHelper : AbpTagHelper { - [HtmlTargetElement("p", ParentTag = "blockquote")] - public class AbpBlockquoteParagraphTagHelper : AbpTagHelper + public AbpBlockquoteParagraphTagHelper(AbpBlockquoteParagraphTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpBlockquoteParagraphTagHelper(AbpBlockquoteParagraphTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelperService.cs index d3ce37cbc5..513cee7833 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteParagraphTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote; + +public class AbpBlockquoteParagraphTagHelperService : AbpTagHelperService { - public class AbpBlockquoteParagraphTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("mb-0"); - } - + output.Attributes.AddClass("mb-0"); } -} \ No newline at end of file + +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelper.cs index 74e2a10e2d..72835b53e0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote; + +public class AbpBlockquoteTagHelper : AbpTagHelper { - public class AbpBlockquoteTagHelper : AbpTagHelper + public AbpBlockquoteTagHelper(AbpBlockquoteTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpBlockquoteTagHelper(AbpBlockquoteTagHelperService tagHelperService) - : base(tagHelperService) - { - - } + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelperService.cs index 6c26747d11..53fa7b0b5d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Blockquote/AbpBlockquoteTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Blockquote; + +public class AbpBlockquoteTagHelperService : AbpTagHelperService { - public class AbpBlockquoteTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("blockquote"); - output.TagName = "blockquote"; - } + output.Attributes.AddClass("blockquote"); + output.TagName = "blockquote"; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelper.cs index bc7a6f9829..f701ca4c2d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelper.cs @@ -1,16 +1,15 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border; + +[HtmlTargetElement(Attributes = "abp-border")] +public class AbpBorderTagHelper : AbpTagHelper { - [HtmlTargetElement(Attributes = "abp-border")] - public class AbpBorderTagHelper : AbpTagHelper - { - public AbpBorderType AbpBorder { get; set; } = AbpBorderType.Default; + public AbpBorderType AbpBorder { get; set; } = AbpBorderType.Default; - public AbpBorderTagHelper(AbpBorderTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpBorderTagHelper(AbpBorderTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelperService.cs index 3bf4bc16d4..f8446a493d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderTagHelperService.cs @@ -1,91 +1,90 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border; + +public class AbpBorderTagHelperService : AbpTagHelperService { - public class AbpBorderTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - var borderAttributeAsString = TagHelper.AbpBorder.ToString().ToLowerInvariant(); + var borderAttributeAsString = TagHelper.AbpBorder.ToString().ToLowerInvariant(); - var borderClass = "border" + GetBorderDirection(context, output, borderAttributeAsString) + GetExtensionIfBorderIsSubtractive(context, output, borderAttributeAsString); + var borderClass = "border" + GetBorderDirection(context, output, borderAttributeAsString) + GetExtensionIfBorderIsSubtractive(context, output, borderAttributeAsString); - output.Attributes.AddClass(borderClass); + output.Attributes.AddClass(borderClass); - SetBorderType(context, output, borderAttributeAsString); - } + SetBorderType(context, output, borderAttributeAsString); + } - protected virtual string GetBorderDirection(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) + protected virtual string GetBorderDirection(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) + { + if (borderAttributeAsString.Contains("top")) { - if (borderAttributeAsString.Contains("top")) - { - return "-top"; - } - if (borderAttributeAsString.Contains("right")) - { - return "-right"; - } - if (borderAttributeAsString.Contains("left")) - { - return "-left"; - } - if (borderAttributeAsString.Contains("bottom")) - { - return "-bottom"; - } - - return ""; + return "-top"; } - - protected virtual string GetExtensionIfBorderIsSubtractive(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) + if (borderAttributeAsString.Contains("right")) + { + return "-right"; + } + if (borderAttributeAsString.Contains("left")) { - if (borderAttributeAsString.Contains("_0")) - { - return "-0"; - } + return "-left"; + } + if (borderAttributeAsString.Contains("bottom")) + { + return "-bottom"; + } + + return ""; + } - return ""; + protected virtual string GetExtensionIfBorderIsSubtractive(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) + { + if (borderAttributeAsString.Contains("_0")) + { + return "-0"; } - protected virtual void SetBorderType(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) + return ""; + } + + protected virtual void SetBorderType(TagHelperContext context, TagHelperOutput output, string borderAttributeAsString) + { + if (borderAttributeAsString.Contains("primary")) + { + output.Attributes.AddClass("border-primary"); + } + if (borderAttributeAsString.Contains("secondary")) + { + output.Attributes.AddClass("border-secondary"); + } + if (borderAttributeAsString.Contains("success")) + { + output.Attributes.AddClass("border-success"); + } + if (borderAttributeAsString.Contains("danger")) + { + output.Attributes.AddClass("border-danger"); + } + if (borderAttributeAsString.Contains("warning")) + { + output.Attributes.AddClass("border-warning"); + } + if (borderAttributeAsString.Contains("info")) + { + output.Attributes.AddClass("border-info"); + } + if (borderAttributeAsString.Contains("light")) + { + output.Attributes.AddClass("border-light"); + } + if (borderAttributeAsString.Contains("dark")) + { + output.Attributes.AddClass("border-dark"); + } + if (borderAttributeAsString.Contains("white")) { - if (borderAttributeAsString.Contains("primary")) - { - output.Attributes.AddClass("border-primary"); - } - if (borderAttributeAsString.Contains("secondary")) - { - output.Attributes.AddClass("border-secondary"); - } - if (borderAttributeAsString.Contains("success")) - { - output.Attributes.AddClass("border-success"); - } - if (borderAttributeAsString.Contains("danger")) - { - output.Attributes.AddClass("border-danger"); - } - if (borderAttributeAsString.Contains("warning")) - { - output.Attributes.AddClass("border-warning"); - } - if (borderAttributeAsString.Contains("info")) - { - output.Attributes.AddClass("border-info"); - } - if (borderAttributeAsString.Contains("light")) - { - output.Attributes.AddClass("border-light"); - } - if (borderAttributeAsString.Contains("dark")) - { - output.Attributes.AddClass("border-dark"); - } - if (borderAttributeAsString.Contains("white")) - { - output.Attributes.AddClass("border-white"); - } + output.Attributes.AddClass("border-white"); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderType.cs index 14b1684876..c59780971b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpBorderType.cs @@ -1,106 +1,105 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border; + +public enum AbpBorderType { - public enum AbpBorderType - { - Default, - _0, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark, - White, - Primary_0, - Secondary_0, - Success_0, - Danger_0, - Warning_0, - Info_0, - Light_0, - Dark_0, - White_0, - Top, - Top_0, - Top_Primary, - Top_Secondary, - Top_Success, - Top_Danger, - Top_Warning, - Top_Info, - Top_Light, - Top_Dark, - Top_White, - Top_Primary_0, - Top_Secondary_0, - Top_Success_0, - Top_Danger_0, - Top_Warning_0, - Top_Info_0, - Top_Light_0, - Top_Dark_0, - Top_White_0, - Right, - Right_0, - Right_Primary, - Right_Secondary, - Right_Success, - Right_Danger, - Right_Warning, - Right_Info, - Right_Light, - Right_Dark, - Right_White, - Right_Primary_0, - Right_Secondary_0, - Right_Success_0, - Right_Danger_0, - Right_Warning_0, - Right_Info_0, - Right_Light_0, - Right_Dark_0, - Right_White_0, - Left, - Left_0, - Left_Primary, - Left_Secondary, - Left_Success, - Left_Danger, - Left_Warning, - Left_Info, - Left_Light, - Left_Dark, - Left_White, - Left_Primary_0, - Left_Secondary_0, - Left_Success_0, - Left_Danger_0, - Left_Warning_0, - Left_Info_0, - Left_Light_0, - Left_Dark_0, - Left_White_0, - Bottom, - Bottom_0, - Bottom_Primary, - Bottom_Secondary, - Bottom_Success, - Bottom_Danger, - Bottom_Warning, - Bottom_Info, - Bottom_Light, - Bottom_Dark, - Bottom_White, - Bottom_Primary_0, - Bottom_Secondary_0, - Bottom_Success_0, - Bottom_Danger_0, - Bottom_Warning_0, - Bottom_Info_0, - Bottom_Light_0, - Bottom_Dark_0, - Bottom_White_0, - } -} \ No newline at end of file + Default, + _0, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark, + White, + Primary_0, + Secondary_0, + Success_0, + Danger_0, + Warning_0, + Info_0, + Light_0, + Dark_0, + White_0, + Top, + Top_0, + Top_Primary, + Top_Secondary, + Top_Success, + Top_Danger, + Top_Warning, + Top_Info, + Top_Light, + Top_Dark, + Top_White, + Top_Primary_0, + Top_Secondary_0, + Top_Success_0, + Top_Danger_0, + Top_Warning_0, + Top_Info_0, + Top_Light_0, + Top_Dark_0, + Top_White_0, + Right, + Right_0, + Right_Primary, + Right_Secondary, + Right_Success, + Right_Danger, + Right_Warning, + Right_Info, + Right_Light, + Right_Dark, + Right_White, + Right_Primary_0, + Right_Secondary_0, + Right_Success_0, + Right_Danger_0, + Right_Warning_0, + Right_Info_0, + Right_Light_0, + Right_Dark_0, + Right_White_0, + Left, + Left_0, + Left_Primary, + Left_Secondary, + Left_Success, + Left_Danger, + Left_Warning, + Left_Info, + Left_Light, + Left_Dark, + Left_White, + Left_Primary_0, + Left_Secondary_0, + Left_Success_0, + Left_Danger_0, + Left_Warning_0, + Left_Info_0, + Left_Light_0, + Left_Dark_0, + Left_White_0, + Bottom, + Bottom_0, + Bottom_Primary, + Bottom_Secondary, + Bottom_Success, + Bottom_Danger, + Bottom_Warning, + Bottom_Info, + Bottom_Light, + Bottom_Dark, + Bottom_White, + Bottom_Primary_0, + Bottom_Secondary_0, + Bottom_Success_0, + Bottom_Danger_0, + Bottom_Warning_0, + Bottom_Info_0, + Bottom_Light_0, + Bottom_Dark_0, + Bottom_White_0, +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelper.cs index f8c3489cc9..6dc0ecd305 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelper.cs @@ -1,16 +1,15 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border; + +[HtmlTargetElement(Attributes = "abp-rounded")] +public class AbpRoundedTagHelper : AbpTagHelper { - [HtmlTargetElement(Attributes = "abp-rounded")] - public class AbpRoundedTagHelper : AbpTagHelper - { - public AbpRoundedType AbpRounded { get; set; } = AbpRoundedType.Default; + public AbpRoundedType AbpRounded { get; set; } = AbpRoundedType.Default; - public AbpRoundedTagHelper(AbpRoundedTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpRoundedTagHelper(AbpRoundedTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelperService.cs index 89436785ba..798380e411 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedTagHelperService.cs @@ -1,20 +1,19 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border; + +public class AbpRoundedTagHelperService : AbpTagHelperService { - public class AbpRoundedTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - var roundedClass = "rounded"; - - if (TagHelper.AbpRounded != AbpRoundedType.Default) - { - roundedClass += "-" + TagHelper.AbpRounded.ToString().ToLowerInvariant().Replace("_",""); - } + var roundedClass = "rounded"; - output.Attributes.AddClass(roundedClass); + if (TagHelper.AbpRounded != AbpRoundedType.Default) + { + roundedClass += "-" + TagHelper.AbpRounded.ToString().ToLowerInvariant().Replace("_", ""); } + + output.Attributes.AddClass(roundedClass); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedType.cs index 1910ffc714..ab4620f0f5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Border/AbpRoundedType.cs @@ -1,12 +1,11 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Border; + +public enum AbpRoundedType { - public enum AbpRoundedType - { - Default, - _0, - Top, - Right, - Left, - Bottom - } -} \ No newline at end of file + Default, + _0, + Top, + Right, + Left, + Bottom +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelper.cs index e27781479f..71ce3406fa 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelper.cs @@ -1,17 +1,16 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb; + +public class AbpBreadcrumbItemTagHelper : AbpTagHelper { - public class AbpBreadcrumbItemTagHelper : AbpTagHelper - { - public string Href { get; set; } + public string Href { get; set; } - public string Title { get; set; } + public string Title { get; set; } - public bool Active { get; set; } + public bool Active { get; set; } - public AbpBreadcrumbItemTagHelper(AbpBreadcrumbItemTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpBreadcrumbItemTagHelper(AbpBreadcrumbItemTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelperService.cs index 3fa8a27472..9935b90903 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbItemTagHelperService.cs @@ -5,49 +5,48 @@ using System.Text.Encodings.Web; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb; + +public class AbpBreadcrumbItemTagHelperService : AbpTagHelperService { - public class AbpBreadcrumbItemTagHelperService : AbpTagHelperService - { - private readonly HtmlEncoder _encoder; + private readonly HtmlEncoder _encoder; - public AbpBreadcrumbItemTagHelperService(HtmlEncoder encoder) - { - _encoder = encoder; - } + public AbpBreadcrumbItemTagHelperService(HtmlEncoder encoder) + { + _encoder = encoder; + } - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "li"; - output.TagMode = TagMode.StartTagAndEndTag; - output.Attributes.AddClass("breadcrumb-item"); - output.Attributes.AddClass(AbpBreadcrumbItemActivePlaceholder); + public override void Process(TagHelperContext context, TagHelperOutput output) + { + output.TagName = "li"; + output.TagMode = TagMode.StartTagAndEndTag; + output.Attributes.AddClass("breadcrumb-item"); + output.Attributes.AddClass(AbpBreadcrumbItemActivePlaceholder); - var list = context.GetValue>(BreadcrumbItemsContent); + var list = context.GetValue>(BreadcrumbItemsContent); - output.Content.SetHtmlContent(GetInnerHtml(context, output)); + output.Content.SetHtmlContent(GetInnerHtml(context, output)); - list.Add(new BreadcrumbItem - { - Html = output.Render(_encoder), - Active = TagHelper.Active - }); + list.Add(new BreadcrumbItem + { + Html = output.Render(_encoder), + Active = TagHelper.Active + }); - output.SuppressOutput(); - } + output.SuppressOutput(); + } - protected virtual string GetInnerHtml(TagHelperContext context, TagHelperOutput output) + protected virtual string GetInnerHtml(TagHelperContext context, TagHelperOutput output) + { + if (string.IsNullOrWhiteSpace(TagHelper.Href)) { - if (string.IsNullOrWhiteSpace(TagHelper.Href)) - { - output.Attributes.Add("aria-current", "page"); - return _encoder.Encode(TagHelper.Title); - } - - var link = new TagBuilder("a"); - link.Attributes.Add("href", TagHelper.Href); - link.InnerHtml.AppendHtml(TagHelper.Title); - return link.ToHtmlString(); + output.Attributes.Add("aria-current", "page"); + return _encoder.Encode(TagHelper.Title); } + + var link = new TagBuilder("a"); + link.Attributes.Add("href", TagHelper.Href); + link.InnerHtml.AppendHtml(TagHelper.Title); + return link.ToHtmlString(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelper.cs index a207d46a49..cdb9f29741 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb; + +public class AbpBreadcrumbTagHelper : AbpTagHelper { - public class AbpBreadcrumbTagHelper : AbpTagHelper + public AbpBreadcrumbTagHelper(AbpBreadcrumbTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpBreadcrumbTagHelper(AbpBreadcrumbTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } 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 4b433ac495..a23dc6c294 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 @@ -4,66 +4,65 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb; + +public class AbpBreadcrumbTagHelperService : AbpTagHelperService { - public class AbpBreadcrumbTagHelperService : AbpTagHelperService + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "nav"; - output.Attributes.Add("aria-label", "breadcrumb"); - - var list = InitilizeFormGroupContentsContext(context, output); + output.TagName = "nav"; + output.Attributes.Add("aria-label", "breadcrumb"); - await output.GetChildContentAsync(); + var list = InitilizeFormGroupContentsContext(context, output); - var listTagBuilder = GetOlTagBuilder(); + await output.GetChildContentAsync(); - SetInnerList(context, output, list, listTagBuilder); + var listTagBuilder = GetOlTagBuilder(); - output.Content.SetHtmlContent(listTagBuilder); - } - - protected virtual TagBuilder GetOlTagBuilder() - { - var builder = new TagBuilder("ol"); - builder.AddCssClass("breadcrumb"); - return builder; - } + SetInnerList(context, output, list, listTagBuilder); - protected virtual void SetInnerList(TagHelperContext context, TagHelperOutput output, List list, TagBuilder listTagBuilder) - { - SetLastOneActiveIfThereIsNotAny(context, output, list); + output.Content.SetHtmlContent(listTagBuilder); + } - foreach (var breadcrumbItem in list) - { - var htmlPart = SetActiveClassIfActiveAndGetHtml(breadcrumbItem); + protected virtual TagBuilder GetOlTagBuilder() + { + var builder = new TagBuilder("ol"); + builder.AddCssClass("breadcrumb"); + return builder; + } - listTagBuilder.InnerHtml.AppendHtml(htmlPart); - } - } + protected virtual void SetInnerList(TagHelperContext context, TagHelperOutput output, List list, TagBuilder listTagBuilder) + { + SetLastOneActiveIfThereIsNotAny(context, output, list); - protected virtual List InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) + foreach (var breadcrumbItem in list) { - var items = new List(); - context.Items[BreadcrumbItemsContent] = items; - return items; - } + var htmlPart = SetActiveClassIfActiveAndGetHtml(breadcrumbItem); - protected virtual void SetLastOneActiveIfThereIsNotAny(TagHelperContext context, TagHelperOutput output, List list) - { - if (list.Count > 0 && !list.Any(bc => bc.Active)) - { - list.Last().Active = true; - } + listTagBuilder.InnerHtml.AppendHtml(htmlPart); } + } - protected virtual string SetActiveClassIfActiveAndGetHtml(BreadcrumbItem item) + protected virtual List InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) + { + var items = new List(); + context.Items[BreadcrumbItemsContent] = items; + return items; + } + + protected virtual void SetLastOneActiveIfThereIsNotAny(TagHelperContext context, TagHelperOutput output, List list) + { + if (list.Count > 0 && !list.Any(bc => bc.Active)) { - return item.Active ? - item.Html.Replace(AbpBreadcrumbItemActivePlaceholder, " active") : - item.Html.Replace(AbpBreadcrumbItemActivePlaceholder, ""); + list.Last().Active = true; } + } + protected virtual string SetActiveClassIfActiveAndGetHtml(BreadcrumbItem item) + { + return item.Active ? + item.Html.Replace(AbpBreadcrumbItemActivePlaceholder, " active") : + item.Html.Replace(AbpBreadcrumbItemActivePlaceholder, ""); } + } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/BreadcrumbItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/BreadcrumbItem.cs index 7f69abdfca..37a194b906 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/BreadcrumbItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/BreadcrumbItem.cs @@ -1,9 +1,8 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb; + +public class BreadcrumbItem { - public class BreadcrumbItem - { - public string Html { get; set; } + public string Html { get; set; } - public bool Active { get; set; } - } + public bool Active { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs index 53f3c3b6f9..9b4e42805d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupDirection.cs @@ -3,11 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public enum AbpButtonGroupDirection { - public enum AbpButtonGroupDirection - { - Horizontal, - Vertical - } + Horizontal, + Vertical } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs index 42635dd232..d54cdcea8c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupSize.cs @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public enum AbpButtonGroupSize { - public enum AbpButtonGroupSize - { - Default, - Small, - Medium, - Large - } + Default, + Small, + Medium, + Large } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs index b1958fc8af..cc48c96bf9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelper.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public class AbpButtonGroupTagHelper : AbpTagHelper { - public class AbpButtonGroupTagHelper : AbpTagHelper - { - public AbpButtonGroupDirection Direction { get; set; } = AbpButtonGroupDirection.Horizontal; + public AbpButtonGroupDirection Direction { get; set; } = AbpButtonGroupDirection.Horizontal; - public AbpButtonGroupSize Size { get; set; } = AbpButtonGroupSize.Default; + public AbpButtonGroupSize Size { get; set; } = AbpButtonGroupSize.Default; - public AbpButtonGroupTagHelper(AbpButtonGroupTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpButtonGroupTagHelper(AbpButtonGroupTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs index 3250fe6877..fb646e9941 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonGroupTagHelperService.cs @@ -2,56 +2,55 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public class AbpButtonGroupTagHelperService : AbpTagHelperService { - public class AbpButtonGroupTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - AddButtonGroupClass(context, output); - AddSizeClass(context, output); - AddAttributes(context, output); + AddButtonGroupClass(context, output); + AddSizeClass(context, output); + AddAttributes(context, output); - output.TagName = "div"; - } + output.TagName = "div"; + } - protected virtual void AddSizeClass(TagHelperContext context, TagHelperOutput output) + protected virtual void AddSizeClass(TagHelperContext context, TagHelperOutput output) + { + switch (TagHelper.Size) { - switch (TagHelper.Size) - { - case AbpButtonGroupSize.Default: - break; - case AbpButtonGroupSize.Small: - output.Attributes.AddClass("btn-group-sm"); - break; - case AbpButtonGroupSize.Medium: - output.Attributes.AddClass("btn-group-md"); - break; - case AbpButtonGroupSize.Large: - output.Attributes.AddClass("btn-group-lg"); - break; - } + case AbpButtonGroupSize.Default: + break; + case AbpButtonGroupSize.Small: + output.Attributes.AddClass("btn-group-sm"); + break; + case AbpButtonGroupSize.Medium: + output.Attributes.AddClass("btn-group-md"); + break; + case AbpButtonGroupSize.Large: + output.Attributes.AddClass("btn-group-lg"); + break; } + } - protected virtual void AddButtonGroupClass(TagHelperContext context, TagHelperOutput output) + protected virtual void AddButtonGroupClass(TagHelperContext context, TagHelperOutput output) + { + switch (TagHelper.Direction) { - switch (TagHelper.Direction) - { - case AbpButtonGroupDirection.Horizontal: - output.Attributes.AddClass("btn-group"); - break; - case AbpButtonGroupDirection.Vertical: - output.Attributes.AddClass("btn-group-vertical"); - break; - default: - output.Attributes.AddClass("btn-group"); - break; - } + case AbpButtonGroupDirection.Horizontal: + output.Attributes.AddClass("btn-group"); + break; + case AbpButtonGroupDirection.Vertical: + output.Attributes.AddClass("btn-group-vertical"); + break; + default: + output.Attributes.AddClass("btn-group"); + break; } + } - protected virtual void AddAttributes(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.Add("role", "group"); - } + protected virtual void AddAttributes(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.Add("role", "group"); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSize.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSize.cs index b3aae45f6d..96f7b27d1e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSize.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSize.cs @@ -1,20 +1,19 @@ using System; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public enum AbpButtonSize { - public enum AbpButtonSize - { - Default, - Small, - Medium, - Large, - [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] - Block, - [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] - Block_Small, - [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] - Block_Medium, - [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] - Block_Large, - } + Default, + Small, + Medium, + Large, + [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] + Block, + [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] + Block_Small, + [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] + Block_Medium, + [Obsolete("https://getbootstrap.com/docs/5.0/components/buttons/#block-buttons")] + Block_Large, } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSizeExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSizeExtensions.cs index 5927d06e43..bdd0de72f2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSizeExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonSizeExtensions.cs @@ -1,26 +1,25 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public static class AbpButtonSizeExtensions { - public static class AbpButtonSizeExtensions + public static string ToClassName(this AbpButtonSize size) { - public static string ToClassName(this AbpButtonSize size) + switch (size) { - switch (size) - { - case AbpButtonSize.Small: - case AbpButtonSize.Block_Small: - return "btn-sm"; - case AbpButtonSize.Medium: - case AbpButtonSize.Block_Medium: - return "btn-md"; - case AbpButtonSize.Large: - case AbpButtonSize.Block_Large: - return "btn-lg"; - case AbpButtonSize.Block: - case AbpButtonSize.Default: - return ""; - default: - throw new AbpException($"Unknown {nameof(AbpButtonSize)}: {size}"); - } + case AbpButtonSize.Small: + case AbpButtonSize.Block_Small: + return "btn-sm"; + case AbpButtonSize.Medium: + case AbpButtonSize.Block_Medium: + return "btn-md"; + case AbpButtonSize.Large: + case AbpButtonSize.Block_Large: + return "btn-lg"; + case AbpButtonSize.Block: + case AbpButtonSize.Default: + return ""; + default: + throw new AbpException($"Unknown {nameof(AbpButtonSize)}: {size}"); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelper.cs index f7ffa84c39..624d750274 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelper.cs @@ -1,31 +1,30 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +[HtmlTargetElement("abp-button", TagStructure = TagStructure.NormalOrSelfClosing)] +public class AbpButtonTagHelper : AbpTagHelper, IButtonTagHelperBase { - [HtmlTargetElement("abp-button", TagStructure = TagStructure.NormalOrSelfClosing)] - public class AbpButtonTagHelper : AbpTagHelper, IButtonTagHelperBase - { - public AbpButtonType ButtonType { get; set; } = AbpButtonType.Default; + public AbpButtonType ButtonType { get; set; } = AbpButtonType.Default; - public AbpButtonSize Size { get; set; } = AbpButtonSize.Default; + public AbpButtonSize Size { get; set; } = AbpButtonSize.Default; - public string BusyText { get; set; } + public string BusyText { get; set; } - public string Text { get; set; } + public string Text { get; set; } - public string Icon { get; set; } + public string Icon { get; set; } - public bool? Disabled { get; set; } + public bool? Disabled { get; set; } - public FontIconType IconType { get; set; } = FontIconType.FontAwesome; + public FontIconType IconType { get; set; } = FontIconType.FontAwesome; - public bool BusyTextIsHtml { get; set; } + public bool BusyTextIsHtml { get; set; } - public AbpButtonTagHelper(AbpButtonTagHelperService service) - : base(service) - { + public AbpButtonTagHelper(AbpButtonTagHelperService service) + : base(service) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperService.cs index fb74d5c1da..e5576332b3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperService.cs @@ -3,58 +3,57 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Localization; using System; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public class AbpButtonTagHelperService : AbpButtonTagHelperServiceBase { - public class AbpButtonTagHelperService : AbpButtonTagHelperServiceBase + protected const string DataBusyTextAttributeName = "data-busy-text"; + protected const string DataBusyTextIsHtmlAttributeName = "data-busy-text-is-html"; + + protected IStringLocalizer L { get; } + + public AbpButtonTagHelperService(IStringLocalizer localizer) { - protected const string DataBusyTextAttributeName = "data-busy-text"; - protected const string DataBusyTextIsHtmlAttributeName = "data-busy-text-is-html"; + L = localizer; + } - protected IStringLocalizer L { get; } + public override void Process(TagHelperContext context, TagHelperOutput output) + { + base.Process(context, output); + output.TagName = "button"; + AddType(context, output); + AddBusyText(context, output); + AddBusyTextIsHtml(context, output); + } - public AbpButtonTagHelperService(IStringLocalizer localizer) + protected virtual void AddType(TagHelperContext context, TagHelperOutput output) + { + if (output.Attributes.ContainsName("type")) { - L = localizer; + return; } - public override void Process(TagHelperContext context, TagHelperOutput output) - { - base.Process(context, output); - output.TagName = "button"; - AddType(context, output); - AddBusyText(context, output); - AddBusyTextIsHtml(context, output); - } + output.Attributes.Add("type", "button"); + } - protected virtual void AddType(TagHelperContext context, TagHelperOutput output) + protected virtual void AddBusyText(TagHelperContext context, TagHelperOutput output) + { + var busyText = TagHelper.BusyText ?? L["ProcessingWithThreeDot"]; + if (busyText.IsNullOrWhiteSpace()) { - if (output.Attributes.ContainsName("type")) - { - return; - } - - output.Attributes.Add("type", "button"); + return; } - protected virtual void AddBusyText(TagHelperContext context, TagHelperOutput output) - { - var busyText = TagHelper.BusyText ?? L["ProcessingWithThreeDot"]; - if (busyText.IsNullOrWhiteSpace()) - { - return; - } - - output.Attributes.SetAttribute(DataBusyTextAttributeName, busyText); - } + output.Attributes.SetAttribute(DataBusyTextAttributeName, busyText); + } - protected virtual void AddBusyTextIsHtml(TagHelperContext context, TagHelperOutput output) + protected virtual void AddBusyTextIsHtml(TagHelperContext context, TagHelperOutput output) + { + if (!TagHelper.BusyTextIsHtml) { - if (!TagHelper.BusyTextIsHtml) - { - return; - } - - output.Attributes.SetAttribute(DataBusyTextIsHtmlAttributeName, TagHelper.BusyTextIsHtml.ToString().ToLower()); + return; } + + output.Attributes.SetAttribute(DataBusyTextIsHtmlAttributeName, TagHelper.BusyTextIsHtml.ToString().ToLower()); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperServiceBase.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperServiceBase.cs index cb795bdc6c..17422327c8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperServiceBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonTagHelperServiceBase.cs @@ -3,82 +3,81 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using System; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public abstract class AbpButtonTagHelperServiceBase : AbpTagHelperService + where TTagHelper : TagHelper, IButtonTagHelperBase { - public abstract class AbpButtonTagHelperServiceBase : AbpTagHelperService - where TTagHelper : TagHelper, IButtonTagHelperBase + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - NormalizeTagMode(context, output); - AddClasses(context, output); - AddIcon(context, output); - AddText(context, output); - AddDisabled(context, output); - } + NormalizeTagMode(context, output); + AddClasses(context, output); + AddIcon(context, output); + AddText(context, output); + AddDisabled(context, output); + } + + protected virtual void NormalizeTagMode(TagHelperContext context, TagHelperOutput output) + { + output.TagMode = TagMode.StartTagAndEndTag; + } + + protected virtual void AddClasses(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.AddClass("btn"); - protected virtual void NormalizeTagMode(TagHelperContext context, TagHelperOutput output) + if (TagHelper.ButtonType != AbpButtonType.Default) { - output.TagMode = TagMode.StartTagAndEndTag; + output.Attributes.AddClass("btn-" + TagHelper.ButtonType.ToString().ToLowerInvariant().Replace("_", "-")); } - protected virtual void AddClasses(TagHelperContext context, TagHelperOutput output) + if (TagHelper.Size != AbpButtonSize.Default) { - output.Attributes.AddClass("btn"); - - if (TagHelper.ButtonType != AbpButtonType.Default) - { - output.Attributes.AddClass("btn-" + TagHelper.ButtonType.ToString().ToLowerInvariant().Replace("_","-")); - } - - if (TagHelper.Size != AbpButtonSize.Default) - { - output.Attributes.AddClass(TagHelper.Size.ToClassName()); - } + output.Attributes.AddClass(TagHelper.Size.ToClassName()); } + } - protected virtual void AddIcon(TagHelperContext context, TagHelperOutput output) + protected virtual void AddIcon(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Icon.IsNullOrWhiteSpace()) { - if (TagHelper.Icon.IsNullOrWhiteSpace()) - { - return; - } - - var icon = new TagBuilder("i"); - icon.AddCssClass(GetIconClass(context, output)); - output.Content.AppendHtml(icon); - output.Content.Append(" "); + return; } - protected virtual string GetIconClass(TagHelperContext context, TagHelperOutput output) + var icon = new TagBuilder("i"); + icon.AddCssClass(GetIconClass(context, output)); + output.Content.AppendHtml(icon); + output.Content.Append(" "); + } + + protected virtual string GetIconClass(TagHelperContext context, TagHelperOutput output) + { + switch (TagHelper.IconType) { - switch (TagHelper.IconType) - { - case FontIconType.FontAwesome: - return "fa fa-" + TagHelper.Icon; - default: - return TagHelper.Icon; - } + case FontIconType.FontAwesome: + return "fa fa-" + TagHelper.Icon; + default: + return TagHelper.Icon; } + } - protected virtual void AddText(TagHelperContext context, TagHelperOutput output) + protected virtual void AddText(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Text.IsNullOrWhiteSpace()) { - if (TagHelper.Text.IsNullOrWhiteSpace()) - { - return; - } - - var span = new TagBuilder("span"); - span.InnerHtml.AppendHtml(TagHelper.Text); - output.Content.AppendHtml(span); + return; } - protected virtual void AddDisabled(TagHelperContext context, TagHelperOutput output) + var span = new TagBuilder("span"); + span.InnerHtml.AppendHtml(TagHelper.Text); + output.Content.AppendHtml(span); + } + + protected virtual void AddDisabled(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Disabled ?? false) { - if (TagHelper.Disabled ?? false) - { - output.Attributes.Add("disabled", "disabled"); - } + output.Attributes.Add("disabled", "disabled"); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelper.cs index 7c716b88f8..afbd6bb53a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public class AbpButtonToolbarTagHelper : AbpTagHelper { - public class AbpButtonToolbarTagHelper : AbpTagHelper + public AbpButtonToolbarTagHelper(AbpButtonToolbarTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpButtonToolbarTagHelper(AbpButtonToolbarTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelperService.cs index 1581cc8bd3..6033621614 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonToolbarTagHelperService.cs @@ -1,15 +1,14 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public class AbpButtonToolbarTagHelperService : AbpTagHelperService { - public class AbpButtonToolbarTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("btn-toolbar"); - output.Attributes.Add("role","toolbar"); - } + output.TagName = "div"; + output.Attributes.AddClass("btn-toolbar"); + output.Attributes.Add("role", "toolbar"); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonType.cs index a6ced457e0..0e9990e683 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpButtonType.cs @@ -1,24 +1,23 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public enum AbpButtonType { - public enum AbpButtonType - { - Default, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark, - Outline_Primary, - Outline_Secondary, - Outline_Success, - Outline_Danger, - Outline_Warning, - Outline_Info, - Outline_Light, - Outline_Dark, - Link - } -} \ No newline at end of file + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark, + Outline_Primary, + Outline_Secondary, + Outline_Success, + Outline_Danger, + Outline_Warning, + Outline_Info, + Outline_Light, + Outline_Dark, + Link +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelper.cs index 9a553a1be5..bf3b4d8bac 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelper.cs @@ -1,28 +1,27 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +[HtmlTargetElement("a", Attributes = "abp-button", TagStructure = TagStructure.NormalOrSelfClosing)] +[HtmlTargetElement("input", Attributes = "abp-button", TagStructure = TagStructure.WithoutEndTag)] +public class AbpLinkButtonTagHelper : AbpTagHelper, IButtonTagHelperBase { - [HtmlTargetElement("a", Attributes = "abp-button", TagStructure = TagStructure.NormalOrSelfClosing)] - [HtmlTargetElement("input", Attributes = "abp-button", TagStructure = TagStructure.WithoutEndTag)] - public class AbpLinkButtonTagHelper : AbpTagHelper, IButtonTagHelperBase - { - [HtmlAttributeName("abp-button")] - public AbpButtonType ButtonType { get; set; } + [HtmlAttributeName("abp-button")] + public AbpButtonType ButtonType { get; set; } - public AbpButtonSize Size { get; set; } = AbpButtonSize.Default; + public AbpButtonSize Size { get; set; } = AbpButtonSize.Default; - public string Text { get; set; } + public string Text { get; set; } - public string Icon { get; set; } + public string Icon { get; set; } - public bool? Disabled { get; set; } + public bool? Disabled { get; set; } - public FontIconType IconType { get; } = FontIconType.FontAwesome; + public FontIconType IconType { get; } = FontIconType.FontAwesome; - public AbpLinkButtonTagHelper(AbpLinkButtonTagHelperService service) - : base(service) - { + public AbpLinkButtonTagHelper(AbpLinkButtonTagHelperService service) + : base(service) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelperService.cs index f92e2d5137..44dc996284 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/AbpLinkButtonTagHelperService.cs @@ -1,32 +1,31 @@ using System; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public class AbpLinkButtonTagHelperService : AbpButtonTagHelperServiceBase { - public class AbpLinkButtonTagHelperService : AbpButtonTagHelperServiceBase + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - base.Process(context, output); - AddType(context, output); - AddRole(context, output); - } + base.Process(context, output); + AddType(context, output); + AddRole(context, output); + } - protected virtual void AddType(TagHelperContext context, TagHelperOutput output) + protected virtual void AddType(TagHelperContext context, TagHelperOutput output) + { + if (!output.Attributes.ContainsName("type") && + output.TagName.Equals("input", StringComparison.InvariantCultureIgnoreCase)) { - if (!output.Attributes.ContainsName("type") && - output.TagName.Equals("input", StringComparison.InvariantCultureIgnoreCase)) - { - output.Attributes.Add("type", "button"); - } + output.Attributes.Add("type", "button"); } + } - protected virtual void AddRole(TagHelperContext context, TagHelperOutput output) + protected virtual void AddRole(TagHelperContext context, TagHelperOutput output) + { + if (!output.Attributes.ContainsName("role")) { - if (!output.Attributes.ContainsName("role")) - { - output.Attributes.Add("role", "button"); - } + output.Attributes.Add("role", "button"); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/IButtonTagHelperBase.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/IButtonTagHelperBase.cs index ee88c4d294..8ba73b2ab9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/IButtonTagHelperBase.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Button/IButtonTagHelperBase.cs @@ -1,17 +1,16 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; + +public interface IButtonTagHelperBase { - public interface IButtonTagHelperBase - { - AbpButtonType ButtonType { get; } + AbpButtonType ButtonType { get; } - AbpButtonSize Size { get; } + AbpButtonSize Size { get; } - string Text { get; } + string Text { get; } - string Icon { get; } + string Icon { get; } - bool? Disabled { get; } + bool? Disabled { get; } - FontIconType IconType { get; } - } -} \ No newline at end of file + FontIconType IconType { get; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelper.cs index 5e95e8bf87..9b4697c44a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelper.cs @@ -1,19 +1,18 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +[HtmlTargetElement("abp-card", Attributes = "background")] +[HtmlTargetElement("abp-card-header", Attributes = "background")] +[HtmlTargetElement("abp-card-body", Attributes = "background")] +[HtmlTargetElement("abp-card-footer", Attributes = "background")] +public class AbpCardBackgroundTagHelper : AbpTagHelper { - [HtmlTargetElement("abp-card", Attributes = "background")] - [HtmlTargetElement("abp-card-header", Attributes = "background")] - [HtmlTargetElement("abp-card-body", Attributes = "background")] - [HtmlTargetElement("abp-card-footer", Attributes = "background")] - public class AbpCardBackgroundTagHelper : AbpTagHelper - { - public AbpCardBackgroundType Background { get; set; } = AbpCardBackgroundType.Default; + public AbpCardBackgroundType Background { get; set; } = AbpCardBackgroundType.Default; - public AbpCardBackgroundTagHelper(AbpCardBackgroundTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCardBackgroundTagHelper(AbpCardBackgroundTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelperService.cs index 248d737648..af8e0bbf51 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundTagHelperService.cs @@ -1,23 +1,22 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardBackgroundTagHelperService : AbpTagHelperService { - public class AbpCardBackgroundTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - SetBackground(context, output); - } + SetBackground(context, output); + } - protected virtual void SetBackground(TagHelperContext context, TagHelperOutput output) + protected virtual void SetBackground(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Background == AbpCardBackgroundType.Default) { - if (TagHelper.Background == AbpCardBackgroundType.Default) - { - return; - } - - output.Attributes.AddClass("bg-" + TagHelper.Background.ToString().ToLowerInvariant()); + return; } + + output.Attributes.AddClass("bg-" + TagHelper.Background.ToString().ToLowerInvariant()); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundType.cs index 2eb9732ce8..da7aca4eec 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBackgroundType.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public enum AbpCardBackgroundType { - public enum AbpCardBackgroundType - { - Default, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark, - } + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark, } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelper.cs index b28b126cf2..34a14e6f33 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelper.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardBodyTagHelper : AbpTagHelper { - public class AbpCardBodyTagHelper : AbpTagHelper - { - public string Title { get; set; } + public string Title { get; set; } - public string Subtitle { get; set; } + public string Subtitle { get; set; } - public AbpCardBodyTagHelper(AbpCardBodyTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCardBodyTagHelper(AbpCardBodyTagHelperService tagHelperService) + : base(tagHelperService) + { - } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelperService.cs index 5707775a3a..172fa778b6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBodyTagHelperService.cs @@ -3,39 +3,38 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardBodyTagHelperService : AbpTagHelperService { - public class AbpCardBodyTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("card-body"); + output.TagName = "div"; + output.Attributes.AddClass("card-body"); - ProcessTitle(output); - ProcessSubtitle(output); - } + ProcessTitle(output); + ProcessSubtitle(output); + } - protected virtual void ProcessTitle(TagHelperOutput output) + protected virtual void ProcessTitle(TagHelperOutput output) + { + if (!TagHelper.Title.IsNullOrWhiteSpace()) { - if (!TagHelper.Title.IsNullOrWhiteSpace()) - { - var cardTitle = new TagBuilder(AbpCardTitleTagHelper.DefaultHeading.ToHtmlTag()); - cardTitle.AddCssClass("card-title"); - cardTitle.InnerHtml.AppendHtml(TagHelper.Title); - output.PreContent.AppendHtml(cardTitle); - } + var cardTitle = new TagBuilder(AbpCardTitleTagHelper.DefaultHeading.ToHtmlTag()); + cardTitle.AddCssClass("card-title"); + cardTitle.InnerHtml.AppendHtml(TagHelper.Title); + output.PreContent.AppendHtml(cardTitle); } + } - protected virtual void ProcessSubtitle(TagHelperOutput output) + protected virtual void ProcessSubtitle(TagHelperOutput output) + { + if (!TagHelper.Subtitle.IsNullOrWhiteSpace()) { - if (!TagHelper.Subtitle.IsNullOrWhiteSpace()) - { - var cardSubtitle = new TagBuilder(AbpCardSubtitleTagHelper.DefaultHeading.ToHtmlTag()); - cardSubtitle.AddCssClass("card-subtitle text-muted mb-2"); - cardSubtitle.InnerHtml.AppendHtml(TagHelper.Subtitle); - output.PreContent.AppendHtml(cardSubtitle); - } + var cardSubtitle = new TagBuilder(AbpCardSubtitleTagHelper.DefaultHeading.ToHtmlTag()); + cardSubtitle.AddCssClass("card-subtitle text-muted mb-2"); + cardSubtitle.InnerHtml.AppendHtml(TagHelper.Subtitle); + output.PreContent.AppendHtml(cardSubtitle); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBorderColorType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBorderColorType.cs index 0f5ccc3363..8da13ccbb8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBorderColorType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardBorderColorType.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public enum AbpCardBorderColorType { - public enum AbpCardBorderColorType - { - Default, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark, - } + Default, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark, } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelper.cs index 44b8588576..087c02320e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardFooterTagHelper : AbpTagHelper { - public class AbpCardFooterTagHelper : AbpTagHelper + public AbpCardFooterTagHelper(AbpCardFooterTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpCardFooterTagHelper(AbpCardFooterTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelperService.cs index 2a127a495b..abf4e71020 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardFooterTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardFooterTagHelperService : AbpTagHelperService { - public class AbpCardFooterTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("card-footer"); - output.TagName = "div"; - } + output.Attributes.AddClass("card-footer"); + output.TagName = "div"; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelper.cs index 0584d40ced..54d61cf61d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelper.cs @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardHeaderTagHelper : AbpTagHelper { - public class AbpCardHeaderTagHelper : AbpTagHelper + public AbpCardHeaderTagHelper(AbpCardHeaderTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpCardHeaderTagHelper(AbpCardHeaderTagHelperService tagHelperService) - : base(tagHelperService) - { - } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelperService.cs index 2f68196607..96e8f91a83 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardHeaderTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardHeaderTagHelperService : AbpTagHelperService { - public class AbpCardHeaderTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("card-header"); - } + output.TagName = "div"; + output.Attributes.AddClass("card-header"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePosition.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePosition.cs index b3396a513b..f101e44313 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePosition.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePosition.cs @@ -1,9 +1,8 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public enum AbpCardImagePosition { - public enum AbpCardImagePosition - { - None, - Top, - Bottom - } -} \ No newline at end of file + None, + Top, + Bottom +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePositionExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePositionExtensions.cs index 7a3f74449c..5ab3676651 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePositionExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImagePositionExtensions.cs @@ -1,20 +1,19 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public static class AbpCardImagePositionExtensions { - public static class AbpCardImagePositionExtensions + public static string ToClassName(this AbpCardImagePosition position) { - public static string ToClassName(this AbpCardImagePosition position) + switch (position) { - switch (position) - { - case AbpCardImagePosition.None: - return "card-img"; - case AbpCardImagePosition.Top: - return "card-img-top"; - case AbpCardImagePosition.Bottom: - return "card-img-bottom"; - default: - throw new AbpException("Unknown AbpCardImagePosition: " + position); - } + case AbpCardImagePosition.None: + return "card-img"; + case AbpCardImagePosition.Top: + return "card-img-top"; + case AbpCardImagePosition.Bottom: + return "card-img-bottom"; + default: + throw new AbpException("Unknown AbpCardImagePosition: " + position); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelper.cs index 4a173968d0..0610cfa150 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelper.cs @@ -1,18 +1,17 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +[HtmlTargetElement("img", Attributes = "abp-card-image", TagStructure = TagStructure.WithoutEndTag)] +[HtmlTargetElement("abp-image", Attributes = "abp-card-image", TagStructure = TagStructure.WithoutEndTag)] +public class AbpCardImageTagHelper : AbpTagHelper { - [HtmlTargetElement("img", Attributes = "abp-card-image", TagStructure = TagStructure.WithoutEndTag)] - [HtmlTargetElement("abp-image", Attributes = "abp-card-image", TagStructure = TagStructure.WithoutEndTag)] - public class AbpCardImageTagHelper : AbpTagHelper - { - [HtmlAttributeName("abp-card-image")] - public AbpCardImagePosition Position { get; set; } = AbpCardImagePosition.Top; + [HtmlAttributeName("abp-card-image")] + public AbpCardImagePosition Position { get; set; } = AbpCardImagePosition.Top; - public AbpCardImageTagHelper(AbpCardImageTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCardImageTagHelper(AbpCardImageTagHelperService tagHelperService) + : base(tagHelperService) + { - } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelperService.cs index 65cb8ff2bc..4d91cd30c9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardImageTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardImageTagHelperService : AbpTagHelperService { - public class AbpCardImageTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass(TagHelper.Position.ToClassName()); - output.Attributes.RemoveAll("abp-card-image"); - } + output.Attributes.AddClass(TagHelper.Position.ToClassName()); + output.Attributes.RemoveAll("abp-card-image"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelper.cs index 8f7f29bbb5..9626dd2bd4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelper.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +[HtmlTargetElement("a", Attributes = "abp-card-link")] +public class AbpCardLinkTagHelper : AbpTagHelper { - [HtmlTargetElement("a", Attributes = "abp-card-link")] - public class AbpCardLinkTagHelper : AbpTagHelper + public AbpCardLinkTagHelper(AbpCardLinkTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpCardLinkTagHelper(AbpCardLinkTagHelperService tagHelperService) - : base(tagHelperService) - { - - } + } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelperService.cs index 5cdba7cdba..d4dc775479 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardLinkTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardLinkTagHelperService : AbpTagHelperService { - public class AbpCardLinkTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("card-link"); - output.Attributes.RemoveAll("abp-card-link"); - } + output.Attributes.AddClass("card-link"); + output.Attributes.RemoveAll("abp-card-link"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelper.cs index cc6ef506dd..e740af2664 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelper.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardSubtitleTagHelper : AbpTagHelper { - public class AbpCardSubtitleTagHelper : AbpTagHelper - { - public static HtmlHeadingType DefaultHeading { get; set; } = HtmlHeadingType.H6; + public static HtmlHeadingType DefaultHeading { get; set; } = HtmlHeadingType.H6; - public HtmlHeadingType Heading { get; set; } = DefaultHeading; + public HtmlHeadingType Heading { get; set; } = DefaultHeading; - public AbpCardSubtitleTagHelper(AbpCardSubtitleTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCardSubtitleTagHelper(AbpCardSubtitleTagHelperService tagHelperService) + : base(tagHelperService) + { - } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelperService.cs index 8f9084d3bf..5710c81000 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardSubtitleTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardSubtitleTagHelperService : AbpTagHelperService { - public class AbpCardSubtitleTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = TagHelper.Heading.ToHtmlTag(); - output.Attributes.AddClass("card-subtitle"); - } + output.TagName = TagHelper.Heading.ToHtmlTag(); + output.Attributes.AddClass("card-subtitle"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelper.cs index c186e8857c..5b568e16a6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelper.cs @@ -1,12 +1,11 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTagHelper : AbpTagHelper { - public class AbpCardTagHelper : AbpTagHelper - { - public AbpCardBorderColorType Border { get; set; } = AbpCardBorderColorType.Default; + public AbpCardBorderColorType Border { get; set; } = AbpCardBorderColorType.Default; - public AbpCardTagHelper(AbpCardTagHelperService tagHelperService) - : base(tagHelperService) - { - } + public AbpCardTagHelper(AbpCardTagHelperService tagHelperService) + : base(tagHelperService) + { } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelperService.cs index 29a462797d..6169154904 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTagHelperService.cs @@ -1,25 +1,24 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTagHelperService : AbpTagHelperService { - public class AbpCardTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("card"); + output.TagName = "div"; + output.Attributes.AddClass("card"); - SetBorder(context, output); - } - protected virtual void SetBorder(TagHelperContext context, TagHelperOutput output) + SetBorder(context, output); + } + protected virtual void SetBorder(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Border == AbpCardBorderColorType.Default) { - if (TagHelper.Border == AbpCardBorderColorType.Default) - { - return; - } - - output.Attributes.AddClass("border-" + TagHelper.Border.ToString().ToLowerInvariant()); + return; } + + output.Attributes.AddClass("border-" + TagHelper.Border.ToString().ToLowerInvariant()); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelper.cs index f9787b1f18..45ddf9725a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelper.cs @@ -1,19 +1,18 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +[HtmlTargetElement("abp-card", Attributes = "text-color")] +[HtmlTargetElement("abp-card-header", Attributes = "text-color")] +[HtmlTargetElement("abp-card-body", Attributes = "text-color")] +[HtmlTargetElement("abp-card-footer", Attributes = "text-color")] +public class AbpCardTextColorTagHelper : AbpTagHelper { - [HtmlTargetElement("abp-card", Attributes = "text-color")] - [HtmlTargetElement("abp-card-header", Attributes = "text-color")] - [HtmlTargetElement("abp-card-body", Attributes = "text-color")] - [HtmlTargetElement("abp-card-footer", Attributes = "text-color")] - public class AbpCardTextColorTagHelper : AbpTagHelper - { - public AbpCardTextColorType TextColor { get; set; } = AbpCardTextColorType.Default; + public AbpCardTextColorType TextColor { get; set; } = AbpCardTextColorType.Default; - public AbpCardTextColorTagHelper(AbpCardTextColorTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCardTextColorTagHelper(AbpCardTextColorTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelperService.cs index 36484a33f8..04be1fa5bb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorTagHelperService.cs @@ -1,23 +1,22 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTextColorTagHelperService : AbpTagHelperService { - public class AbpCardTextColorTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - SetTextColor(context, output); - } + SetTextColor(context, output); + } - protected virtual void SetTextColor(TagHelperContext context, TagHelperOutput output) + protected virtual void SetTextColor(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.TextColor == AbpCardTextColorType.Default) { - if (TagHelper.TextColor == AbpCardTextColorType.Default) - { - return; - } - - output.Attributes.AddClass("text-" + TagHelper.TextColor.ToString().ToLowerInvariant()); + return; } + + output.Attributes.AddClass("text-" + TagHelper.TextColor.ToString().ToLowerInvariant()); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorType.cs index eb415945b0..45df26f761 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextColorType.cs @@ -1,16 +1,15 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public enum AbpCardTextColorType { - public enum AbpCardTextColorType - { - Default, - White, - Primary, - Secondary, - Success, - Danger, - Warning, - Info, - Light, - Dark - } + Default, + White, + Primary, + Secondary, + Success, + Danger, + Warning, + Info, + Light, + Dark } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelper.cs index 00e2468dfe..6cb434b17a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelper.cs @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTextTagHelper : AbpTagHelper { - public class AbpCardTextTagHelper : AbpTagHelper + public AbpCardTextTagHelper(AbpCardTextTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpCardTextTagHelper(AbpCardTextTagHelperService tagHelperService) - : base(tagHelperService) - { - } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelperService.cs index ba2d619126..41195ef966 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTextTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTextTagHelperService : AbpTagHelperService { - public class AbpCardTextTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "p"; - output.Attributes.AddClass("card-text"); - } + output.TagName = "p"; + output.Attributes.AddClass("card-text"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelper.cs index 410a64d76d..ba3b6a41e1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelper.cs @@ -1,14 +1,13 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTitleTagHelper : AbpTagHelper { - public class AbpCardTitleTagHelper : AbpTagHelper - { - public static HtmlHeadingType DefaultHeading { get; set; } = HtmlHeadingType.H5; + public static HtmlHeadingType DefaultHeading { get; set; } = HtmlHeadingType.H5; - public HtmlHeadingType Heading { get; set; } = DefaultHeading; + public HtmlHeadingType Heading { get; set; } = DefaultHeading; - public AbpCardTitleTagHelper(AbpCardTitleTagHelperService tagHelperService) - : base(tagHelperService) - { - } + public AbpCardTitleTagHelper(AbpCardTitleTagHelperService tagHelperService) + : base(tagHelperService) + { } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelperService.cs index 9ad27a49a0..2977fc42e9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Card/AbpCardTitleTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; + +public class AbpCardTitleTagHelperService : AbpTagHelperService { - public class AbpCardTitleTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = TagHelper.Heading.ToHtmlTag(); - output.Attributes.AddClass("card-title"); - } + output.TagName = TagHelper.Heading.ToHtmlTag(); + output.Attributes.AddClass("card-title"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelper.cs index e8e983b34a..65a47b73c4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelper.cs @@ -1,21 +1,20 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel; + +public class AbpCarouselItemTagHelper : AbpTagHelper { - public class AbpCarouselItemTagHelper : AbpTagHelper - { - public bool? Active { get; set; } + public bool? Active { get; set; } - public string Src { get; set; } + public string Src { get; set; } - public string Alt { get; set; } + public string Alt { get; set; } - public string CaptionTitle { get; set; } + public string CaptionTitle { get; set; } - public string Caption { get; set; } + public string Caption { get; set; } - public AbpCarouselItemTagHelper(AbpCarouselItemTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCarouselItemTagHelper(AbpCarouselItemTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelperService.cs index 1af2b759a4..a8a3030e95 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselItemTagHelperService.cs @@ -5,79 +5,78 @@ using System.Text.Encodings.Web; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel; + +public class AbpCarouselItemTagHelperService : AbpTagHelperService { - public class AbpCarouselItemTagHelperService : AbpTagHelperService - { - private readonly HtmlEncoder _encoder; + private readonly HtmlEncoder _encoder; - public AbpCarouselItemTagHelperService(HtmlEncoder encoder) - { - _encoder = encoder; - } + public AbpCarouselItemTagHelperService(HtmlEncoder encoder) + { + _encoder = encoder; + } - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("carousel-item"); - output.Attributes.AddClass(AbpCarouselItemActivePlaceholder); + public override void Process(TagHelperContext context, TagHelperOutput output) + { + output.TagName = "div"; + output.Attributes.AddClass("carousel-item"); + output.Attributes.AddClass(AbpCarouselItemActivePlaceholder); - SetInnerImgTag(context, output); - SetActive(context, output); - AddCaption(context, output); + SetInnerImgTag(context, output); + SetActive(context, output); + AddCaption(context, output); - AddToContext(context, output); + AddToContext(context, output); - output.SuppressOutput(); - } + output.SuppressOutput(); + } - private void AddToContext(TagHelperContext context, TagHelperOutput output) - { - var getOutputAsHtml = output.Render(_encoder); + private void AddToContext(TagHelperContext context, TagHelperOutput output) + { + var getOutputAsHtml = output.Render(_encoder); - var itemList = context.GetValue>(CarouselItemsContent); + var itemList = context.GetValue>(CarouselItemsContent); - itemList.Add(new CarouselItem(getOutputAsHtml, TagHelper.Active ?? false)); - } + itemList.Add(new CarouselItem(getOutputAsHtml, TagHelper.Active ?? false)); + } - protected virtual void SetInnerImgTag(TagHelperContext context, TagHelperOutput output) - { - var img = new TagBuilder("img"); - img.AddCssClass("d-block w-100"); - img.Attributes.Add("src", TagHelper.Src); - img.Attributes.Add("alt", TagHelper.Alt); + protected virtual void SetInnerImgTag(TagHelperContext context, TagHelperOutput output) + { + var img = new TagBuilder("img"); + img.AddCssClass("d-block w-100"); + img.Attributes.Add("src", TagHelper.Src); + img.Attributes.Add("alt", TagHelper.Alt); - output.Content.SetHtmlContent(img); - } + output.Content.SetHtmlContent(img); + } - protected virtual void SetActive(TagHelperContext context, TagHelperOutput output) + protected virtual void SetActive(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Active ?? false) { - if (TagHelper.Active??false) - { - output.Attributes.AddClass("active"); - } + output.Attributes.AddClass("active"); } + } - protected virtual void AddCaption(TagHelperContext context, TagHelperOutput output) + protected virtual void AddCaption(TagHelperContext context, TagHelperOutput output) + { + if (string.IsNullOrWhiteSpace(TagHelper.Caption) && string.IsNullOrWhiteSpace(TagHelper.CaptionTitle)) { - if (string.IsNullOrWhiteSpace(TagHelper.Caption) && string.IsNullOrWhiteSpace(TagHelper.CaptionTitle)) - { - return; - } - - var title = new TagBuilder("h5"); - title.InnerHtml.AppendHtml(TagHelper.CaptionTitle); + return; + } - var caption = new TagBuilder("p"); - caption.InnerHtml.AppendHtml(TagHelper.Caption); + var title = new TagBuilder("h5"); + title.InnerHtml.AppendHtml(TagHelper.CaptionTitle); - var wrapper = new TagBuilder("div"); - wrapper.AddCssClass("carousel-caption d-none d-md-block"); - wrapper.InnerHtml.AppendHtml(title); - wrapper.InnerHtml.AppendHtml(caption); + var caption = new TagBuilder("p"); + caption.InnerHtml.AppendHtml(TagHelper.Caption); - output.PostContent.SetHtmlContent(wrapper); - } + var wrapper = new TagBuilder("div"); + wrapper.AddCssClass("carousel-caption d-none d-md-block"); + wrapper.InnerHtml.AppendHtml(title); + wrapper.InnerHtml.AppendHtml(caption); + output.PostContent.SetHtmlContent(wrapper); } + } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelper.cs index becb13ca47..e9931241c2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelper.cs @@ -1,19 +1,18 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel; + +public class AbpCarouselTagHelper : AbpTagHelper { - public class AbpCarouselTagHelper : AbpTagHelper - { - public string Id { get; set; } + public string Id { get; set; } - public bool? Crossfade { get; set; } + public bool? Crossfade { get; set; } - public bool? Controls { get; set; } + public bool? Controls { get; set; } - public bool? Indicators { get; set; } + public bool? Indicators { get; set; } - public AbpCarouselTagHelper(AbpCarouselTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCarouselTagHelper(AbpCarouselTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 bb3c38f12b..9264737b7b 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 @@ -8,174 +8,173 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel; + +public class AbpCarouselTagHelperService : AbpTagHelperService { - public class AbpCarouselTagHelperService : AbpTagHelperService + protected IStringLocalizer L { get; } + + public AbpCarouselTagHelperService(IStringLocalizer localizer) { - protected IStringLocalizer L { get; } + L = localizer; + } - public AbpCarouselTagHelperService(IStringLocalizer localizer) - { - L = localizer; - } + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + output.TagName = "div"; - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; + SetRandomIdIfNotProvided(); + AddBasicAttributes(context, output); - SetRandomIdIfNotProvided(); - AddBasicAttributes(context, output); + var itemList = InitilizeCarouselItemsContentsContext(context, output); - var itemList = InitilizeCarouselItemsContentsContext(context, output); + await output.GetChildContentAsync(); - await output.GetChildContentAsync(); + SetOneItemAsActive(context, output, itemList); + SetItems(context, output, itemList); + SetControls(context, output, itemList); + SetIndicators(context, output, itemList); + } - SetOneItemAsActive(context, output, itemList); - SetItems(context, output, itemList); - SetControls(context, output, itemList); - SetIndicators(context, output, itemList); - } + protected virtual List InitilizeCarouselItemsContentsContext(TagHelperContext context, TagHelperOutput output) + { + var items = new List(); + context.Items[CarouselItemsContent] = items; + return items; + } - protected virtual List InitilizeCarouselItemsContentsContext(TagHelperContext context, TagHelperOutput output) - { - var items = new List(); - context.Items[CarouselItemsContent] = items; - return items; - } + protected virtual void SetItems(TagHelperContext context, TagHelperOutput output, List itemList) + { + var wrapper = new TagBuilder("div"); + wrapper.AddCssClass("carousel-inner"); - protected virtual void SetItems(TagHelperContext context, TagHelperOutput output, List itemList) + foreach (var carouselItem in itemList) { - var wrapper = new TagBuilder("div"); - wrapper.AddCssClass("carousel-inner"); + SetActiveIfActive(carouselItem); - foreach (var carouselItem in itemList) - { - SetActiveIfActive(carouselItem); + wrapper.InnerHtml.AppendHtml(carouselItem.Html); + } - wrapper.InnerHtml.AppendHtml(carouselItem.Html); - } + output.Content.SetHtmlContent(wrapper); + } - output.Content.SetHtmlContent(wrapper); + protected virtual void SetControls(TagHelperContext context, TagHelperOutput output, List itemList) + { + if (!TagHelper.Controls ?? false) + { + return; } - protected virtual void SetControls(TagHelperContext context, TagHelperOutput output, List itemList) - { - if (!TagHelper.Controls ?? false) - { - return; - } + // create 'previous' item + var prevIcon = new TagBuilder("span"); + prevIcon.AddCssClass("carousel-control-prev-icon"); + prevIcon.Attributes.Add("aria-hidden", "true"); + + var prevText = new TagBuilder("span"); + prevText.AddCssClass("visually-hidden"); + prevText.InnerHtml.Append(L["Previous"].Value); + + var prevAnchor = new TagBuilder("a"); + prevAnchor.AddCssClass("carousel-control-prev"); + prevAnchor.Attributes.Add("href", "#" + TagHelper.Id); + prevAnchor.Attributes.Add("role", "button"); + prevAnchor.Attributes.Add("data-bs-slide", "prev"); + + prevAnchor.InnerHtml.AppendHtml(prevIcon); + prevAnchor.InnerHtml.AppendHtml(prevText); + + // create 'next' item + var nextIcon = new TagBuilder("span"); + nextIcon.AddCssClass("carousel-control-next-icon"); + nextIcon.Attributes.Add("aria-hidden", "true"); + + var nextText = new TagBuilder("span"); + nextText.AddCssClass("visually-hidden"); + nextText.InnerHtml.Append(L["Next"].Value); + + var nextAnchor = new TagBuilder("a"); + nextAnchor.AddCssClass("carousel-control-next"); + nextAnchor.Attributes.Add("href", "#" + TagHelper.Id); + nextAnchor.Attributes.Add("role", "button"); + nextAnchor.Attributes.Add("data-bs-slide", "next"); + + nextAnchor.InnerHtml.AppendHtml(nextIcon); + nextAnchor.InnerHtml.AppendHtml(nextText); + + // append post content + output.PostContent.AppendHtml(prevAnchor); + output.PostContent.AppendHtml(nextAnchor); + } - // create 'previous' item - var prevIcon = new TagBuilder("span"); - prevIcon.AddCssClass("carousel-control-prev-icon"); - prevIcon.Attributes.Add("aria-hidden", "true"); - - var prevText = new TagBuilder("span"); - prevText.AddCssClass("visually-hidden"); - prevText.InnerHtml.Append(L["Previous"].Value); - - var prevAnchor = new TagBuilder("a"); - prevAnchor.AddCssClass("carousel-control-prev"); - prevAnchor.Attributes.Add("href", "#" + TagHelper.Id); - prevAnchor.Attributes.Add("role", "button"); - prevAnchor.Attributes.Add("data-bs-slide", "prev"); - - prevAnchor.InnerHtml.AppendHtml(prevIcon); - prevAnchor.InnerHtml.AppendHtml(prevText); - - // create 'next' item - var nextIcon = new TagBuilder("span"); - nextIcon.AddCssClass("carousel-control-next-icon"); - nextIcon.Attributes.Add("aria-hidden", "true"); - - var nextText = new TagBuilder("span"); - nextText.AddCssClass("visually-hidden"); - nextText.InnerHtml.Append(L["Next"].Value); - - var nextAnchor = new TagBuilder("a"); - nextAnchor.AddCssClass("carousel-control-next"); - nextAnchor.Attributes.Add("href", "#" + TagHelper.Id); - nextAnchor.Attributes.Add("role", "button"); - nextAnchor.Attributes.Add("data-bs-slide", "next"); - - nextAnchor.InnerHtml.AppendHtml(nextIcon); - nextAnchor.InnerHtml.AppendHtml(nextText); - - // append post content - output.PostContent.AppendHtml(prevAnchor); - output.PostContent.AppendHtml(nextAnchor); + protected virtual void SetIndicators(TagHelperContext context, TagHelperOutput output, List itemList) + { + if (!TagHelper.Indicators ?? false) + { + return; } - protected virtual void SetIndicators(TagHelperContext context, TagHelperOutput output, List itemList) - { - if (!TagHelper.Indicators ?? false) - { - return; - } + var list = new TagBuilder("ol"); + list.AddCssClass("carousel-indicators"); - var list = new TagBuilder("ol"); - list.AddCssClass("carousel-indicators"); + for (var i = 0; i < itemList.Count; i++) + { + var listItem = new TagBuilder("li"); + listItem.Attributes.Add("data-bs-target", "#" + TagHelper.Id); + listItem.Attributes.Add("data-bs-slide-to", i.ToString()); - for (var i = 0; i < itemList.Count; i++) + if (itemList[i].Active) { - var listItem = new TagBuilder("li"); - listItem.Attributes.Add("data-bs-target", "#" + TagHelper.Id); - listItem.Attributes.Add("data-bs-slide-to", i.ToString()); - - if (itemList[i].Active) - { - listItem.AddCssClass("active"); - } - - list.InnerHtml.AppendHtml(listItem); + listItem.AddCssClass("active"); } - output.PreContent.SetHtmlContent(list); + list.InnerHtml.AppendHtml(listItem); } - protected virtual void SetOneItemAsActive(TagHelperContext context, TagHelperOutput output, List itemList) - { - if (!itemList.Any(it => it.Active) && itemList.Count > 0) - { - itemList.FirstOrDefault().Active = true; - } - } + output.PreContent.SetHtmlContent(list); + } - protected virtual void AddBasicAttributes(TagHelperContext context, TagHelperOutput output) + protected virtual void SetOneItemAsActive(TagHelperContext context, TagHelperOutput output, List itemList) + { + if (!itemList.Any(it => it.Active) && itemList.Count > 0) { - output.Attributes.Add("data-bs-ride", "carousel"); - output.Attributes.Add("id", TagHelper.Id); - AddBasicClasses(context, output); + itemList.FirstOrDefault().Active = true; } + } - protected virtual void AddBasicClasses(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("carousel"); - output.Attributes.AddClass("slide"); - SetFadeAnimation(context, output); - } + protected virtual void AddBasicAttributes(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.Add("data-bs-ride", "carousel"); + output.Attributes.Add("id", TagHelper.Id); + AddBasicClasses(context, output); + } - protected virtual void SetFadeAnimation(TagHelperContext context, TagHelperOutput output) - { - if (TagHelper.Crossfade ?? false) - { - output.Attributes.AddClass("carousel-fade"); - } - } + protected virtual void AddBasicClasses(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.AddClass("carousel"); + output.Attributes.AddClass("slide"); + SetFadeAnimation(context, output); + } - protected virtual void SetRandomIdIfNotProvided() + protected virtual void SetFadeAnimation(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Crossfade ?? false) { - if (string.IsNullOrWhiteSpace(TagHelper.Id)) - { - TagHelper.Id = "C" + Guid.NewGuid().ToString("N"); - } + output.Attributes.AddClass("carousel-fade"); } + } - protected virtual void SetActiveIfActive(CarouselItem item) + protected virtual void SetRandomIdIfNotProvided() + { + if (string.IsNullOrWhiteSpace(TagHelper.Id)) { - item.Html = item.Html.Replace(AbpCarouselItemActivePlaceholder, item.Active ? "active" : ""); + TagHelper.Id = "C" + Guid.NewGuid().ToString("N"); } + } + protected virtual void SetActiveIfActive(CarouselItem item) + { + item.Html = item.Html.Replace(AbpCarouselItemActivePlaceholder, item.Active ? "active" : ""); } + } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/CarouselItem.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/CarouselItem.cs index da901f39b0..2942a62541 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/CarouselItem.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/CarouselItem.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel; + +public class CarouselItem { - public class CarouselItem + public CarouselItem(string html, bool active) { - public CarouselItem(string html, bool active) - { - Html = html; - Active = active; - } + Html = html; + Active = active; + } - public string Html { get; set; } + public string Html { get; set; } - public bool Active { get; set; } - } + public bool Active { get; set; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelper.cs index d1ec7e41b4..8742631e9a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelper.cs @@ -1,17 +1,16 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpAccordionItemTagHelper : AbpTagHelper { - public class AbpAccordionItemTagHelper : AbpTagHelper - { - public string Id { get; set; } + public string Id { get; set; } - public string Title { get; set; } + public string Title { get; set; } - public bool? Active { get; set; } + public bool? Active { get; set; } - public AbpAccordionItemTagHelper(AbpAccordionItemTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpAccordionItemTagHelper(AbpAccordionItemTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 3ea2824b62..7f3f7e9c17 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 @@ -5,81 +5,80 @@ using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpAccordionItemTagHelperService : AbpTagHelperService { - public class AbpAccordionItemTagHelperService : AbpTagHelperService + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - SetRandomIdIfNotProvided(); + SetRandomIdIfNotProvided(); - var childContent = await output.GetChildContentAsync(); + var childContent = await output.GetChildContentAsync(); - var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, childContent); + var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, childContent); - var tabHeaderItems = context.GetValue>(AccordionItems); - tabHeaderItems.Add(html); + var tabHeaderItems = context.GetValue>(AccordionItems); + tabHeaderItems.Add(html); - output.SuppressOutput(); - } + output.SuppressOutput(); + } - protected virtual string GetAccordionHeaderItem(TagHelperContext context, TagHelperOutput output) - { - var button = new TagBuilder("button"); - button.AddCssClass("btn btn-link"); - button.Attributes.Add("type", "button"); - button.Attributes.Add("data-bs-toggle", "collapse"); - button.Attributes.Add("data-bs-target", "#" + GetContentId()); - button.Attributes.Add("aria-expanded", "true"); - button.Attributes.Add("aria-controls", GetContentId()); - button.InnerHtml.AppendHtml(TagHelper.Title); - - var h5 = new TagBuilder("h5"); - h5.AddCssClass("mb-0"); - h5.InnerHtml.AppendHtml(button); - - var header = new TagBuilder("div"); - header.AddCssClass("card-header"); - header.Attributes.Add("id", GetHeadingId()); - header.InnerHtml.AppendHtml(h5); - - return header.ToHtmlString(); - } + protected virtual string GetAccordionHeaderItem(TagHelperContext context, TagHelperOutput output) + { + var button = new TagBuilder("button"); + button.AddCssClass("btn btn-link"); + button.Attributes.Add("type", "button"); + button.Attributes.Add("data-bs-toggle", "collapse"); + button.Attributes.Add("data-bs-target", "#" + GetContentId()); + button.Attributes.Add("aria-expanded", "true"); + button.Attributes.Add("aria-controls", GetContentId()); + button.InnerHtml.AppendHtml(TagHelper.Title); + + var h5 = new TagBuilder("h5"); + h5.AddCssClass("mb-0"); + h5.InnerHtml.AppendHtml(button); + + var header = new TagBuilder("div"); + header.AddCssClass("card-header"); + header.Attributes.Add("id", GetHeadingId()); + header.InnerHtml.AppendHtml(h5); + + return header.ToHtmlString(); + } - protected virtual string GetAccordionContentItem(TagHelperContext context, TagHelperOutput output, TagHelperContent content) - { - var show = (TagHelper.Active ?? false) ? " show" : ""; + protected virtual string GetAccordionContentItem(TagHelperContext context, TagHelperOutput output, TagHelperContent content) + { + var show = (TagHelper.Active ?? false) ? " show" : ""; - var cardBody = new TagBuilder("div"); - cardBody.AddCssClass("card-body"); - cardBody.InnerHtml.AppendHtml(content); + var cardBody = new TagBuilder("div"); + cardBody.AddCssClass("card-body"); + cardBody.InnerHtml.AppendHtml(content); - var wrapper = new TagBuilder("div"); - wrapper.AddCssClass("collapse" + show); - wrapper.Attributes.Add("id", GetContentId()); - wrapper.Attributes.Add("aria-labelledby", GetHeadingId()); - wrapper.Attributes.Add("data-bs-parent", "#" + AbpAccordionParentIdPlaceholder); - wrapper.InnerHtml.AppendHtml(cardBody); + var wrapper = new TagBuilder("div"); + wrapper.AddCssClass("collapse" + show); + wrapper.Attributes.Add("id", GetContentId()); + wrapper.Attributes.Add("aria-labelledby", GetHeadingId()); + wrapper.Attributes.Add("data-bs-parent", "#" + AbpAccordionParentIdPlaceholder); + wrapper.InnerHtml.AppendHtml(cardBody); - return wrapper.ToHtmlString(); - } + return wrapper.ToHtmlString(); + } - protected virtual string GetHeadingId() - { - return "heading" + TagHelper.Id; ; - } + protected virtual string GetHeadingId() + { + return "heading" + TagHelper.Id; ; + } - protected virtual string GetContentId() - { - return "content" + TagHelper.Id; ; - } + protected virtual string GetContentId() + { + return "content" + TagHelper.Id; ; + } - protected virtual void SetRandomIdIfNotProvided() + protected virtual void SetRandomIdIfNotProvided() + { + if (string.IsNullOrWhiteSpace(TagHelper.Id)) { - if (string.IsNullOrWhiteSpace(TagHelper.Id)) - { - TagHelper.Id = "A" + Guid.NewGuid().ToString("N"); - } + TagHelper.Id = "A" + Guid.NewGuid().ToString("N"); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelper.cs index c297a7c630..49cca3199f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelper.cs @@ -1,13 +1,12 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpAccordionTagHelper : AbpTagHelper { - public class AbpAccordionTagHelper : AbpTagHelper - { - public string Id { get; set; } + public string Id { get; set; } - public AbpAccordionTagHelper(AbpAccordionTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpAccordionTagHelper(AbpAccordionTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 d55bb04d21..c33b25022b 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 @@ -6,60 +6,59 @@ using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpAccordionTagHelperService : AbpTagHelperService { - public class AbpAccordionTagHelperService : AbpTagHelperService - { - protected IHtmlGenerator HtmlGenerator { get; } + protected IHtmlGenerator HtmlGenerator { get; } - public AbpAccordionTagHelperService(IHtmlGenerator htmlGenerator) - { - HtmlGenerator = htmlGenerator; - } + public AbpAccordionTagHelperService(IHtmlGenerator htmlGenerator) + { + HtmlGenerator = htmlGenerator; + } - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - SetRandomIdIfNotProvided(); + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + SetRandomIdIfNotProvided(); - output.TagName = "div"; - output.TagMode = TagMode.StartTagAndEndTag; - output.Attributes.AddClass("accordion"); - output.Attributes.Add("id",TagHelper.Id); + output.TagName = "div"; + output.TagMode = TagMode.StartTagAndEndTag; + output.Attributes.AddClass("accordion"); + output.Attributes.Add("id", TagHelper.Id); - var items = InitilizeFormGroupContentsContext(context, output); + var items = InitilizeFormGroupContentsContext(context, output); - await output.GetChildContentAsync(); + await output.GetChildContentAsync(); - SetContent(context, output, items); - } + SetContent(context, output, items); + } - protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List items) + protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List items) + { + foreach (var item in items) { - foreach (var item in items) - { - var content = item.Replace(AbpAccordionParentIdPlaceholder, HtmlGenerator.Encode(TagHelper.Id)); + var content = item.Replace(AbpAccordionParentIdPlaceholder, HtmlGenerator.Encode(TagHelper.Id)); - var wrapper = new TagBuilder("div"); - wrapper.AddCssClass("card"); - wrapper.InnerHtml.AppendHtml(content); + var wrapper = new TagBuilder("div"); + wrapper.AddCssClass("card"); + wrapper.InnerHtml.AppendHtml(content); - output.Content.AppendHtml(wrapper); - } + output.Content.AppendHtml(wrapper); } + } - protected virtual List InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) - { - var items = new List(); - context.Items[AccordionItems] = items; - return items; - } + protected virtual List InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) + { + var items = new List(); + context.Items[AccordionItems] = items; + return items; + } - protected virtual void SetRandomIdIfNotProvided() + protected virtual void SetRandomIdIfNotProvided() + { + if (string.IsNullOrWhiteSpace(TagHelper.Id)) { - if (string.IsNullOrWhiteSpace(TagHelper.Id)) - { - TagHelper.Id = "A" + Guid.NewGuid().ToString("N"); - } + TagHelper.Id = "A" + Guid.NewGuid().ToString("N"); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelper.cs index a50907addb..cd6d5d43ed 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelper.cs @@ -1,17 +1,16 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpCollapseBodyTagHelper : AbpTagHelper { - public class AbpCollapseBodyTagHelper : AbpTagHelper - { - public string Id { get; set; } + public string Id { get; set; } - public bool? Multi { get; set; } + public bool? Multi { get; set; } - public bool? Show { get; set; } + public bool? Show { get; set; } - public AbpCollapseBodyTagHelper(AbpCollapseBodyTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpCollapseBodyTagHelper(AbpCollapseBodyTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 843efae0f4..85685ccf80 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 @@ -2,29 +2,28 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpCollapseBodyTagHelperService : AbpTagHelperService { - public class AbpCollapseBodyTagHelperService : AbpTagHelperService + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("collapse"); - output.Attributes.Add("id", TagHelper.Id); + output.TagName = "div"; + output.Attributes.AddClass("collapse"); + output.Attributes.Add("id", TagHelper.Id); - if (TagHelper.Show ?? false) - { - output.Attributes.AddClass("show"); - } + if (TagHelper.Show ?? false) + { + output.Attributes.AddClass("show"); + } - if (TagHelper.Multi ?? false) - { - output.Attributes.AddClass("multi-collapse"); - } + if (TagHelper.Multi ?? false) + { + output.Attributes.AddClass("multi-collapse"); + } - var childContent = await output.GetChildContentAsync(); + var childContent = await output.GetChildContentAsync(); - output.Content.SetHtmlContent(childContent); - } + output.Content.SetHtmlContent(childContent); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelper.cs index 6b8fc8c30b..c1219b3bbb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelper.cs @@ -1,20 +1,18 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +[HtmlTargetElement("abp-button", Attributes = "abp-collapse-id")] +[HtmlTargetElement("a", Attributes = "abp-collapse-id")] +public class AbpCollapseButtonTagHelper : AbpTagHelper { + [HtmlAttributeName("abp-collapse-id")] + public string BodyId { get; set; } - [HtmlTargetElement("abp-button", Attributes = "abp-collapse-id")] - [HtmlTargetElement("a", Attributes = "abp-collapse-id")] - public class AbpCollapseButtonTagHelper : AbpTagHelper + public AbpCollapseButtonTagHelper(AbpCollapseButtonTagHelperService tagHelperService) + : base(tagHelperService) { - [HtmlAttributeName("abp-collapse-id")] - public string BodyId { get; set; } - - public AbpCollapseButtonTagHelper(AbpCollapseButtonTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelperService.cs index fcc4ff413e..49b356379a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseButtonTagHelperService.cs @@ -2,54 +2,53 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse; + +public class AbpCollapseButtonTagHelperService : AbpTagHelperService { - public class AbpCollapseButtonTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - AddCommonAttributes(context, output); + AddCommonAttributes(context, output); - if (output.TagName == "abp-button" || output.TagName == "button") - { - AddButtonAttributes(context,output); - } - else if (output.TagName == "a") - { - AddLinkAttributes(context, output); - } + if (output.TagName == "abp-button" || output.TagName == "button") + { + AddButtonAttributes(context, output); } - - protected virtual void AddCommonAttributes(TagHelperContext context, TagHelperOutput output) + else if (output.TagName == "a") { - output.Attributes.Add("data-bs-toggle", "collapse"); - output.Attributes.Add("aria-expanded", "false"); - output.Attributes.Add("aria-controls", TagHelper.BodyId); + AddLinkAttributes(context, output); } + } - protected virtual void AddButtonAttributes(TagHelperContext context, TagHelperOutput output) - { - if (TagHelper.BodyId.Trim().Split(' ').Length > 1) - { - output.Attributes.Add("data-bs-target", ".multi-collapse"); - return; - } + protected virtual void AddCommonAttributes(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.Add("data-bs-toggle", "collapse"); + output.Attributes.Add("aria-expanded", "false"); + output.Attributes.Add("aria-controls", TagHelper.BodyId); + } - output.Attributes.Add("data-bs-target", "#" + TagHelper.BodyId); + protected virtual void AddButtonAttributes(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.BodyId.Trim().Split(' ').Length > 1) + { + output.Attributes.Add("data-bs-target", ".multi-collapse"); + return; } - protected virtual void AddLinkAttributes(TagHelperContext context, TagHelperOutput output) - { - if (TagHelper.BodyId.Trim().Split(' ').Length > 1) - { - output.Attributes.Add("href", ".multi-collapse"); - return; - } + output.Attributes.Add("data-bs-target", "#" + TagHelper.BodyId); + } - output.Attributes.Add("href", "#" + TagHelper.BodyId); + protected virtual void AddLinkAttributes(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.BodyId.Trim().Split(' ').Length > 1) + { + output.Attributes.Add("href", ".multi-collapse"); + return; } + output.Attributes.Add("href", "#" + TagHelper.BodyId); } + } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelper.cs index de20c8743c..ac87900307 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelper.cs @@ -1,29 +1,28 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownButtonTagHelper : AbpTagHelper { - public class AbpDropdownButtonTagHelper : AbpTagHelper - { - public string Text { get; set; } + public string Text { get; set; } - public AbpButtonSize Size { get; set; } = AbpButtonSize.Default; + public AbpButtonSize Size { get; set; } = AbpButtonSize.Default; - public DropdownStyle DropdownStyle { get; set; } = DropdownStyle.Single; + public DropdownStyle DropdownStyle { get; set; } = DropdownStyle.Single; - public AbpButtonType ButtonType { get; set; } = AbpButtonType.Default; + public AbpButtonType ButtonType { get; set; } = AbpButtonType.Default; - public string Icon { get; set; } + public string Icon { get; set; } - public FontIconType IconType { get; set; } = FontIconType.FontAwesome; + public FontIconType IconType { get; set; } = FontIconType.FontAwesome; - public bool? Link { get; set; } + public bool? Link { get; set; } - public bool? NavLink { get; set; } + public bool? NavLink { get; set; } - public AbpDropdownButtonTagHelper(AbpDropdownButtonTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpDropdownButtonTagHelper(AbpDropdownButtonTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 faa8fe7d75..8a5f5df409 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 @@ -8,138 +8,137 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown -{ - public class AbpDropdownButtonTagHelperService : AbpTagHelperService - { +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; - private readonly HtmlEncoder _htmlEncoder; - private readonly IServiceProvider _serviceProvider; +public class AbpDropdownButtonTagHelperService : AbpTagHelperService +{ - public AbpDropdownButtonTagHelperService( - HtmlEncoder htmlEncoder, - IServiceProvider serviceProvider) - { - _htmlEncoder = htmlEncoder; - _serviceProvider = serviceProvider; - } + private readonly HtmlEncoder _htmlEncoder; + private readonly IServiceProvider _serviceProvider; - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - var content = await output.GetChildContentAsync(); + public AbpDropdownButtonTagHelperService( + HtmlEncoder htmlEncoder, + IServiceProvider serviceProvider) + { + _htmlEncoder = htmlEncoder; + _serviceProvider = serviceProvider; + } - var buttonsAsHtml = await GetButtonsAsHtmlAsync(context, output, content); + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + var content = await output.GetChildContentAsync(); - output.PreElement.SetHtmlContent(buttonsAsHtml); + var buttonsAsHtml = await GetButtonsAsHtmlAsync(context, output, content); - output.TagName = "div"; - output.TagMode = TagMode.StartTagAndEndTag; - output.Content.SetContent(""); - output.Attributes.Clear(); - } + output.PreElement.SetHtmlContent(buttonsAsHtml); - protected virtual async Task GetButtonsAsHtmlAsync(TagHelperContext context, TagHelperOutput output, - TagHelperContent content) - { - var buttonBuilder = new StringBuilder(""); + output.TagName = "div"; + output.TagMode = TagMode.StartTagAndEndTag; + output.Content.SetContent(""); + output.Attributes.Clear(); + } - var mainButton = await GetMainButtonAsync(context, output, content); + protected virtual async Task GetButtonsAsHtmlAsync(TagHelperContext context, TagHelperOutput output, + TagHelperContent content) + { + var buttonBuilder = new StringBuilder(""); - buttonBuilder.AppendLine(mainButton); + var mainButton = await GetMainButtonAsync(context, output, content); - if (TagHelper.DropdownStyle == DropdownStyle.Split) - { - var splitButton = await GetSplitButtonAsync(context, output); + buttonBuilder.AppendLine(mainButton); - buttonBuilder.AppendLine(splitButton); - } + if (TagHelper.DropdownStyle == DropdownStyle.Split) + { + var splitButton = await GetSplitButtonAsync(context, output); - return buttonBuilder.ToString(); + buttonBuilder.AppendLine(splitButton); } - protected virtual async Task GetMainButtonAsync(TagHelperContext context, TagHelperOutput output, TagHelperContent content) - { - var abpButtonTagHelper = _serviceProvider.GetRequiredService(); - - abpButtonTagHelper.Icon = TagHelper.Icon; - abpButtonTagHelper.Text = TagHelper.Text; - abpButtonTagHelper.IconType = TagHelper.IconType; - abpButtonTagHelper.Size = TagHelper.Size; - abpButtonTagHelper.ButtonType = TagHelper.ButtonType; - var attributes = GetAttributesForMainButton(context, output); + return buttonBuilder.ToString(); + } - var buttonTag = await abpButtonTagHelper.ProcessAndGetOutputAsync(attributes, context, "button", TagMode.StartTagAndEndTag); + protected virtual async Task GetMainButtonAsync(TagHelperContext context, TagHelperOutput output, TagHelperContent content) + { + var abpButtonTagHelper = _serviceProvider.GetRequiredService(); - buttonTag.PreContent.SetHtmlContent(content); + abpButtonTagHelper.Icon = TagHelper.Icon; + abpButtonTagHelper.Text = TagHelper.Text; + abpButtonTagHelper.IconType = TagHelper.IconType; + abpButtonTagHelper.Size = TagHelper.Size; + abpButtonTagHelper.ButtonType = TagHelper.ButtonType; + var attributes = GetAttributesForMainButton(context, output); - if ((TagHelper.NavLink ?? false) || (TagHelper.Link ?? false)) - { - var linkTag = ConvertButtonToLink(buttonTag); - return linkTag.Render(_htmlEncoder); - } + var buttonTag = await abpButtonTagHelper.ProcessAndGetOutputAsync(attributes, context, "button", TagMode.StartTagAndEndTag); - return buttonTag.Render(_htmlEncoder); - } + buttonTag.PreContent.SetHtmlContent(content); - protected virtual async Task GetSplitButtonAsync(TagHelperContext context, TagHelperOutput output) + if ((TagHelper.NavLink ?? false) || (TagHelper.Link ?? false)) { - var abpButtonTagHelper = _serviceProvider.GetRequiredService(); + var linkTag = ConvertButtonToLink(buttonTag); + return linkTag.Render(_htmlEncoder); + } - abpButtonTagHelper.Size = TagHelper.Size; - abpButtonTagHelper.ButtonType = TagHelper.ButtonType; - var attributes = GetAttributesForSplitButton(context, output); + return buttonTag.Render(_htmlEncoder); + } - return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag); - } + protected virtual async Task GetSplitButtonAsync(TagHelperContext context, TagHelperOutput output) + { + var abpButtonTagHelper = _serviceProvider.GetRequiredService(); - protected virtual TagHelperAttributeList GetAttributesForMainButton(TagHelperContext context, TagHelperOutput output) - { + abpButtonTagHelper.Size = TagHelper.Size; + abpButtonTagHelper.ButtonType = TagHelper.ButtonType; + var attributes = GetAttributesForSplitButton(context, output); - var attributes = new TagHelperAttributeList(); + return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag); + } - foreach (var tagHelperAttribute in output.Attributes) - { - attributes.Add(tagHelperAttribute); - } + protected virtual TagHelperAttributeList GetAttributesForMainButton(TagHelperContext context, TagHelperOutput output) + { - if (TagHelper.DropdownStyle != DropdownStyle.Split) - { - attributes.AddClass("dropdown-toggle"); - attributes.Add("data-bs-toggle", "dropdown"); - attributes.Add("aria-haspopup", "true"); - attributes.Add("aria-expanded", "false"); - } + var attributes = new TagHelperAttributeList(); - return attributes; + foreach (var tagHelperAttribute in output.Attributes) + { + attributes.Add(tagHelperAttribute); } - protected virtual TagHelperAttributeList GetAttributesForSplitButton(TagHelperContext context, TagHelperOutput output) + if (TagHelper.DropdownStyle != DropdownStyle.Split) { - var attributes = new TagHelperAttributeList + attributes.AddClass("dropdown-toggle"); + attributes.Add("data-bs-toggle", "dropdown"); + attributes.Add("aria-haspopup", "true"); + attributes.Add("aria-expanded", "false"); + } + + return attributes; + } + + protected virtual TagHelperAttributeList GetAttributesForSplitButton(TagHelperContext context, TagHelperOutput output) + { + var attributes = new TagHelperAttributeList { {"data-bs-toggle", "dropdown"}, {"aria-haspopup", "true"}, {"aria-expanded", "false"}, }; - attributes.AddClass("dropdown-toggle"); - attributes.AddClass("dropdown-toggle-split"); + attributes.AddClass("dropdown-toggle"); + attributes.AddClass("dropdown-toggle-split"); - return attributes; - } + return attributes; + } - protected virtual TagHelperOutput ConvertButtonToLink(TagHelperOutput buttonTag) - { - buttonTag.TagName = "a"; - buttonTag.Attributes.RemoveAll("type"); - buttonTag.Attributes.Add("roles", "button"); - buttonTag.Attributes.Add("href", "#"); + protected virtual TagHelperOutput ConvertButtonToLink(TagHelperOutput buttonTag) + { + buttonTag.TagName = "a"; + buttonTag.Attributes.RemoveAll("type"); + buttonTag.Attributes.Add("roles", "button"); + buttonTag.Attributes.Add("href", "#"); - if (TagHelper.NavLink??false) - { - buttonTag.Attributes.AddClass("nav-link"); - } - return buttonTag; + if (TagHelper.NavLink ?? false) + { + buttonTag.Attributes.AddClass("nav-link"); } + return buttonTag; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelper.cs index 691d7c23a5..f87abb78f7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownDividerTagHelper : AbpTagHelper { - public class AbpDropdownDividerTagHelper : AbpTagHelper + public AbpDropdownDividerTagHelper(AbpDropdownDividerTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpDropdownDividerTagHelper(AbpDropdownDividerTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelperService.cs index 4e420f538b..7ff04e4f1d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownDividerTagHelperService.cs @@ -1,15 +1,14 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownDividerTagHelperService : AbpTagHelperService { - public class AbpDropdownDividerTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("dropdown-divider"); - output.TagMode = TagMode.StartTagAndEndTag; - } + output.TagName = "div"; + output.Attributes.AddClass("dropdown-divider"); + output.TagMode = TagMode.StartTagAndEndTag; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelper.cs index cc2a910a07..da0ee56f40 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownHeaderTagHelper : AbpTagHelper { - public class AbpDropdownHeaderTagHelper : AbpTagHelper + public AbpDropdownHeaderTagHelper(AbpDropdownHeaderTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpDropdownHeaderTagHelper(AbpDropdownHeaderTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelperService.cs index 73157f45cc..aed611f6e0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownHeaderTagHelperService.cs @@ -1,15 +1,14 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownHeaderTagHelperService : AbpTagHelperService { - public class AbpDropdownHeaderTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "h6"; - output.Attributes.AddClass("dropdown-header"); - output.TagMode = TagMode.StartTagAndEndTag; - } + output.TagName = "h6"; + output.Attributes.AddClass("dropdown-header"); + output.TagMode = TagMode.StartTagAndEndTag; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelper.cs index c017986271..a2a8403863 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelper.cs @@ -1,15 +1,14 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownItemTagHelper : AbpTagHelper { - public class AbpDropdownItemTagHelper : AbpTagHelper - { - public bool? Active { get; set; } + public bool? Active { get; set; } - public bool? Disabled { get; set; } + public bool? Disabled { get; set; } - public AbpDropdownItemTagHelper(AbpDropdownItemTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpDropdownItemTagHelper(AbpDropdownItemTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelperService.cs index 5f74b7a303..29815c5a4e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTagHelperService.cs @@ -1,34 +1,33 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownItemTagHelperService : AbpTagHelperService { - public class AbpDropdownItemTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "a"; - output.Attributes.AddClass("dropdown-item"); - output.TagMode = TagMode.StartTagAndEndTag; + output.TagName = "a"; + output.Attributes.AddClass("dropdown-item"); + output.TagMode = TagMode.StartTagAndEndTag; - SetActiveClassIfActive(context,output); - SetDisabledClassIfDisabled(context,output); - } + SetActiveClassIfActive(context, output); + SetDisabledClassIfDisabled(context, output); + } - protected virtual void SetActiveClassIfActive(TagHelperContext context, TagHelperOutput output) + protected virtual void SetActiveClassIfActive(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Active ?? false) { - if (TagHelper.Active??false) - { - output.Attributes.AddClass("active"); - } + output.Attributes.AddClass("active"); } + } - protected virtual void SetDisabledClassIfDisabled(TagHelperContext context, TagHelperOutput output) + protected virtual void SetDisabledClassIfDisabled(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.Disabled ?? false) { - if (TagHelper.Disabled??false) - { - output.Attributes.AddClass("disabled"); - } + output.Attributes.AddClass("disabled"); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelper.cs index 4c5e82fac7..b231aa63ef 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownItemTextTagHelper : AbpTagHelper { - public class AbpDropdownItemTextTagHelper : AbpTagHelper + public AbpDropdownItemTextTagHelper(AbpDropdownItemTextTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpDropdownItemTextTagHelper(AbpDropdownItemTextTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelperService.cs index 8cd84eade6..51b8af6250 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownItemTextTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownItemTextTagHelperService : AbpTagHelperService { - public class AbpDropdownItemTextTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("dropdown-item-text"); - output.TagName = "span"; - } + output.Attributes.AddClass("dropdown-item-text"); + output.TagName = "span"; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelper.cs index 04523033bc..1744d1922f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelper.cs @@ -1,13 +1,12 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownMenuTagHelper : AbpTagHelper { - public class AbpDropdownMenuTagHelper : AbpTagHelper - { - public DropdownAlign Align { get; set; } = DropdownAlign.Start; + public DropdownAlign Align { get; set; } = DropdownAlign.Start; - public AbpDropdownMenuTagHelper(AbpDropdownMenuTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpDropdownMenuTagHelper(AbpDropdownMenuTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelperService.cs index 80c4d31c87..1a9a1b6c55 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownMenuTagHelperService.cs @@ -1,29 +1,28 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownMenuTagHelperService : AbpTagHelperService { - public class AbpDropdownMenuTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("dropdown-menu"); - output.TagMode = TagMode.StartTagAndEndTag; + output.TagName = "div"; + output.Attributes.AddClass("dropdown-menu"); + output.TagMode = TagMode.StartTagAndEndTag; - SetAlign(context, output); - } + SetAlign(context, output); + } - protected virtual void SetAlign(TagHelperContext context, TagHelperOutput output) + protected virtual void SetAlign(TagHelperContext context, TagHelperOutput output) + { + switch (TagHelper.Align) { - switch (TagHelper.Align) - { - case DropdownAlign.End: - output.Attributes.AddClass("dropdown-menu-end"); - return; - case DropdownAlign.Start: - return; - } + case DropdownAlign.End: + output.Attributes.AddClass("dropdown-menu-end"); + return; + case DropdownAlign.Start: + return; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelper.cs index 5daad8a9b7..2cd06cff74 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelper.cs @@ -1,13 +1,12 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownTagHelper : AbpTagHelper { - public class AbpDropdownTagHelper : AbpTagHelper - { - public DropdownDirection Direction { get; set; } = DropdownDirection.Down; + public DropdownDirection Direction { get; set; } = DropdownDirection.Down; - public AbpDropdownTagHelper(AbpDropdownTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpDropdownTagHelper(AbpDropdownTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelperService.cs index 8f37fca5ee..581239a4b6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownTagHelperService.cs @@ -1,37 +1,36 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public class AbpDropdownTagHelperService : AbpTagHelperService { - public class AbpDropdownTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "div"; - output.Attributes.AddClass("dropdown"); - output.Attributes.AddClass("btn-group"); + output.TagName = "div"; + output.Attributes.AddClass("dropdown"); + output.Attributes.AddClass("btn-group"); - SetDirection(context, output); + SetDirection(context, output); - output.TagMode = TagMode.StartTagAndEndTag; - } + output.TagMode = TagMode.StartTagAndEndTag; + } - protected virtual void SetDirection(TagHelperContext context, TagHelperOutput output) + protected virtual void SetDirection(TagHelperContext context, TagHelperOutput output) + { + switch (TagHelper.Direction) { - switch (TagHelper.Direction) - { - case DropdownDirection.Down: - return; - case DropdownDirection.Up: - output.Attributes.AddClass("dropup"); - return; - case DropdownDirection.Right: - output.Attributes.AddClass("dropright"); - return; - case DropdownDirection.Left: - output.Attributes.AddClass("dropleft"); - return; - } + case DropdownDirection.Down: + return; + case DropdownDirection.Up: + output.Attributes.AddClass("dropup"); + return; + case DropdownDirection.Right: + output.Attributes.AddClass("dropright"); + return; + case DropdownDirection.Left: + output.Attributes.AddClass("dropleft"); + return; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownAlign.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownAlign.cs index a15cf821ea..331a0c3e5f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownAlign.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownAlign.cs @@ -1,8 +1,7 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public enum DropdownAlign { - public enum DropdownAlign - { - Start, - End - } -} \ No newline at end of file + Start, + End +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownDirection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownDirection.cs index f7c90ae58c..e67025e614 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownDirection.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownDirection.cs @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public enum DropdownDirection { - public enum DropdownDirection - { - Down, - Up, - Right, - Left - } -} \ No newline at end of file + Down, + Up, + Right, + Left +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownStyle.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownStyle.cs index 67d02ace22..6ea9256748 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownStyle.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/DropdownStyle.cs @@ -1,8 +1,7 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown; + +public enum DropdownStyle { - public enum DropdownStyle - { - Single, - Split - } -} \ No newline at end of file + Single, + Split +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/ModelExplorerExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/ModelExplorerExtensions.cs index b6bedac11b..eced70b75e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/ModelExplorerExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/ModelExplorerExtensions.cs @@ -3,18 +3,17 @@ using System.Reflection; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; + +public static class ModelExplorerExtensions { - public static class ModelExplorerExtensions + public static T GetAttribute(this ModelExplorer property) where T : Attribute { - public static T GetAttribute(this ModelExplorer property) where T : Attribute - { - return property?.Metadata?.ContainerType?.GetTypeInfo()?.GetProperty(property.Metadata.PropertyName)?.GetCustomAttribute(); - } + return property?.Metadata?.ContainerType?.GetTypeInfo()?.GetProperty(property.Metadata.PropertyName)?.GetCustomAttribute(); + } - public static int GetDisplayOrder(this ModelExplorer explorer) - { - return GetAttribute(explorer)?.Number ?? DisplayOrder.Default; - } + public static int GetDisplayOrder(this ModelExplorer explorer) + { + return GetAttribute(explorer)?.Number ?? DisplayOrder.Default; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperAttributeExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperAttributeExtensions.cs index ef581529a6..09d0513fbd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperAttributeExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperAttributeExtensions.cs @@ -1,25 +1,24 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using System.Collections.Generic; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; + +public static class TagHelperAttributeExtensions { - public static class TagHelperAttributeExtensions + public static string ToHtmlAttributeAsString(this TagHelperAttribute attribute) { - public static string ToHtmlAttributeAsString(this TagHelperAttribute attribute) - { - return attribute.Name + "=\"" + attribute.Value + "\""; - } - - public static string ToHtmlAttributesAsString(this List attributes) - { - var attributesAsString = ""; + return attribute.Name + "=\"" + attribute.Value + "\""; + } - foreach (var attribute in attributes) - { - attributesAsString += attribute.ToHtmlAttributeAsString() + " "; - } + public static string ToHtmlAttributesAsString(this List attributes) + { + var attributesAsString = ""; - return attributesAsString; + foreach (var attribute in attributes) + { + attributesAsString += attribute.ToHtmlAttributeAsString() + " "; } + + return attributesAsString; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperContextExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperContextExtensions.cs index c2b3e41192..47ab8827e7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperContextExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperContextExtensions.cs @@ -3,18 +3,17 @@ using System.Linq; using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; + +public static class TagHelperContextExtensions { - public static class TagHelperContextExtensions + public static T GetValue(this TagHelperContext context, string key) { - public static T GetValue(this TagHelperContext context, string key) + if (!context.Items.ContainsKey(key)) { - if (!context.Items.ContainsKey(key)) - { - return default(T); - } - - return (T)context.Items[key]; + return default(T); } + + return (T)context.Items[key]; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperExtensions.cs index 761b72ec99..227c824002 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperExtensions.cs @@ -3,43 +3,42 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.TagHelpers; using System.Text.Encodings.Web; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; + +public static class TagHelperExtensions { - public static class TagHelperExtensions + public static async Task ProcessAndGetOutputAsync( + this TagHelper tagHelper, + TagHelperAttributeList attributeList, + TagHelperContext context, + string tagName = "div", + TagMode tagMode = TagMode.SelfClosing) { - public static async Task ProcessAndGetOutputAsync( - this TagHelper tagHelper, - TagHelperAttributeList attributeList, - TagHelperContext context, - string tagName = "div", - TagMode tagMode = TagMode.SelfClosing) - { - var innerOutput = new TagHelperOutput( - tagName, - attributeList, - (useCachedResult, encoder) => Task.Run(() => new DefaultTagHelperContent())) - { - TagMode = tagMode - }; - - var innerContext = new TagHelperContext( - attributeList, - context.Items, - Guid.NewGuid().ToString() - ); - - tagHelper.Init(context); - - await tagHelper.ProcessAsync(innerContext, innerOutput); - - return innerOutput; - } - - public static async Task RenderAsync(this TagHelper tagHelper, TagHelperAttributeList attributeList, TagHelperContext context, HtmlEncoder htmlEncoder, string tagName = "div", TagMode tagMode = TagMode.SelfClosing) + var innerOutput = new TagHelperOutput( + tagName, + attributeList, + (useCachedResult, encoder) => Task.Run(() => new DefaultTagHelperContent())) { - var innerOutput = await tagHelper.ProcessAndGetOutputAsync(attributeList, context, tagName, tagMode); + TagMode = tagMode + }; + + var innerContext = new TagHelperContext( + attributeList, + context.Items, + Guid.NewGuid().ToString() + ); + + tagHelper.Init(context); + + await tagHelper.ProcessAsync(innerContext, innerOutput); + + return innerOutput; + } + + public static async Task RenderAsync(this TagHelper tagHelper, TagHelperAttributeList attributeList, TagHelperContext context, HtmlEncoder htmlEncoder, string tagName = "div", TagMode tagMode = TagMode.SelfClosing) + { + var innerOutput = await tagHelper.ProcessAndGetOutputAsync(attributeList, context, tagName, tagMode); - return innerOutput.Render(htmlEncoder); - } + return innerOutput.Render(htmlEncoder); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperOutputExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperOutputExtensions.cs index 0cc9bae6e2..40ca23a8f1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperOutputExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperOutputExtensions.cs @@ -2,17 +2,16 @@ using System.IO; using System.Text.Encodings.Web; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; + +public static class TagHelperOutputExtensions { - public static class TagHelperOutputExtensions + public static string Render(this TagHelperOutput output, HtmlEncoder htmlEncoder) { - public static string Render(this TagHelperOutput output, HtmlEncoder htmlEncoder) + using (var writer = new StringWriter()) { - using (var writer = new StringWriter()) - { - output.WriteTo(writer, htmlEncoder); - return writer.ToString(); - } + output.WriteTo(writer, htmlEncoder); + return writer.ToString(); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelper.cs index 9bac7ca93a..ea35a52fa4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelper.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure; + +[HtmlTargetElement("abp-figcaption")] +public class AbpFigureCaptionTagHelper : AbpTagHelper { - [HtmlTargetElement("abp-figcaption")] - public class AbpFigureCaptionTagHelper : AbpTagHelper + public AbpFigureCaptionTagHelper(AbpFigureCaptionTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpFigureCaptionTagHelper(AbpFigureCaptionTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelperService.cs index f14a4a18fd..e2df91691b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureCaptionTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure; + +public class AbpFigureCaptionTagHelperService : AbpTagHelperService { - public class AbpFigureCaptionTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "figcaption"; - output.Attributes.AddClass("figure-caption"); - } + output.TagName = "figcaption"; + output.Attributes.AddClass("figure-caption"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelper.cs index 4b395508ad..7229a40656 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelper.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure; + +[HtmlTargetElement("abp-image", ParentTag = "abp-figure")] +public class AbpFigureImageTagHelper : AbpTagHelper { - [HtmlTargetElement("abp-image", ParentTag = "abp-figure")] - public class AbpFigureImageTagHelper : AbpTagHelper + public AbpFigureImageTagHelper(AbpFigureImageTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpFigureImageTagHelper(AbpFigureImageTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelperService.cs index 51237fe297..f79eb9b9e1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureImageTagHelperService.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure; + +public class AbpFigureImageTagHelperService : AbpTagHelperService { - public class AbpFigureImageTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.AddClass("figure-img"); - } + output.Attributes.AddClass("figure-img"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelper.cs index 88b99b6138..1b9b8116e7 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelper.cs @@ -1,11 +1,10 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure; + +public class AbpFigureTagHelper : AbpTagHelper { - public class AbpFigureTagHelper : AbpTagHelper + public AbpFigureTagHelper(AbpFigureTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpFigureTagHelper(AbpFigureTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelperService.cs index 7fe094f94e..6c75c299b5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Figure/AbpFigureTagHelperService.cs @@ -1,14 +1,13 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Figure; + +public class AbpFigureTagHelperService : AbpTagHelperService { - public class AbpFigureTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.TagName = "figure"; - output.Attributes.AddClass("figure"); - } + output.TagName = "figure"; + output.Attributes.AddClass("figure"); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/FontIconType.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/FontIconType.cs index 81debc06b0..ebc23d68ff 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/FontIconType.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/FontIconType.cs @@ -1,8 +1,7 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; + +public enum FontIconType { - public enum FontIconType - { - FontAwesome, - Other - } -} \ No newline at end of file + FontAwesome, + Other +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelper.cs index d710793151..da4a567b5d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelper.cs @@ -4,63 +4,62 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +[HtmlTargetElement("abp-dynamic-form", TagStructure = TagStructure.NormalOrSelfClosing)] +public class AbpDynamicFormTagHelper : AbpTagHelper { - [HtmlTargetElement("abp-dynamic-form", TagStructure = TagStructure.NormalOrSelfClosing)] - public class AbpDynamicFormTagHelper : AbpTagHelper - { - [HtmlAttributeName("abp-model")] - public ModelExpression Model { get; set; } + [HtmlAttributeName("abp-model")] + public ModelExpression Model { get; set; } - public bool? SubmitButton { get; set; } + public bool? SubmitButton { get; set; } - public bool? RequiredSymbols { get; set; } = true; + public bool? RequiredSymbols { get; set; } = true; -#region MvcFormTagHelperAttiributes + #region MvcFormTagHelperAttiributes - private const string ActionAttributeName = "asp-action"; - private const string AreaAttributeName = "asp-area"; - private const string PageAttributeName = "asp-page"; - private const string PageHandlerAttributeName = "asp-page-handler"; - private const string FragmentAttributeName = "asp-fragment"; - private const string ControllerAttributeName = "asp-controller"; - private const string RouteAttributeName = "asp-route"; - private const string RouteValuesDictionaryName = "asp-all-route-data"; - private const string RouteValuesPrefix = "asp-route-"; + private const string ActionAttributeName = "asp-action"; + private const string AreaAttributeName = "asp-area"; + private const string PageAttributeName = "asp-page"; + private const string PageHandlerAttributeName = "asp-page-handler"; + private const string FragmentAttributeName = "asp-fragment"; + private const string ControllerAttributeName = "asp-controller"; + private const string RouteAttributeName = "asp-route"; + private const string RouteValuesDictionaryName = "asp-all-route-data"; + private const string RouteValuesPrefix = "asp-route-"; - [HtmlAttributeName(ActionAttributeName)] - public string Action { get; set; } + [HtmlAttributeName(ActionAttributeName)] + public string Action { get; set; } - [HtmlAttributeName(ControllerAttributeName)] - public string Controller { get; set; } + [HtmlAttributeName(ControllerAttributeName)] + public string Controller { get; set; } - [HtmlAttributeName(AreaAttributeName)] - public string Area { get; set; } + [HtmlAttributeName(AreaAttributeName)] + public string Area { get; set; } - [HtmlAttributeName(PageAttributeName)] - public string Page { get; set; } + [HtmlAttributeName(PageAttributeName)] + public string Page { get; set; } - [HtmlAttributeName(PageHandlerAttributeName)] - public string PageHandler { get; set; } + [HtmlAttributeName(PageHandlerAttributeName)] + public string PageHandler { get; set; } - [HtmlAttributeName(FragmentAttributeName)] - public string Fragment { get; set; } + [HtmlAttributeName(FragmentAttributeName)] + public string Fragment { get; set; } - [HtmlAttributeName(RouteAttributeName)] - public string Route { get; set; } + [HtmlAttributeName(RouteAttributeName)] + public string Route { get; set; } - [EditorBrowsable(EditorBrowsableState.Never)] - public string Method { get; set; } + [EditorBrowsable(EditorBrowsableState.Never)] + public string Method { get; set; } - [HtmlAttributeName(RouteValuesDictionaryName, DictionaryAttributePrefix = RouteValuesPrefix)] - public IDictionary RouteValues { get; set; } + [HtmlAttributeName(RouteValuesDictionaryName, DictionaryAttributePrefix = RouteValuesPrefix)] + public IDictionary RouteValues { get; set; } -#endregion + #endregion - public AbpDynamicFormTagHelper(AbpDynamicFormTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpDynamicFormTagHelper(AbpDynamicFormTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 410a3d1454..38f55ca04e 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 @@ -15,298 +15,297 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +public class AbpDynamicFormTagHelperService : AbpTagHelperService { - public class AbpDynamicFormTagHelperService : AbpTagHelperService + private readonly HtmlEncoder _htmlEncoder; + private readonly IHtmlGenerator _htmlGenerator; + private readonly IServiceProvider _serviceProvider; + private readonly IStringLocalizer _localizer; + + public AbpDynamicFormTagHelperService( + HtmlEncoder htmlEncoder, + IHtmlGenerator htmlGenerator, + IServiceProvider serviceProvider, + IStringLocalizer localizer) { - private readonly HtmlEncoder _htmlEncoder; - private readonly IHtmlGenerator _htmlGenerator; - private readonly IServiceProvider _serviceProvider; - private readonly IStringLocalizer _localizer; - - public AbpDynamicFormTagHelperService( - HtmlEncoder htmlEncoder, - IHtmlGenerator htmlGenerator, - IServiceProvider serviceProvider, - IStringLocalizer localizer) - { - _htmlEncoder = htmlEncoder; - _htmlGenerator = htmlGenerator; - _serviceProvider = serviceProvider; - _localizer = localizer; - } + _htmlEncoder = htmlEncoder; + _htmlGenerator = htmlGenerator; + _serviceProvider = serviceProvider; + _localizer = localizer; + } - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) - { - var list = InitilizeFormGroupContentsContext(context, output); + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + var list = InitilizeFormGroupContentsContext(context, output); - NormalizeTagMode(context, output); + NormalizeTagMode(context, output); - var childContent = await output.GetChildContentAsync(); + var childContent = await output.GetChildContentAsync(); - await ConvertToMvcForm(context, output); + await ConvertToMvcForm(context, output); - await ProcessFieldsAsync(context, output); + await ProcessFieldsAsync(context, output); - RemoveFormGroupItemsNotInModel(context, output, list); + RemoveFormGroupItemsNotInModel(context, output, list); - SetContent(context, output, list, childContent); + SetContent(context, output, list, childContent); - SetFormAttributes(context, output); + SetFormAttributes(context, output); - await SetSubmitButton(context, output); - } + await SetSubmitButton(context, output); + } - protected virtual async Task ConvertToMvcForm(TagHelperContext context, TagHelperOutput output) + protected virtual async Task ConvertToMvcForm(TagHelperContext context, TagHelperOutput output) + { + var formTagHelper = new FormTagHelper(_htmlGenerator) { - var formTagHelper = new FormTagHelper(_htmlGenerator) - { - Action = TagHelper.Action, - Controller = TagHelper.Controller, - Area = TagHelper.Area, - Page = TagHelper.Page, - PageHandler = TagHelper.PageHandler, - Antiforgery = true, - Fragment = TagHelper.Fragment, - Route = TagHelper.Route, - Method = TagHelper.Method, - RouteValues = TagHelper.RouteValues, - ViewContext = TagHelper.ViewContext - }; - - var formTagOutput = await formTagHelper.ProcessAndGetOutputAsync(output.Attributes, context, "form", TagMode.StartTagAndEndTag); - - await formTagOutput.GetChildContentAsync(); - - output.PostContent.AppendHtml(formTagOutput.PostContent); - output.PreContent.AppendHtml(formTagOutput.PreContent); - } + Action = TagHelper.Action, + Controller = TagHelper.Controller, + Area = TagHelper.Area, + Page = TagHelper.Page, + PageHandler = TagHelper.PageHandler, + Antiforgery = true, + Fragment = TagHelper.Fragment, + Route = TagHelper.Route, + Method = TagHelper.Method, + RouteValues = TagHelper.RouteValues, + ViewContext = TagHelper.ViewContext + }; + + var formTagOutput = await formTagHelper.ProcessAndGetOutputAsync(output.Attributes, context, "form", TagMode.StartTagAndEndTag); + + await formTagOutput.GetChildContentAsync(); + + output.PostContent.AppendHtml(formTagOutput.PostContent); + output.PreContent.AppendHtml(formTagOutput.PreContent); + } + + protected virtual void NormalizeTagMode(TagHelperContext context, TagHelperOutput output) + { + output.TagMode = TagMode.StartTagAndEndTag; + output.TagName = "form"; + } + + protected virtual void SetFormAttributes(TagHelperContext context, TagHelperOutput output) + { + output.Attributes.AddIfNotContains("method", "post"); + } + + protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List items, TagHelperContent childContent) + { + var contentBuilder = new StringBuilder(""); - protected virtual void NormalizeTagMode(TagHelperContext context, TagHelperOutput output) + foreach (var item in items.OrderBy(o => o.Order)) { - output.TagMode = TagMode.StartTagAndEndTag; - output.TagName = "form"; + contentBuilder.AppendLine(item.HtmlContent); } - protected virtual void SetFormAttributes(TagHelperContext context, TagHelperOutput output) + var content = childContent.GetContent(); + if (content.Contains(AbpFormContentPlaceHolder)) { - output.Attributes.AddIfNotContains("method", "post"); + content = content.Replace(AbpFormContentPlaceHolder, contentBuilder.ToString()); } - - protected virtual void SetContent(TagHelperContext context, TagHelperOutput output, List items, TagHelperContent childContent) + else { - var contentBuilder = new StringBuilder(""); - - foreach (var item in items.OrderBy(o => o.Order)) - { - contentBuilder.AppendLine(item.HtmlContent); - } + content = contentBuilder + content; + } - var content = childContent.GetContent(); - if (content.Contains(AbpFormContentPlaceHolder)) - { - content = content.Replace(AbpFormContentPlaceHolder, contentBuilder.ToString()); - } - else - { - content = contentBuilder + content; - } + output.Content.SetHtmlContent(content); + } - output.Content.SetHtmlContent(content); + protected virtual async Task SetSubmitButton(TagHelperContext context, TagHelperOutput output) + { + if (!TagHelper.SubmitButton ?? true) + { + return; } - protected virtual async Task SetSubmitButton(TagHelperContext context, TagHelperOutput output) - { - if (!TagHelper.SubmitButton ?? true) - { - return; - } + var buttonHtml = await ProcessSubmitButtonAndGetContentAsync(context, output); - var buttonHtml = await ProcessSubmitButtonAndGetContentAsync(context, output); + output.PostContent.AppendHtml(buttonHtml); + } - output.PostContent.AppendHtml(buttonHtml); - } + protected virtual List InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) + { + var items = new List(); + context.Items[FormGroupContents] = items; + return items; + } - protected virtual List InitilizeFormGroupContentsContext(TagHelperContext context, TagHelperOutput output) - { - var items = new List(); - context.Items[FormGroupContents] = items; - return items; - } + protected virtual async Task ProcessFieldsAsync(TagHelperContext context, TagHelperOutput output) + { + var models = GetModels(context, output); - protected virtual async Task ProcessFieldsAsync(TagHelperContext context, TagHelperOutput output) + foreach (var model in models) { - var models = GetModels(context, output); - - foreach (var model in models) + if (IsSelectGroup(context, model)) { - if (IsSelectGroup(context, model)) - { - await ProcessSelectGroupAsync(context, output, model); - } - else - { - await ProcessInputGroupAsync(context, output, model); - } + await ProcessSelectGroupAsync(context, output, model); + } + else + { + await ProcessInputGroupAsync(context, output, model); } } + } - protected virtual void RemoveFormGroupItemsNotInModel(TagHelperContext context, TagHelperOutput output, List items) - { - var models = GetModels(context, output); + protected virtual void RemoveFormGroupItemsNotInModel(TagHelperContext context, TagHelperOutput output, List items) + { + var models = GetModels(context, output); - items.RemoveAll(x => models.All(m => !m.Name.Equals(x.PropertyName, StringComparison.InvariantCultureIgnoreCase))); - } + items.RemoveAll(x => models.All(m => !m.Name.Equals(x.PropertyName, StringComparison.InvariantCultureIgnoreCase))); + } - protected virtual async Task ProcessSelectGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model) - { - var abpSelectTagHelper = GetSelectGroupTagHelper(context, output, model); + protected virtual async Task ProcessSelectGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model) + { + var abpSelectTagHelper = GetSelectGroupTagHelper(context, output, model); - await abpSelectTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag); - } + await abpSelectTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag); + } - protected virtual AbpTagHelper GetSelectGroupTagHelper(TagHelperContext context, TagHelperOutput output, ModelExpression model) - { - return IsRadioGroup(model.ModelExplorer) ? - GetAbpRadioInputTagHelper(model) : - GetSelectTagHelper(model); - } + protected virtual AbpTagHelper GetSelectGroupTagHelper(TagHelperContext context, TagHelperOutput output, ModelExpression model) + { + return IsRadioGroup(model.ModelExplorer) ? + GetAbpRadioInputTagHelper(model) : + GetSelectTagHelper(model); + } - protected virtual AbpTagHelper GetSelectTagHelper(ModelExpression model) - { - var abpSelectTagHelper = _serviceProvider.GetRequiredService(); - abpSelectTagHelper.AspFor = model; - abpSelectTagHelper.AspItems = null; - abpSelectTagHelper.ViewContext = TagHelper.ViewContext; - return abpSelectTagHelper; - } + protected virtual AbpTagHelper GetSelectTagHelper(ModelExpression model) + { + var abpSelectTagHelper = _serviceProvider.GetRequiredService(); + abpSelectTagHelper.AspFor = model; + abpSelectTagHelper.AspItems = null; + abpSelectTagHelper.ViewContext = TagHelper.ViewContext; + return abpSelectTagHelper; + } - protected virtual AbpTagHelper GetAbpRadioInputTagHelper(ModelExpression model) - { - var radioButtonAttribute = model.ModelExplorer.GetAttribute(); - var abpRadioInputTagHelper = _serviceProvider.GetRequiredService(); - abpRadioInputTagHelper.AspFor = model; - abpRadioInputTagHelper.AspItems = null; - abpRadioInputTagHelper.Inline = radioButtonAttribute.Inline; - abpRadioInputTagHelper.Disabled = radioButtonAttribute.Disabled; - abpRadioInputTagHelper.ViewContext = TagHelper.ViewContext; - return abpRadioInputTagHelper; - } + protected virtual AbpTagHelper GetAbpRadioInputTagHelper(ModelExpression model) + { + var radioButtonAttribute = model.ModelExplorer.GetAttribute(); + var abpRadioInputTagHelper = _serviceProvider.GetRequiredService(); + abpRadioInputTagHelper.AspFor = model; + abpRadioInputTagHelper.AspItems = null; + abpRadioInputTagHelper.Inline = radioButtonAttribute.Inline; + abpRadioInputTagHelper.Disabled = radioButtonAttribute.Disabled; + abpRadioInputTagHelper.ViewContext = TagHelper.ViewContext; + return abpRadioInputTagHelper; + } - protected virtual async Task ProcessSubmitButtonAndGetContentAsync(TagHelperContext context, TagHelperOutput output) - { - var abpButtonTagHelper = _serviceProvider.GetRequiredService(); - var attributes = new TagHelperAttributeList { new TagHelperAttribute("type", "submit") }; - abpButtonTagHelper.Text = _localizer["Submit"]; - abpButtonTagHelper.ButtonType = AbpButtonType.Primary; + protected virtual async Task ProcessSubmitButtonAndGetContentAsync(TagHelperContext context, TagHelperOutput output) + { + var abpButtonTagHelper = _serviceProvider.GetRequiredService(); + var attributes = new TagHelperAttributeList { new TagHelperAttribute("type", "submit") }; + abpButtonTagHelper.Text = _localizer["Submit"]; + abpButtonTagHelper.ButtonType = AbpButtonType.Primary; - return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag); - } + return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag); + } - protected virtual async Task ProcessInputGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model) - { - var abpInputTagHelper = _serviceProvider.GetRequiredService(); - abpInputTagHelper.AspFor = model; - abpInputTagHelper.ViewContext = TagHelper.ViewContext; - abpInputTagHelper.DisplayRequiredSymbol = TagHelper.RequiredSymbols ?? true; + protected virtual async Task ProcessInputGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model) + { + var abpInputTagHelper = _serviceProvider.GetRequiredService(); + abpInputTagHelper.AspFor = model; + abpInputTagHelper.ViewContext = TagHelper.ViewContext; + abpInputTagHelper.DisplayRequiredSymbol = TagHelper.RequiredSymbols ?? true; - await abpInputTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag); - } + await abpInputTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag); + } - protected virtual List GetModels(TagHelperContext context, TagHelperOutput output) + protected virtual List GetModels(TagHelperContext context, TagHelperOutput output) + { + return TagHelper.Model.ModelExplorer.Properties.Aggregate(new List(), ExploreModelsRecursively); + } + + protected virtual List ExploreModelsRecursively(List list, ModelExplorer model) + { + if (model.GetAttribute() != null) { - return TagHelper.Model.ModelExplorer.Properties.Aggregate(new List(), ExploreModelsRecursively); + return list; } - protected virtual List ExploreModelsRecursively(List list, ModelExplorer model) + if (IsCsharpClassOrPrimitive(model.ModelType) || IsListOfCsharpClassOrPrimitive(model.ModelType)) { - if (model.GetAttribute() != null) - { - return list; - } - - if (IsCsharpClassOrPrimitive(model.ModelType) || IsListOfCsharpClassOrPrimitive(model.ModelType)) - { - list.Add(ModelExplorerToModelExpressionConverter(model)); - - return list; - } - - if (IsListOfSelectItem(model.ModelType)) - { - return list; - } + list.Add(ModelExplorerToModelExpressionConverter(model)); - return model.Properties.Aggregate(list, ExploreModelsRecursively); + return list; } - protected virtual ModelExpression ModelExplorerToModelExpressionConverter(ModelExplorer explorer) + if (IsListOfSelectItem(model.ModelType)) { - var temp = explorer; - var propertyName = explorer.Metadata.PropertyName; - - while (temp?.Container?.Metadata?.PropertyName != null) - { - temp = temp.Container; - propertyName = temp.Metadata.PropertyName + "." + propertyName; - } - - return new ModelExpression(propertyName, explorer); + return list; } - protected virtual bool IsListOfCsharpClassOrPrimitive(Type type) - { - var genericType = type.GenericTypeArguments.FirstOrDefault(); + return model.Properties.Aggregate(list, ExploreModelsRecursively); + } - if (genericType == null || !IsCsharpClassOrPrimitive(genericType)) - { - return false; - } + protected virtual ModelExpression ModelExplorerToModelExpressionConverter(ModelExplorer explorer) + { + var temp = explorer; + var propertyName = explorer.Metadata.PropertyName; - return type.ToString().StartsWith("System.Collections.Generic.IEnumerable`") || type.ToString().StartsWith("System.Collections.Generic.List`"); + while (temp?.Container?.Metadata?.PropertyName != null) + { + temp = temp.Container; + propertyName = temp.Metadata.PropertyName + "." + propertyName; } - protected virtual bool IsCsharpClassOrPrimitive(Type type) - { - if (type == null) - { - return false; - } + return new ModelExpression(propertyName, explorer); + } - return type.IsPrimitive || - type.IsValueType || - type == typeof(string) || - type == typeof(Guid) || - type == typeof(DateTime) || - type == typeof(ValueType) || - type == typeof(TimeSpan) || - type == typeof(DateTimeOffset) || - type.IsEnum; - } + protected virtual bool IsListOfCsharpClassOrPrimitive(Type type) + { + var genericType = type.GenericTypeArguments.FirstOrDefault(); - protected virtual bool IsListOfSelectItem(Type type) + if (genericType == null || !IsCsharpClassOrPrimitive(genericType)) { - return type == typeof(List) || type == typeof(IEnumerable); + return false; } - protected virtual bool IsSelectGroup(TagHelperContext context, ModelExpression model) - { - return IsEnum(model.ModelExplorer) || AreSelectItemsProvided(model.ModelExplorer); - } + return type.ToString().StartsWith("System.Collections.Generic.IEnumerable`") || type.ToString().StartsWith("System.Collections.Generic.List`"); + } - protected virtual bool IsEnum(ModelExplorer explorer) + protected virtual bool IsCsharpClassOrPrimitive(Type type) + { + if (type == null) { - return explorer.Metadata.IsEnum; + return false; } - protected virtual bool AreSelectItemsProvided(ModelExplorer explorer) - { - return explorer.GetAttribute() != null; - } + return type.IsPrimitive || + type.IsValueType || + type == typeof(string) || + type == typeof(Guid) || + type == typeof(DateTime) || + type == typeof(ValueType) || + type == typeof(TimeSpan) || + type == typeof(DateTimeOffset) || + type.IsEnum; + } - protected virtual bool IsRadioGroup(ModelExplorer explorer) - { - return explorer.GetAttribute() != null; - } + protected virtual bool IsListOfSelectItem(Type type) + { + return type == typeof(List) || type == typeof(IEnumerable); + } + + protected virtual bool IsSelectGroup(TagHelperContext context, ModelExpression model) + { + return IsEnum(model.ModelExplorer) || AreSelectItemsProvided(model.ModelExplorer); + } + + protected virtual bool IsEnum(ModelExplorer explorer) + { + return explorer.Metadata.IsEnum; + } + + protected virtual bool AreSelectItemsProvided(ModelExplorer explorer) + { + return explorer.GetAttribute() != null; + } + + protected virtual bool IsRadioGroup(ModelExplorer explorer) + { + return explorer.GetAttribute() != null; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelper.cs index 9606cc1b77..af0ff4e2d3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelper.cs @@ -1,15 +1,14 @@ using Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.DependencyInjection; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +[HtmlTargetElement("abp-form-content", TagStructure = TagStructure.WithoutEndTag)] +public class AbpFormContentTagHelper : AbpTagHelper, ITransientDependency { - [HtmlTargetElement("abp-form-content", TagStructure = TagStructure.WithoutEndTag)] - public class AbpFormContentTagHelper : AbpTagHelper, ITransientDependency + public AbpFormContentTagHelper(AbpFormContentTagHelperService tagHelperService) + : base(tagHelperService) { - public AbpFormContentTagHelper(AbpFormContentTagHelperService tagHelperService) - : base(tagHelperService) - { - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelperService.cs index 9cb06d5364..d973c31fb2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormContentTagHelperService.cs @@ -1,15 +1,14 @@ using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +public class AbpFormContentTagHelperService : AbpTagHelperService { - public class AbpFormContentTagHelperService : AbpTagHelperService + public override void Process(TagHelperContext context, TagHelperOutput output) { - public override void Process(TagHelperContext context, TagHelperOutput output) - { - output.Attributes.Clear(); - output.TagName = "div"; - output.TagMode = TagMode.StartTagAndEndTag; - output.Content.SetContent(AbpFormContentPlaceHolder); - } + output.Attributes.Clear(); + output.TagName = "div"; + output.TagMode = TagMode.StartTagAndEndTag; + output.Content.SetContent(AbpFormContentPlaceHolder); } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormControlSize.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormControlSize.cs index 79070b559e..94acbca97e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormControlSize.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpFormControlSize.cs @@ -1,10 +1,9 @@ -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +public enum AbpFormControlSize { - public enum AbpFormControlSize - { - Default, - Small, - Medium, - Large - } + Default, + Small, + Medium, + Large } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpIdNameTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpIdNameTagHelper.cs index 7bc1c674a7..d24e247abe 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpIdNameTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpIdNameTagHelper.cs @@ -7,43 +7,42 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.Options; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +[HtmlTargetElement(Attributes = "abp-id-name")] +public class AbpIdNameTagHelper : AbpTagHelper { - [HtmlTargetElement(Attributes = "abp-id-name")] - public class AbpIdNameTagHelper : AbpTagHelper - { - /// - /// Make sure this TagHelper is executed first. - /// - public override int Order => -1000 - 1; + /// + /// Make sure this TagHelper is executed first. + /// + public override int Order => -1000 - 1; - [HtmlAttributeName("abp-id-name")] - public ModelExpression IdNameFor { get; set; } + [HtmlAttributeName("abp-id-name")] + public ModelExpression IdNameFor { get; set; } - private readonly MvcViewOptions _mvcViewOptions; + private readonly MvcViewOptions _mvcViewOptions; - public AbpIdNameTagHelper(IOptions mvcViewOptions) - { - _mvcViewOptions = mvcViewOptions.Value; - } + public AbpIdNameTagHelper(IOptions mvcViewOptions) + { + _mvcViewOptions = mvcViewOptions.Value; + } - public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + if (IdNameFor != null) { - if (IdNameFor != null) + if (!context.AllAttributes.Any(x => x.Name.Equals("id", StringComparison.OrdinalIgnoreCase))) { - if (!context.AllAttributes.Any(x => x.Name.Equals("id", StringComparison.OrdinalIgnoreCase))) - { - var id = TagBuilder.CreateSanitizedId(IdNameFor.Name, _mvcViewOptions.HtmlHelperOptions.IdAttributeDotReplacement); - output.Attributes.Add("id", id); - } - - if (!context.AllAttributes.Any(x => x.Name.Equals("name", StringComparison.OrdinalIgnoreCase))) - { - output.Attributes.Add("name", IdNameFor.Name); - } + var id = TagBuilder.CreateSanitizedId(IdNameFor.Name, _mvcViewOptions.HtmlHelperOptions.IdAttributeDotReplacement); + output.Attributes.Add("id", id); } - return Task.CompletedTask; + if (!context.AllAttributes.Any(x => x.Name.Equals("name", StringComparison.OrdinalIgnoreCase))) + { + output.Attributes.Add("name", IdNameFor.Name); + } } + + return Task.CompletedTask; } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs index fdab58203a..5778e47692 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelper.cs @@ -2,48 +2,47 @@ using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Razor.TagHelpers; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +public class AbpInputTagHelper : AbpTagHelper { - public class AbpInputTagHelper : AbpTagHelper - { - public ModelExpression AspFor { get; set; } + public ModelExpression AspFor { get; set; } - public string Label { get; set; } + public string Label { get; set; } - [HtmlAttributeName("info")] - public string InfoText { get; set; } + [HtmlAttributeName("info")] + public string InfoText { get; set; } - [HtmlAttributeName("disabled")] - public bool IsDisabled { get; set; } = false; + [HtmlAttributeName("disabled")] + public bool IsDisabled { get; set; } = false; - [HtmlAttributeName("readonly")] - public bool? IsReadonly { get; set; } = false; + [HtmlAttributeName("readonly")] + public bool? IsReadonly { get; set; } = false; - public bool AutoFocus { get; set; } + public bool AutoFocus { get; set; } - [HtmlAttributeName("type")] - public string InputTypeName { get; set; } + [HtmlAttributeName("type")] + public string InputTypeName { get; set; } - public AbpFormControlSize Size { get; set; } = AbpFormControlSize.Default; + public AbpFormControlSize Size { get; set; } = AbpFormControlSize.Default; - [HtmlAttributeName("required-symbol")] - public bool DisplayRequiredSymbol { get; set; } = true; + [HtmlAttributeName("required-symbol")] + public bool DisplayRequiredSymbol { get; set; } = true; - [HtmlAttributeName("asp-format")] - public string Format { get; set; } + [HtmlAttributeName("asp-format")] + public string Format { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public string Value { get; set; } + public string Value { get; set; } - public bool SuppressLabel { get; set; } + public bool SuppressLabel { get; set; } - public CheckBoxHiddenInputRenderMode? CheckBoxHiddenInputRenderMode { get; set; } + public CheckBoxHiddenInputRenderMode? CheckBoxHiddenInputRenderMode { get; set; } - public AbpInputTagHelper(AbpInputTagHelperService tagHelperService) - : base(tagHelperService) - { + public AbpInputTagHelper(AbpInputTagHelperService tagHelperService) + : base(tagHelperService) + { - } } } 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 1ef29c799b..3bc99436ca 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 @@ -11,462 +11,461 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Microsoft.AspNetCore.Razor.TagHelpers; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions; -namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form +namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; + +public class AbpInputTagHelperService : AbpTagHelperService { - public class AbpInputTagHelperService : AbpTagHelperService + private readonly IHtmlGenerator _generator; + private readonly HtmlEncoder _encoder; + private readonly IAbpTagHelperLocalizer _tagHelperLocalizer; + + public AbpInputTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IAbpTagHelperLocalizer tagHelperLocalizer) { - private readonly IHtmlGenerator _generator; - private readonly HtmlEncoder _encoder; - private readonly IAbpTagHelperLocalizer _tagHelperLocalizer; + _generator = generator; + _encoder = encoder; + _tagHelperLocalizer = tagHelperLocalizer; + } - public AbpInputTagHelperService(IHtmlGenerator generator, HtmlEncoder encoder, IAbpTagHelperLocalizer tagHelperLocalizer) - { - _generator = generator; - _encoder = encoder; - _tagHelperLocalizer = tagHelperLocalizer; - } + public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + { + var (innerHtml, isCheckBox) = await GetFormInputGroupAsHtmlAsync(context, output); - public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) + if (isCheckBox && TagHelper.CheckBoxHiddenInputRenderMode.HasValue) { - var (innerHtml, isCheckBox) = await GetFormInputGroupAsHtmlAsync(context, output); - - if (isCheckBox && TagHelper.CheckBoxHiddenInputRenderMode.HasValue) - { - TagHelper.ViewContext.CheckBoxHiddenInputRenderMode = TagHelper.CheckBoxHiddenInputRenderMode.Value; - } + TagHelper.ViewContext.CheckBoxHiddenInputRenderMode = TagHelper.CheckBoxHiddenInputRenderMode.Value; + } - var order = TagHelper.AspFor.ModelExplorer.GetDisplayOrder(); + var order = TagHelper.AspFor.ModelExplorer.GetDisplayOrder(); - AddGroupToFormGroupContents( - context, - TagHelper.AspFor.Name, - SurroundInnerHtmlAndGet(context, output, innerHtml, isCheckBox), - order, - out var suppress - ); + AddGroupToFormGroupContents( + context, + TagHelper.AspFor.Name, + SurroundInnerHtmlAndGet(context, output, innerHtml, isCheckBox), + order, + out var suppress + ); - if (suppress) - { - output.SuppressOutput(); - } - else + if (suppress) + { + output.SuppressOutput(); + } + else + { + output.TagMode = TagMode.StartTagAndEndTag; + output.TagName = "div"; + LeaveOnlyGroupAttributes(context, output); + output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3"); + if (isCheckBox) { - output.TagMode = TagMode.StartTagAndEndTag; - output.TagName = "div"; - LeaveOnlyGroupAttributes(context, output); - output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3"); - if (isCheckBox) - { - output.Attributes.AddClass("form-check"); - } - output.Content.AppendHtml(innerHtml); + output.Attributes.AddClass("form-check"); } + output.Content.AppendHtml(innerHtml); } + } - protected virtual async Task<(string, bool)> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output) - { - var (inputTag, isCheckBox) = await GetInputTagHelperOutputAsync(context, output); + protected virtual async Task<(string, bool)> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output) + { + var (inputTag, isCheckBox) = await GetInputTagHelperOutputAsync(context, output); - var inputHtml = inputTag.Render(_encoder); - var label = await GetLabelAsHtmlAsync(context, output, inputTag, isCheckBox); - var info = GetInfoAsHtml(context, output, inputTag, isCheckBox); - var validation = isCheckBox ? "" : await GetValidationAsHtmlAsync(context, output, inputTag); + var inputHtml = inputTag.Render(_encoder); + var label = await GetLabelAsHtmlAsync(context, output, inputTag, isCheckBox); + var info = GetInfoAsHtml(context, output, inputTag, isCheckBox); + var validation = isCheckBox ? "" : await GetValidationAsHtmlAsync(context, output, inputTag); - return (GetContent(context, output, label, inputHtml, validation, info, isCheckBox), isCheckBox); - } + return (GetContent(context, output, label, inputHtml, validation, info, isCheckBox), isCheckBox); + } - protected virtual async Task GetValidationAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag) + protected virtual async Task GetValidationAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag) + { + if (IsOutputHidden(inputTag)) { - if (IsOutputHidden(inputTag)) - { - return ""; - } + return ""; + } - var validationMessageTagHelper = new ValidationMessageTagHelper(_generator) - { - For = TagHelper.AspFor, - ViewContext = TagHelper.ViewContext - }; + var validationMessageTagHelper = new ValidationMessageTagHelper(_generator) + { + For = TagHelper.AspFor, + ViewContext = TagHelper.ViewContext + }; - var attributeList = new TagHelperAttributeList { { "class", "text-danger" } }; + var attributeList = new TagHelperAttributeList { { "class", "text-danger" } }; - return await validationMessageTagHelper.RenderAsync(attributeList, context, _encoder, "span", TagMode.StartTagAndEndTag); - } + return await validationMessageTagHelper.RenderAsync(attributeList, context, _encoder, "span", TagMode.StartTagAndEndTag); + } - protected virtual string GetContent(TagHelperContext context, TagHelperOutput output, string label, string inputHtml, string validation, string infoHtml, bool isCheckbox) - { - var innerContent = isCheckbox ? - inputHtml + label : - label + inputHtml; + protected virtual string GetContent(TagHelperContext context, TagHelperOutput output, string label, string inputHtml, string validation, string infoHtml, bool isCheckbox) + { + var innerContent = isCheckbox ? + inputHtml + label : + label + inputHtml; - return innerContent + infoHtml + validation; - } + return innerContent + infoHtml + validation; + } - protected virtual string SurroundInnerHtmlAndGet(TagHelperContext context, TagHelperOutput output, string innerHtml, bool isCheckbox) - { - return "
" + - Environment.NewLine + innerHtml + Environment.NewLine + - "
"; - } + protected virtual string SurroundInnerHtmlAndGet(TagHelperContext context, TagHelperOutput output, string innerHtml, bool isCheckbox) + { + return "
" + + Environment.NewLine + innerHtml + Environment.NewLine + + "
"; + } - protected virtual TagHelper GetInputTagHelper(TagHelperContext context, TagHelperOutput output) + protected virtual TagHelper GetInputTagHelper(TagHelperContext context, TagHelperOutput output) + { + if (TagHelper.AspFor.ModelExplorer.GetAttribute