private static void SetupCompiler(MapsterCompilerType type) { TypeAdapterConfig.GlobalSettings.Compiler = type switch { MapsterCompilerType.Default => _defaultCompiler, MapsterCompilerType.Roslyn => exp => exp.CompileWithDebugInfo(), MapsterCompilerType.FEC => exp => exp.CompileFast(), _ => throw new ArgumentOutOfRangeException(nameof(type)), }; }
private static void SetupCompiler(MapsterCompilerType type) { switch (type) { case MapsterCompilerType.Default: TypeAdapterConfig.GlobalSettings.Compiler = _defaultCompiler; break; case MapsterCompilerType.Roslyn: TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo(); break; case MapsterCompilerType.FEC: TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileFast(); break; default: throw new ArgumentOutOfRangeException(nameof(type)); } }
public static void ConfigureMapster(Customer customerInstance, MapsterCompilerType type) { SetupCompiler(type); TypeAdapterConfig.GlobalSettings.Compile(typeof(Customer), typeof(CustomerDTO)); //recompile customerInstance.Adapt <Customer, CustomerDTO>(); //exercise }
public static void ConfigureMapster(Foo fooInstance, MapsterCompilerType type) { SetupCompiler(type); TypeAdapterConfig.GlobalSettings.Compile(typeof(Foo), typeof(Foo)); //recompile fooInstance.Adapt <Foo, Foo>(); //exercise }