Skip to content

Commit 46bd789

Browse files
authored
Merge pull request #334 from SergerGood/switch-expression
Switch expression
2 parents ac8b6af + b226a23 commit 46bd789

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

src/Benchmark/TestAdaptHelper.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,13 @@ public static Foo SetupFooInstance()
7272

7373
private static void SetupCompiler(MapsterCompilerType type)
7474
{
75-
switch (type)
75+
TypeAdapterConfig.GlobalSettings.Compiler = type switch
7676
{
77-
case MapsterCompilerType.Default:
78-
TypeAdapterConfig.GlobalSettings.Compiler = _defaultCompiler;
79-
break;
80-
case MapsterCompilerType.Roslyn:
81-
TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileWithDebugInfo();
82-
break;
83-
case MapsterCompilerType.FEC:
84-
TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileFast();
85-
break;
86-
default:
87-
throw new ArgumentOutOfRangeException(nameof(type));
88-
}
77+
MapsterCompilerType.Default => _defaultCompiler,
78+
MapsterCompilerType.Roslyn => exp => exp.CompileWithDebugInfo(),
79+
MapsterCompilerType.FEC => exp => exp.CompileFast(),
80+
_ => throw new ArgumentOutOfRangeException(nameof(type)),
81+
};
8982
}
9083
public static void ConfigureMapster(Foo fooInstance, MapsterCompilerType type)
9184
{

0 commit comments

Comments
 (0)