source: TFP-WebServer/WebServer/src/WebAPI/APIs/ServerState/ServerInfo.cs@ 474

Last change on this file since 474 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.3 KB
RevLine 
[404]1using System.Collections.Generic;
[391]2using JetBrains.Annotations;
[402]3using Utf8Json;
[437]4using Webserver.Permissions;
[391]5
[437]6namespace Webserver.WebAPI.APIs.ServerState {
[391]7 [UsedImplicitly]
[457]8 public class ServerInfo : KeyValueListAbs {
9 public ServerInfo () : base ("ServerInfo") {
10 }
[391]11
[457]12 protected override void iterateList (ref JsonWriter _writer, ref bool _first) {
[391]13 GameServerInfo gsi = ConnectionManager.Instance.LocalServerInfo;
14
[404]15 IList<GameInfoString> list = EnumUtils.Values<GameInfoString> ();
16 for (int i = 0; i < list.Count; i++) {
17 GameInfoString stringGamePref = list [i];
[457]18 addItem (ref _writer, ref _first, stringGamePref.ToStringCached (), gsi.GetValue (stringGamePref));
[391]19 }
20
[404]21 IList<GameInfoInt> ints = EnumUtils.Values<GameInfoInt> ();
22 for (int i = 0; i < ints.Count; i++) {
23 GameInfoInt intGamePref = ints [i];
[457]24 addItem (ref _writer, ref _first, intGamePref.ToStringCached (), gsi.GetValue (intGamePref));
[391]25 }
26
[404]27 IList<GameInfoBool> prefs = EnumUtils.Values<GameInfoBool> ();
28 for (int i = 0; i < prefs.Count; i++) {
29 GameInfoBool boolGamePref = prefs [i];
[457]30 addItem (ref _writer, ref _first, boolGamePref.ToStringCached (), gsi.GetValue (boolGamePref));
[391]31 }
32 }
[437]33
34 public override int DefaultPermissionLevel () => AdminWebModules.PermissionLevelGuest;
[391]35 }
36}
Note: See TracBrowser for help on using the repository browser.