コード例 #1
0
 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)),
     };
 }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
 public static void ConfigureMapster(Customer customerInstance, MapsterCompilerType type)
 {
     SetupCompiler(type);
     TypeAdapterConfig.GlobalSettings.Compile(typeof(Customer), typeof(CustomerDTO)); //recompile
     customerInstance.Adapt <Customer, CustomerDTO>();                                //exercise
 }
コード例 #4
0
 public static void ConfigureMapster(Foo fooInstance, MapsterCompilerType type)
 {
     SetupCompiler(type);
     TypeAdapterConfig.GlobalSettings.Compile(typeof(Foo), typeof(Foo)); //recompile
     fooInstance.Adapt <Foo, Foo>();                                     //exercise
 }