Changeset 391 for binary-improvements2/MarkersMod
- Timestamp:
- Aug 7, 2022, 3:02:24 PM (2 years ago)
- Location:
- binary-improvements2/MarkersMod
- Files:
-
- 1 added
- 1 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/MarkersMod/MarkersMod.csproj
r390 r391 8 8 <ProjectGuid>{2A008E16-6EB8-4B85-A175-3CB89D9FF4AE}</ProjectGuid> 9 9 <OutputType>Library</OutputType> 10 <RootNamespace> MarkersMod</RootNamespace>10 <RootNamespace>Examples</RootNamespace> 11 11 <AssemblyName>MarkersMod</AssemblyName> 12 12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> … … 16 16 <DebugType>none</DebugType> 17 17 <Optimize>true</Optimize> 18 <OutputPath>..\bin\Mods\ MarkersMod\</OutputPath>18 <OutputPath>..\bin\Mods\Xample_MarkersMod\</OutputPath> 19 19 <ErrorReport>prompt</ErrorReport> 20 20 <WarningLevel>4</WarningLevel> … … 23 23 </PropertyGroup> 24 24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Profiler|AnyCPU' "> 25 <OutputPath>..\bin\Mods\ MarkersMod\</OutputPath>25 <OutputPath>..\bin\Mods\Xample_MarkersMod\</OutputPath> 26 26 <DefineConstants>ENABLE_PROFILER</DefineConstants> 27 27 <Optimize>true</Optimize> … … 32 32 </PropertyGroup> 33 33 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 34 <OutputPath>..\bin\Mods\ MarkersMod\</OutputPath>34 <OutputPath>..\bin\Mods\Xample_MarkersMod\</OutputPath> 35 35 <DebugType>full</DebugType> 36 36 <DebugSymbols>true</DebugSymbols> … … 55 55 </ItemGroup> 56 56 <ItemGroup> 57 <Compile Include=" AssemblyInfo.cs" />58 <Compile Include=" API.cs" />59 <Compile Include=" Markers.cs" />57 <Compile Include="src\ModApi.cs" /> 58 <Compile Include="src\AssemblyInfo.cs" /> 59 <Compile Include="src\Markers.cs" /> 60 60 </ItemGroup> 61 61 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> … … 71 71 <Private>False</Private> 72 72 </ProjectReference> 73 <ProjectReference Include="..\ MapRendering\WebAndMapRendering.csproj">74 <Project>{ a1847b5f-7bfc-4bcd-94aa-a6c9fb7e7c54}</Project>75 <Name>Web AndMapRendering</Name>73 <ProjectReference Include="..\WebServer\WebServer.csproj"> 74 <Project>{01b5f981-b9fd-4364-8f9e-9127130d2542}</Project> 75 <Name>WebServer</Name> 76 76 <Private>False</Private> 77 77 </ProjectReference> -
binary-improvements2/MarkersMod/src/AssemblyInfo.cs
r390 r391 7 7 [assembly: AssemblyDescription ("")] 8 8 [assembly: AssemblyConfiguration ("")] 9 [assembly: AssemblyCompany (" ")]9 [assembly: AssemblyCompany ("The Fun Pimps LLC")] 10 10 [assembly: AssemblyProduct ("")] 11 [assembly: AssemblyCopyright (" ")]11 [assembly: AssemblyCopyright ("The Fun Pimps LLC")] 12 12 [assembly: AssemblyTrademark ("")] 13 13 [assembly: AssemblyCulture ("")] -
binary-improvements2/MarkersMod/src/Markers.cs
r390 r391 2 2 using System.Net; 3 3 using AllocsFixes.JSON; 4 using AllocsFixes.NetConnections.Servers.Web;5 using AllocsFixes.NetConnections.Servers.Web.API;4 using Webserver; 5 using Webserver.WebAPI; 6 6 7 7 namespace Examples { 8 class Markers : AbsRestApi {9 private const int NumRandomMarkers = 5;8 public class Markers : AbsRestApi { 9 private const int numRandomMarkers = 5; 10 10 11 11 private readonly Dictionary<string, (int, int)> markers = new Dictionary<string, (int, int)> (); 12 12 13 private static readonly J SONArray emptyResult = new JSONArray ();13 private static readonly JsonArray emptyResult = new JsonArray (); 14 14 15 15 public Markers () { 16 16 GameRandom random = GameRandomManager.Instance.CreateGameRandom (); 17 17 18 for (int i = 0; i < NumRandomMarkers; i++) {18 for (int i = 0; i < numRandomMarkers; i++) { 19 19 int lat = random.RandomRange (-1000, 1001); 20 20 int lng = random.RandomRange (-1000, 1001); … … 28 28 29 29 if (string.IsNullOrEmpty (id)) { 30 J SONArray result = new JSONArray ();30 JsonArray result = new JsonArray (); 31 31 32 foreach ( KeyValuePair<string, (int, int)> kvpin markers) {33 J SONObject marker = new JSONObject ();34 marker.Add ("id", new J SONString (kvp.Key));35 marker.Add ("lat", new J SONNumber (kvp.Value.Item1));36 marker.Add ("lng", new J SONNumber (kvp.Value.Item2));32 foreach ((string markerId, (int, int) coordinates) in markers) { 33 JsonObject marker = new JsonObject (); 34 marker.Add ("id", new JsonString (markerId)); 35 marker.Add ("lat", new JsonNumber (coordinates.Item1)); 36 marker.Add ("lng", new JsonNumber (coordinates.Item2)); 37 37 result.Add (marker); 38 38 } … … 48 48 49 49 { 50 J SONArray result = new JSONArray ();51 J SONObject marker = new JSONObject ();52 marker.Add ("id", new J SONString (id));53 marker.Add ("lat", new J SONNumber (location.Item1));54 marker.Add ("lng", new J SONNumber (location.Item2));50 JsonArray result = new JsonArray (); 51 JsonObject marker = new JsonObject (); 52 marker.Add ("id", new JsonString (id)); 53 marker.Add ("lat", new JsonNumber (location.Item1)); 54 marker.Add ("lng", new JsonNumber (location.Item2)); 55 55 result.Add (marker); 56 56 SendEnvelopedResult (_context, result); … … 58 58 } 59 59 60 protected override void HandleRestPost (RequestContext _context, J SONNode _jsonBody) {61 if (!(_jsonBody is J SONObject bodyObject)) {60 protected override void HandleRestPost (RequestContext _context, JsonNode _jsonBody) { 61 if (!(_jsonBody is JsonObject bodyObject)) { 62 62 SendEnvelopedResult (_context, null, HttpStatusCode.BadRequest, _jsonBody, "BODY_NOT_OBJECT"); 63 63 return; … … 77 77 markers.Add (newId, (lat, lng)); 78 78 79 J SONString result = new JSONString (newId);80 SendEnvelopedResult (_context, result );79 JsonString result = new JsonString (newId); 80 SendEnvelopedResult (_context, result, HttpStatusCode.Created); 81 81 } 82 82 83 protected override void HandleRestPut (RequestContext _context, J SONNode _jsonBody) {84 if (!(_jsonBody is J SONObject bodyObject)) {83 protected override void HandleRestPut (RequestContext _context, JsonNode _jsonBody) { 84 if (!(_jsonBody is JsonObject bodyObject)) { 85 85 SendEnvelopedResult (_context, null, HttpStatusCode.BadRequest, _jsonBody, "BODY_NOT_OBJECT"); 86 86 return; … … 99 99 string id = _context.RequestPath; 100 100 101 if (!markers.TryGetValue (id, out (int, int) location)) {101 if (!markers.TryGetValue (id, out _)) { 102 102 SendEnvelopedResult (_context, null, HttpStatusCode.NotFound, _jsonBody, "ID_NOT_FOUND"); 103 103 return; … … 106 106 markers [id] = (lat, lng); 107 107 108 J SONObject result = new JSONObject ();109 result.Add ("id", new J SONString (id));110 result.Add ("lat", new J SONNumber (lat));111 result.Add ("lng", new J SONNumber (lng));108 JsonObject result = new JsonObject (); 109 result.Add ("id", new JsonString (id)); 110 result.Add ("lat", new JsonNumber (lat)); 111 result.Add ("lng", new JsonNumber (lng)); 112 112 SendEnvelopedResult (_context, result); 113 113 } -
binary-improvements2/MarkersMod/src/ModApi.cs
r390 r391 1 1 namespace Examples { 2 public class API: IModApi {2 public class ModApi : IModApi { 3 3 public void InitMod (Mod _modInstance) { 4 4 }
Note:
See TracChangeset
for help on using the changeset viewer.