Last change
on this file since 490 was 457, checked in by alloc, 16 months ago |
Refactored APIs GamePrefs, GameStats, ServerInfo: Using arrays as result instead of objects, code sharing
|
File size:
1.0 KB
|
Rev | Line | |
---|
[437] | 1 | using JetBrains.Annotations;
|
---|
| 2 | using Utf8Json;
|
---|
| 3 |
|
---|
| 4 | namespace Webserver.WebAPI.APIs.ServerState {
|
---|
| 5 | [UsedImplicitly]
|
---|
[457] | 6 | public class GameStats : KeyValueListAbs {
|
---|
| 7 | public GameStats () : base ("GameStats") {
|
---|
| 8 | }
|
---|
[437] | 9 |
|
---|
[457] | 10 | protected override void iterateList (ref JsonWriter _writer, ref bool _first) {
|
---|
[437] | 11 | foreach (EnumGameStats stat in EnumUtils.Values<EnumGameStats> ()) {
|
---|
| 12 | string name = stat.ToStringCached ();
|
---|
| 13 | global::GameStats.EnumType? type = global::GameStats.GetStatType (stat);
|
---|
| 14 |
|
---|
| 15 | switch (type) {
|
---|
| 16 | case global::GameStats.EnumType.Int:
|
---|
[457] | 17 | addItem (ref _writer, ref _first, name, global::GameStats.GetInt (stat));
|
---|
[437] | 18 | break;
|
---|
| 19 | case global::GameStats.EnumType.Float:
|
---|
[457] | 20 | addItem (ref _writer, ref _first, name, global::GameStats.GetFloat (stat));
|
---|
[437] | 21 | break;
|
---|
| 22 | case global::GameStats.EnumType.String:
|
---|
[457] | 23 | addItem (ref _writer, ref _first, name, global::GameStats.GetString (stat));
|
---|
[437] | 24 | break;
|
---|
| 25 | case global::GameStats.EnumType.Bool:
|
---|
[457] | 26 | addItem (ref _writer, ref _first, name, global::GameStats.GetBool (stat));
|
---|
[437] | 27 | break;
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.