From e9fc742b7e901de2b69032d95c96345f410eb145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 29 Apr 2020 03:33:28 +0300 Subject: [PATCH] Added ObjectExtensions to ApplicationConfigurationDto --- .../ApplicationConfigurationDto.cs | 3 + .../CachedObjectExtensionsDtoService.cs | 90 +++++++++++++ .../ICachedObjectExtensionsDtoService.cs | 7 + .../LocalizedDisplayNameDto.cs | 37 +++++ .../ModuleObjectExtensionDto.cs | 11 ++ .../ModuleObjectExtraPropertyAttributeDto.cs | 36 +++++ .../ModuleObjectExtraPropertyExtensionDto.cs | 19 +++ ...ModuleObjectExtraPropertyUiExtensionDto.cs | 12 ++ ...leObjectExtraPropertyUiFormExtensionDto.cs | 10 ++ ...eObjectExtraPropertyUiTableExtensionDto.cs | 10 ++ .../ObjectExtensionConfigurationDto.cs | 12 ++ .../ObjectExtending/ObjectExtensionsDto.cs | 11 ++ .../AbpApplicationConfigurationAppService.cs | 10 +- .../AspNetCoreApiDescriptionModelProvider.cs | 2 +- .../Volo/Abp/Reflection/TypeHelper.cs | 118 ++++++++++++++++ .../MethodParameterApiDescriptionModel.cs | 5 +- .../Abp/Http/Modeling/ModelingTypeHelper.cs | 127 ------------------ .../Modeling/ParameterApiDescriptionModel.cs | 5 +- .../Modeling/PropertyApiDescriptionModel.cs | 12 +- .../ReturnValueApiDescriptionModel.cs | 5 +- .../Http/Modeling/TypeApiDescriptionModel.cs | 3 +- .../ModuleObjectExtensionConfiguration.cs | 2 +- ...eObjectExtensionConfigurationDictionary.cs | 2 +- ...eObjectExtensionConfigurationExtensions.cs | 2 +- 24 files changed, 404 insertions(+), 147 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizedDisplayNameDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtensionDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyAttributeDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyExtensionDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiExtensionDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs delete mode 100644 framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModelingTypeHelper.cs 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 cc62a1e1b9..da99a3e948 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 @@ -1,4 +1,5 @@ using System; +using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations @@ -19,5 +20,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations public MultiTenancyInfoDto MultiTenancy { get; set; } public CurrentTenantDto CurrentTenant { get; set; } + + public ObjectExtensionsDto ObjectExtensions { get; set; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs new file mode 100644 index 0000000000..7ff5f034cb --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs @@ -0,0 +1,90 @@ +using System.Collections.Generic; +using Volo.Abp.DependencyInjection; +using Volo.Abp.ObjectExtending; +using Volo.Abp.Reflection; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoService, ISingletonDependency + { + private volatile ObjectExtensionsDto _cachedValue; + private readonly object _syncLock = new object(); + + public virtual ObjectExtensionsDto Get() + { + if (_cachedValue == null) + { + lock (_syncLock) + { + if (_cachedValue == null) + { + _cachedValue = GenerateCacheValue(); + } + } + } + + return _cachedValue; + } + + protected virtual ObjectExtensionsDto GenerateCacheValue() + { + var objectExtensionsDto = new ObjectExtensionsDto + { + Modules = new Dictionary() + }; + + foreach (var moduleConfig in ObjectExtensionManager.Instance.Modules) + { + var moduleExtensionDto = objectExtensionsDto.Modules[moduleConfig.Key] = new ModuleExtensionDto + { + Objects = new Dictionary() + }; + + foreach (var objectConfig in moduleConfig.Value) + { + var moduleObjectExtensionDto = moduleExtensionDto.Objects[objectConfig.Key] = + new ModuleObjectExtensionDto + { + ExtraProperties = new Dictionary() + }; + + foreach (var propertyConfig in objectConfig.Value.GetProperties()) + { + var propertyExtensionDto = moduleObjectExtensionDto.ExtraProperties[propertyConfig.Name] = + new ModuleObjectExtraPropertyExtensionDto + { + Type = TypeHelper.GetFullNameHandlingNullableAndGenerics(propertyConfig.Type), + TypeSimple = TypeHelper.GetSimplifiedName(propertyConfig.Type), + Attributes = new List(), + DisplayName = LocalizedDisplayNameDto.CreateOrNull(propertyConfig.DisplayName), + Ui = new ModuleObjectExtraPropertyUiExtensionDto + { + CreateForm = new ModuleObjectExtraPropertyUiFormExtensionDto + { + Visible = true + }, + EditForm = new ModuleObjectExtraPropertyUiFormExtensionDto + { + Visible = true + }, + Table = new ModuleObjectExtraPropertyUiTableExtensionDto + { + Visible = true + } + } + }; + + foreach (var attribute in propertyConfig.Attributes) + { + propertyExtensionDto.Attributes.Add( + ModuleObjectExtraPropertyAttributeDto.Create(attribute) + ); + } + } + } + } + + return objectExtensionsDto; + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs new file mode 100644 index 0000000000..f0163c8b55 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ICachedObjectExtensionsDtoService.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + public interface ICachedObjectExtensionsDtoService + { + ObjectExtensionsDto Get(); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizedDisplayNameDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizedDisplayNameDto.cs new file mode 100644 index 0000000000..748daa58b9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/LocalizedDisplayNameDto.cs @@ -0,0 +1,37 @@ +using System; +using JetBrains.Annotations; +using Volo.Abp.Localization; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class LocalizedDisplayNameDto + { + public string Name { get; set; } + + public string Resource { get; set; } + + [CanBeNull] + public static LocalizedDisplayNameDto CreateOrNull(ILocalizableString localizableString) + { + if (localizableString is LocalizableString localizableStringInstance) + { + return new LocalizedDisplayNameDto + { + Name = localizableStringInstance.Name, + Resource = LocalizationResourceNameAttribute.GetName(localizableStringInstance.ResourceType) + }; + } + + if (localizableString is FixedLocalizableString fixedLocalizableString) + { + return new LocalizedDisplayNameDto + { + Name = fixedLocalizableString.Value, + }; + } + + return null; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtensionDto.cs new file mode 100644 index 0000000000..0879fc60bd --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtensionDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleObjectExtensionDto + { + public Dictionary ExtraProperties { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyAttributeDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyAttributeDto.cs new file mode 100644 index 0000000000..d45bf7d8d4 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyAttributeDto.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Reflection; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleObjectExtraPropertyAttributeDto + { + public string Type { get; set; } + public string TypeSimple { get; set; } + public Dictionary Configuration { get; set; } + + public static ModuleObjectExtraPropertyAttributeDto Create(Attribute attribute) + { + var attributeType = attribute.GetType(); + var dto = new ModuleObjectExtraPropertyAttributeDto + { + Type = TypeHelper.GetFullNameHandlingNullableAndGenerics(attributeType), + TypeSimple = TypeHelper.GetSimplifiedName(attributeType), + Configuration = new Dictionary() + }; + + if (attribute is StringLengthAttribute stringLengthAttribute) + { + dto.Configuration["MaximumLength"] = stringLengthAttribute.MaximumLength; + dto.Configuration["MinimumLength"] = stringLengthAttribute.MinimumLength; + } + + //TODO: Others! + + return dto; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyExtensionDto.cs new file mode 100644 index 0000000000..853a27e294 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyExtensionDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleObjectExtraPropertyExtensionDto + { + public string Type { get; set; } + + public string TypeSimple { get; set; } + + public LocalizedDisplayNameDto DisplayName { get; set; } + + public ModuleObjectExtraPropertyUiExtensionDto Ui { get; set; } + + public List Attributes { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiExtensionDto.cs new file mode 100644 index 0000000000..fcb39f67c6 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiExtensionDto.cs @@ -0,0 +1,12 @@ +using System; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleObjectExtraPropertyUiExtensionDto + { + public ModuleObjectExtraPropertyUiTableExtensionDto Table { get; set; } + public ModuleObjectExtraPropertyUiFormExtensionDto CreateForm { get; set; } + public ModuleObjectExtraPropertyUiFormExtensionDto EditForm { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs new file mode 100644 index 0000000000..00411ba0f9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiFormExtensionDto.cs @@ -0,0 +1,10 @@ +using System; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleObjectExtraPropertyUiFormExtensionDto + { + public bool Visible { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs new file mode 100644 index 0000000000..9c2d202da9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ModuleObjectExtraPropertyUiTableExtensionDto.cs @@ -0,0 +1,10 @@ +using System; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleObjectExtraPropertyUiTableExtensionDto + { + public bool Visible { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs new file mode 100644 index 0000000000..096c2210c0 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionConfigurationDto.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ModuleExtensionDto + { + public Dictionary Objects { 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 new file mode 100644 index 0000000000..fd9665eab1 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ObjectExtensionsDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ObjectExtensionsDto + { + public Dictionary Modules { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index 4b4cf521c2..6271505ead 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Volo.Abp.Application.Services; +using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; using Volo.Abp.Authorization; using Volo.Abp.Features; @@ -30,6 +31,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations private readonly ISettingDefinitionManager _settingDefinitionManager; private readonly IFeatureDefinitionManager _featureDefinitionManager; private readonly ILanguageProvider _languageProvider; + private readonly ICachedObjectExtensionsDtoService _cachedObjectExtensionsDtoService; public AbpApplicationConfigurationAppService( IOptions localizationOptions, @@ -41,7 +43,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations ISettingProvider settingProvider, ISettingDefinitionManager settingDefinitionManager, IFeatureDefinitionManager featureDefinitionManager, - ILanguageProvider languageProvider) + ILanguageProvider languageProvider, + ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService) { _serviceProvider = serviceProvider; _abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider; @@ -51,6 +54,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations _settingDefinitionManager = settingDefinitionManager; _featureDefinitionManager = featureDefinitionManager; _languageProvider = languageProvider; + _cachedObjectExtensionsDtoService = cachedObjectExtensionsDtoService; _localizationOptions = localizationOptions.Value; _multiTenancyOptions = multiTenancyOptions.Value; } @@ -67,8 +71,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations CurrentUser = GetCurrentUser(), Setting = await GetSettingConfigAsync(), MultiTenancy = GetMultiTenancy(), - CurrentTenant = GetCurrentTenant() - + CurrentTenant = GetCurrentTenant(), + ObjectExtensions = _cachedObjectExtensionsDtoService.Get() }; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index f957fd894f..1042ee4d08 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -206,7 +206,7 @@ namespace Volo.Abp.AspNetCore.Mvc /* TODO: Add interfaces */ - var typeName = ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(type); + var typeName = TypeHelper.GetFullNameHandlingNullableAndGenerics(type); if (applicationModel.Types.ContainsKey(typeName)) { diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs index eeb0259321..1a31cc9f34 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Reflection/TypeHelper.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; +using JetBrains.Annotations; namespace Volo.Abp.Reflection { @@ -146,5 +147,122 @@ namespace Volo.Abp.Reflection return null; } + + public static string GetFullNameHandlingNullableAndGenerics([NotNull] Type type) + { + Check.NotNull(type, nameof(type)); + + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return type.GenericTypeArguments[0].FullName + "?"; + } + + if (type.IsGenericType) + { + var genericType = type.GetGenericTypeDefinition(); + return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetFullNameHandlingNullableAndGenerics).JoinAsString(",")}>"; + } + + return type.FullName; + } + + public static string GetSimplifiedName([NotNull] Type type) + { + Check.NotNull(type, nameof(type)); + + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return GetSimplifiedName(type.GenericTypeArguments[0]) + "?"; + } + + if (type.IsGenericType) + { + var genericType = type.GetGenericTypeDefinition(); + return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetSimplifiedName).JoinAsString(",")}>"; + } + + if (type == typeof(string)) + { + return "string"; + } + else if (type == typeof(int)) + { + return "number"; + } + else if (type == typeof(long)) + { + return "number"; + } + else if (type == typeof(bool)) + { + return "boolean"; + } + else if (type == typeof(char)) + { + return "string"; + } + else if (type == typeof(double)) + { + return "number"; + } + else if (type == typeof(float)) + { + return "number"; + } + else if (type == typeof(decimal)) + { + return "number"; + } + else if (type == typeof(DateTime)) + { + return "string"; + } + else if (type == typeof(DateTimeOffset)) + { + return "string"; + } + else if (type == typeof(TimeSpan)) + { + return "string"; + } + else if (type == typeof(Guid)) + { + return "string"; + } + else if (type == typeof(byte)) + { + return "number"; + } + else if (type == typeof(sbyte)) + { + return "number"; + } + else if (type == typeof(short)) + { + return "number"; + } + else if (type == typeof(ushort)) + { + return "number"; + } + else if (type == typeof(uint)) + { + return "number"; + } + else if (type == typeof(ulong)) + { + return "number"; + } + else if (type == typeof(IntPtr)) + { + return "number"; + } + else if (type == typeof(UIntPtr)) + { + return "number"; + } + + return type.FullName; + } } } diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/MethodParameterApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/MethodParameterApiDescriptionModel.cs index 4199e29ec0..211359d789 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/MethodParameterApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/MethodParameterApiDescriptionModel.cs @@ -1,5 +1,6 @@ using System; using System.Reflection; +using Volo.Abp.Reflection; namespace Volo.Abp.Http.Modeling { @@ -29,8 +30,8 @@ namespace Volo.Abp.Http.Modeling { Name = parameterInfo.Name, TypeAsString = parameterInfo.ParameterType.GetFullNameWithAssemblyName(), - Type = parameterInfo.ParameterType != null ? ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(parameterInfo.ParameterType) : null, - TypeSimple = parameterInfo.ParameterType != null ? ModelingTypeHelper.GetSimplifiedName(parameterInfo.ParameterType) : null, + Type = parameterInfo.ParameterType != null ? TypeHelper.GetFullNameHandlingNullableAndGenerics(parameterInfo.ParameterType) : null, + TypeSimple = parameterInfo.ParameterType != null ? TypeHelper.GetSimplifiedName(parameterInfo.ParameterType) : null, IsOptional = parameterInfo.IsOptional, DefaultValue = parameterInfo.HasDefaultValue ? parameterInfo.DefaultValue : null }; diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModelingTypeHelper.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModelingTypeHelper.cs deleted file mode 100644 index 2d4b2bac85..0000000000 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModelingTypeHelper.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using JetBrains.Annotations; - -namespace Volo.Abp.Http.Modeling -{ - public static class ModelingTypeHelper - { - public static string GetFullNameHandlingNullableAndGenerics([NotNull] Type type) - { - Check.NotNull(type, nameof(type)); - - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - return type.GenericTypeArguments[0].FullName + "?"; - } - - if (type.IsGenericType) - { - var genericType = type.GetGenericTypeDefinition(); - return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetFullNameHandlingNullableAndGenerics).JoinAsString(",")}>"; - } - - return type.FullName; - } - - public static string GetSimplifiedName([NotNull] Type type) - { - Check.NotNull(type, nameof(type)); - - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - return GetSimplifiedName(type.GenericTypeArguments[0]) + "?"; - } - - if (type.IsGenericType) - { - var genericType = type.GetGenericTypeDefinition(); - return $"{genericType.FullName.Left(genericType.FullName.IndexOf('`'))}<{type.GenericTypeArguments.Select(GetSimplifiedName).JoinAsString(",")}>"; - } - - if (type == typeof(string)) - { - return "string"; - } - else if (type == typeof(int)) - { - return "number"; - } - else if (type == typeof(long)) - { - return "number"; - } - else if (type == typeof(bool)) - { - return "boolean"; - } - else if (type == typeof(char)) - { - return "string"; - } - else if (type == typeof(double)) - { - return "number"; - } - else if (type == typeof(float)) - { - return "number"; - } - else if (type == typeof(decimal)) - { - return "number"; - } - else if (type == typeof(DateTime)) - { - return "string"; - } - else if (type == typeof(DateTimeOffset)) - { - return "string"; - } - else if (type == typeof(TimeSpan)) - { - return "string"; - } - else if (type == typeof(Guid)) - { - return "string"; - } - else if (type == typeof(byte)) - { - return "number"; - } - else if (type == typeof(sbyte)) - { - return "number"; - } - else if (type == typeof(short)) - { - return "number"; - } - else if (type == typeof(ushort)) - { - return "number"; - } - else if (type == typeof(uint)) - { - return "number"; - } - else if (type == typeof(ulong)) - { - return "number"; - } - else if (type == typeof(IntPtr)) - { - return "number"; - } - else if (type == typeof(UIntPtr)) - { - return "number"; - } - - return type.FullName; - } - } -} diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ParameterApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ParameterApiDescriptionModel.cs index 0be791053c..0450861a41 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ParameterApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ParameterApiDescriptionModel.cs @@ -1,4 +1,5 @@ using System; +using Volo.Abp.Reflection; namespace Volo.Abp.Http.Modeling { @@ -34,8 +35,8 @@ namespace Volo.Abp.Http.Modeling { Name = name, NameOnMethod = nameOnMethod, - Type = type != null ? ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(type) : null, - TypeSimple = type != null ? ModelingTypeHelper.GetSimplifiedName(type) : null, + Type = type != null ? TypeHelper.GetFullNameHandlingNullableAndGenerics(type) : null, + TypeSimple = type != null ? TypeHelper.GetSimplifiedName(type) : null, IsOptional = isOptional, DefaultValue = defaultValue, ConstraintTypes = constraintTypes, diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/PropertyApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/PropertyApiDescriptionModel.cs index ca8af7f22a..820d9a46f9 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/PropertyApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/PropertyApiDescriptionModel.cs @@ -21,18 +21,18 @@ namespace Volo.Abp.Http.Modeling if (TypeHelper.IsEnumerable(propertyInfo.PropertyType, out var itemType, includePrimitives: false)) { - typeName = $"[{ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(itemType)}]"; - simpleTypeName = $"[{ModelingTypeHelper.GetSimplifiedName(itemType)}]"; + typeName = $"[{TypeHelper.GetFullNameHandlingNullableAndGenerics(itemType)}]"; + simpleTypeName = $"[{TypeHelper.GetSimplifiedName(itemType)}]"; } else if (TypeHelper.IsDictionary(propertyInfo.PropertyType, out var keyType, out var valueType)) { - typeName = $"{{{ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(keyType)}:{ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(valueType)}}}"; - simpleTypeName = $"{{{ModelingTypeHelper.GetSimplifiedName(keyType)}:{ModelingTypeHelper.GetSimplifiedName(valueType)}}}"; + typeName = $"{{{TypeHelper.GetFullNameHandlingNullableAndGenerics(keyType)}:{TypeHelper.GetFullNameHandlingNullableAndGenerics(valueType)}}}"; + simpleTypeName = $"{{{TypeHelper.GetSimplifiedName(keyType)}:{TypeHelper.GetSimplifiedName(valueType)}}}"; } else { - typeName = ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(propertyInfo.PropertyType); - simpleTypeName = ModelingTypeHelper.GetSimplifiedName(propertyInfo.PropertyType); + typeName = TypeHelper.GetFullNameHandlingNullableAndGenerics(propertyInfo.PropertyType); + simpleTypeName = TypeHelper.GetSimplifiedName(propertyInfo.PropertyType); } return new PropertyApiDescriptionModel diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ReturnValueApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ReturnValueApiDescriptionModel.cs index d6532be6d4..2e0862ccce 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ReturnValueApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ReturnValueApiDescriptionModel.cs @@ -1,4 +1,5 @@ using System; +using Volo.Abp.Reflection; using Volo.Abp.Threading; namespace Volo.Abp.Http.Modeling @@ -21,8 +22,8 @@ namespace Volo.Abp.Http.Modeling return new ReturnValueApiDescriptionModel { - Type = ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(unwrappedType), - TypeSimple = ModelingTypeHelper.GetSimplifiedName(unwrappedType) + Type = TypeHelper.GetFullNameHandlingNullableAndGenerics(unwrappedType), + TypeSimple = TypeHelper.GetSimplifiedName(unwrappedType) }; } } diff --git a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/TypeApiDescriptionModel.cs b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/TypeApiDescriptionModel.cs index fcc4b034ea..161584279b 100644 --- a/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/TypeApiDescriptionModel.cs +++ b/framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/TypeApiDescriptionModel.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Volo.Abp.Reflection; namespace Volo.Abp.Http.Modeling { @@ -32,7 +33,7 @@ namespace Volo.Abp.Http.Modeling var typeModel = new TypeApiDescriptionModel { IsEnum = type.IsEnum, - BaseType = baseType != null ? ModelingTypeHelper.GetFullNameHandlingNullableAndGenerics(baseType) : null + BaseType = baseType != null ? TypeHelper.GetFullNameHandlingNullableAndGenerics(baseType) : null }; if (typeModel.IsEnum) diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfiguration.cs index 4972eace19..991e31b723 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfiguration.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.ObjectExtending { - public class ModuleObjectExtensionConfiguration : Dictionary + public class ModuleObjectExtensionConfiguration : Dictionary { } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationDictionary.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationDictionary.cs index a4ddf66473..6acbedbba6 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationDictionary.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationDictionary.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.ObjectExtending { - public class ModuleObjectExtensionConfigurationDictionary : Dictionary + public class ModuleObjectExtensionConfigurationDictionary : Dictionary { } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationExtensions.cs index 4397bfe088..1f3b682ffa 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ModuleObjectExtensionConfigurationExtensions.cs @@ -14,7 +14,7 @@ namespace Volo.Abp.ObjectExtending var configuration = objectConfiguration.GetOrAdd( objectName, () => new ModuleEntityObjectExtensionConfiguration() - ) as ModuleEntityObjectExtensionConfiguration; + ); configureAction(configuration);