Changeset 402 for binary-improvements2/WebServer/src/WebAPI/APIs/WebMods.cs
- Timestamp:
- Jan 27, 2023, 7:28:00 PM (22 months ago)
- Location:
- binary-improvements2/WebServer/src/WebAPI/APIs
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/WebAPI/APIs/WebMods.cs
r401 r402 1 using AllocsFixes.JSON;2 1 using JetBrains.Annotations; 2 using Utf8Json; 3 3 4 namespace Webserver.WebAPI {4 namespace Webserver.WebAPI.APIs { 5 5 [UsedImplicitly] 6 public class GetWebMods : AbsWebAPI{7 private readonly JsonArray loadedWebMods = new JsonArray ();6 public class WebMods : AbsRestApi { 7 private readonly byte[] loadedWebMods; 8 8 9 public GetWebMods (Web _parent) { 9 public WebMods (Web _parent) { 10 JsonWriter writer = new JsonWriter (); 11 writer.WriteBeginArray (); 12 13 bool first = true; 10 14 foreach (WebMod webMod in _parent.webMods) { 11 JsonObject modJson = new JsonObject (); 15 if (!first) { 16 writer.WriteValueSeparator (); 17 } 18 first = false; 19 20 writer.WriteBeginObject (); 21 22 writer.WriteString ("name"); 23 writer.WriteNameSeparator (); 24 writer.WriteString (webMod.ParentMod.Name); 12 25 13 modJson.Add ("name", new JsonString (webMod.ParentMod.ModInfo.Name.Value));14 15 26 string webModReactBundle = webMod.ReactBundle; 16 27 if (webModReactBundle != null) { 17 modJson.Add ("bundle", new JsonString (webModReactBundle)); 28 writer.WriteValueSeparator (); 29 writer.WriteString ("bundle"); 30 writer.WriteNameSeparator (); 31 writer.WriteString (webModReactBundle); 18 32 } 19 33 20 34 string webModCssFile = webMod.CssPath; 21 35 if (webModCssFile != null) { 22 modJson.Add ("css", new JsonString (webModCssFile)); 36 writer.WriteValueSeparator (); 37 writer.WriteString ("css"); 38 writer.WriteNameSeparator (); 39 writer.WriteString (webModCssFile); 23 40 } 41 42 writer.WriteEndObject (); 43 } 44 45 writer.WriteEndArray (); 24 46 25 loadedWebMods.Add (modJson); 26 } 47 loadedWebMods = writer.ToUtf8ByteArray (); 27 48 } 28 49 29 public override void HandleRequest (RequestContext _context) { 30 WebUtils.WriteJson (_context.Response, loadedWebMods); 50 protected override void HandleRestGet (RequestContext _context) { 51 PrepareEnvelopedResult (out JsonWriter writer); 52 writer.WriteRaw (loadedWebMods); 53 SendEnvelopedResult (_context, ref writer); 31 54 } 32 55
Note:
See TracChangeset
for help on using the changeset viewer.