|
|
@ -1,6 +1,7 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Collections.Immutable;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
@ -12,16 +13,22 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly ConcurrentDictionary<Type, bool> CachedTypes = new ConcurrentDictionary<Type, bool>();
|
|
|
|
private static readonly ConcurrentDictionary<Type, bool> CachedTypes = new ConcurrentDictionary<Type, bool>();
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly List<Type> ExcludeTypes = new List<Type>();
|
|
|
|
private readonly List<Type> _excludeTypes = new List<Type>();
|
|
|
|
|
|
|
|
|
|
|
|
public AbpHasExtraPropertiesJsonConverterFactory(params Type[] excludeTypes)
|
|
|
|
public virtual AbpHasExtraPropertiesJsonConverterFactory AddExcludeTypes(params Type[] excludeTypes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExcludeTypes.AddIfNotContains(excludeTypes);
|
|
|
|
_excludeTypes.AddIfNotContains(excludeTypes);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual IReadOnlyList<Type> GetExcludeTypes()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _excludeTypes.ToImmutableList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool CanConvert(Type typeToConvert)
|
|
|
|
public override bool CanConvert(Type typeToConvert)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ExcludeTypes.Contains(typeToConvert))
|
|
|
|
if (_excludeTypes.Contains(typeToConvert))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|