Created
September 22, 2013 10:04
-
-
Save arturaz/6658569 to your computer and use it in GitHub Desktop.
Matching ADT with C# using https://gist.github.com/arturaz/6658547 helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static LeaderboardName getLeaderboardName( | |
Kind kind, LeaderboardKind lbKind | |
) { | |
return new LeaderboardName( | |
kind.match().returning<string> | |
.when<Kind.Global>(_ => string.Format( | |
"lb_{0}", leaderboardKindToString(lbKind) | |
)) | |
.when<Kind.World>(kw => string.Format( | |
"lb_w{0}_{1}", kw.world, leaderboardKindToString(lbKind) | |
)) | |
.when<Kind.Level>(kl => string.Format( | |
"lb_w{0}_l{1}{2}_{3}", kl.world, kl.level, kl.bonus ? "b" : "", | |
leaderboardKindToString(lbKind) | |
)) | |
.get(), | |
lbKind | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment