-
Notifications
You must be signed in to change notification settings - Fork 2
/
CachedTypeService.cs
31 lines (27 loc) · 3.37 KB
/
CachedTypeService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using Soenneker.Reflection.Cache;
using Soenneker.Reflection.Cache.Types;
using Soenneker.Utils.AutoBogus.Generators.Types;
using Soenneker.Utils.AutoBogus.Generators.Types.Immutables;
namespace Soenneker.Utils.AutoBogus.Services;
internal static class CachedTypeService
{
public static ReflectionCache ReflectionCache { get; set; } = new ReflectionCache();
internal static readonly Lazy<CachedType> TypeGenerator = new(() => ReflectionCache.GetCachedType(typeof(TypeGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> EnumerableGenerator = new(() => ReflectionCache.GetCachedType(typeof(EnumerableGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> ListGenerator = new(() => ReflectionCache.GetCachedType(typeof(ListGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> SetGenerator = new(() => ReflectionCache.GetCachedType(typeof(SetGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> ReadOnlyDictionaryGenerator = new(() => ReflectionCache.GetCachedType(typeof(ReadOnlyDictionaryGenerator<,>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> NullableGenerator = new(() => ReflectionCache.GetCachedType(typeof(NullableGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> EnumGenerator = new(() => ReflectionCache.GetCachedType(typeof(EnumGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> ArrayGenerator = new(() => ReflectionCache.GetCachedType(typeof(ArrayGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> DictionaryGenerator = new(() => ReflectionCache.GetCachedType(typeof(DictionaryGenerator<,>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> CollectionGenerator = new(() => ReflectionCache.GetCachedType(typeof(CollectionGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> ReadOnlyCollectionGenerator = new(() => ReflectionCache.GetCachedType(typeof(ReadOnlyCollectionGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> ImmutableListGenerator = new(() => ReflectionCache.GetCachedType(typeof(ImmutableListGenerator<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> IDictionary = new(() => ReflectionCache.GetCachedType(typeof(IDictionary<,>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> IEnumerable = new(() => ReflectionCache.GetCachedType(typeof(IEnumerable<>)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> AutoFaker = new(() => ReflectionCache.GetCachedType(typeof(AutoFaker)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
internal static readonly Lazy<CachedType> Object = new(() => ReflectionCache.GetCachedType(typeof(object)), System.Threading.LazyThreadSafetyMode.PublicationOnly);
}