Changeset 389
- Timestamp:
- Aug 7, 2022, 1:11:51 AM (2 years ago)
- Location:
- binary-improvements2
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2
- Property svn:ignore
-
old new 1 .idea 1 2 bin 2 .idea 3 server-fixes.sln.DotSettings.user
-
- Property svn:ignore
-
binary-improvements2/7dtd-server-fixes
- Property svn:ignore
-
old new 1 bin 1 2 obj
-
- Property svn:ignore
-
binary-improvements2/7dtd-server-fixes/src/JSON/JSONBoolean.cs
r351 r389 34 34 throw new MalformedJSONException ("No valid boolean found"); 35 35 } 36 37 public override string AsString => value ? "true" : "false"; 38 public override int AsInt => value ? 1 : 0; 39 public override double AsDouble => AsInt; 36 40 } 37 41 } -
binary-improvements2/7dtd-server-fixes/src/JSON/JSONNull.cs
r351 r389 1 using System; 1 2 using System.Text; 2 3 … … 18 19 return new JSONNull (); 19 20 } 21 22 public override string AsString => throw new NotSupportedException (); 23 public override int AsInt => throw new NotSupportedException (); 24 public override double AsDouble => throw new NotSupportedException (); 20 25 } 21 26 } -
binary-improvements2/7dtd-server-fixes/src/JSON/JSONNumber.cs
r351 r389 109 109 throw new MalformedJSONException ("End of JSON reached before parsing number finished"); 110 110 } 111 112 public override string AsString => value.ToCultureInvariantString (); 113 public override int AsInt => GetInt (); 114 public override double AsDouble => value; 111 115 } 112 116 } -
binary-improvements2/7dtd-server-fixes/src/JSON/JSONObject.cs
r383 r389 7 7 8 8 public JSONNode this [string _name] { 9 get { return nodes [_name]; }10 set { nodes [_name] = value; }9 get => nodes [_name]; 10 set => nodes [_name] = value; 11 11 } 12 12 13 public int Count { 14 get { return nodes.Count; } 15 } 13 public int Count => nodes.Count; 16 14 17 public List<string> Keys { 18 get { return new List<string> (nodes.Keys); } 19 } 15 public List<string> Keys => new List<string> (nodes.Keys); 20 16 21 17 public bool ContainsKey (string _name) { 22 18 return nodes.ContainsKey (_name); 19 } 20 21 public bool TryGetValue (string _name, out JSONNode _node) { 22 return nodes.TryGetValue (_name, out _node); 23 23 } 24 24 -
binary-improvements2/7dtd-server-fixes/src/JSON/JSONString.cs
r351 r389 114 114 throw new MalformedJSONException ("End of JSON reached before parsing string finished"); 115 115 } 116 117 public override string AsString => value; 118 public override int AsInt => int.Parse (value); 119 public override double AsDouble => double.Parse (value); 116 120 } 117 121 } -
binary-improvements2/7dtd-server-fixes/src/JSON/JSONValue.cs
r325 r389 1 1 namespace AllocsFixes.JSON { 2 2 public abstract class JSONValue : JSONNode { 3 public abstract string AsString { get; } 4 public abstract int AsInt { get; } 5 public abstract double AsDouble { get; } 3 6 } 4 7 } -
binary-improvements2/AllocsCommands
- Property svn:ignore
-
old new 1 bin 1 2 obj
-
- Property svn:ignore
-
binary-improvements2/MapRendering
- Property svn:ignore
-
old new 1 bin 1 2 obj
-
- Property svn:ignore
-
binary-improvements2/MapRendering/Web/API/AbsRestApi.cs
r388 r389 105 105 } 106 106 107 protected bool TryGetJsonField (JSONObject _body, string _fieldName, out int _value) { 108 _value = default; 109 110 if (!_body.TryGetValue (_fieldName, out JSONNode fieldNode)) { 111 return false; 112 } 113 114 if (!(fieldNode is JSONValue valueField)) { 115 return false; 116 } 117 118 try { 119 _value = valueField.AsInt; 120 return true; 121 } catch (Exception) { 122 return false; 123 } 124 } 125 107 126 protected abstract void HandleRestGet (RequestContext _context); 108 127 -
binary-improvements2/MapRendering/Web/Handlers/ApiHandler.cs
r387 r389 22 22 Object[] apiEmptyCtorArgs = { }; 23 23 24 foreach (Type t in Assembly.GetExecutingAssembly ().GetTypes ()) {25 if (!t.IsAbstract && t.IsSubclassOf (typeof (AbsWebAPI))){26 ConstructorInfo ctor = t.GetConstructor (apiWithParentCtorTypes);27 28 29 30 continue;31 24 25 ReflectionHelpers.FindTypesImplementingBase (typeof (AbsWebAPI), _type => { 26 ConstructorInfo ctor = _type.GetConstructor (apiWithParentCtorTypes); 27 if (ctor != null) { 28 AbsWebAPI apiInstance = (AbsWebAPI) ctor.Invoke (apiWithParentCtorArgs); 29 addApi (apiInstance); 30 return; 31 } 32 32 33 ctor = t.GetConstructor (apiEmptyCtorTypes); 34 if (ctor != null) { 35 AbsWebAPI apiInstance = (AbsWebAPI) ctor.Invoke (apiEmptyCtorArgs); 36 addApi (apiInstance); 37 } 33 ctor = _type.GetConstructor (apiEmptyCtorTypes); 34 if (ctor != null) { 35 AbsWebAPI apiInstance = (AbsWebAPI) ctor.Invoke (apiEmptyCtorArgs); 36 addApi (apiInstance); 38 37 } 39 } 38 }); 40 39 41 40 // Permissions that don't map to a real API -
binary-improvements2/MapRendering/Web/WebUtils.cs
r387 r389 25 25 netWriteSampler.Begin (); 26 26 #endif 27 WriteText (_resp, sb.ToString(), _ mimeType:MimeJson);27 WriteText (_resp, sb.ToString(), _statusCode, MimeJson); 28 28 #if ENABLE_PROFILER 29 29 netWriteSampler.End (); … … 32 32 33 33 public static void WriteText (HttpListenerResponse _resp, string _text, HttpStatusCode _statusCode = HttpStatusCode.OK, string _mimeType = null) { 34 _resp.StatusCode = (int)_statusCode; 35 _resp.ContentType = _mimeType ?? MimePlain; 36 _resp.ContentEncoding = Encoding.UTF8; 37 34 38 byte[] buf = Encoding.UTF8.GetBytes (_text); 35 39 _resp.ContentLength64 = buf.Length; 36 40 _resp.OutputStream.Write (buf, 0, buf.Length); 37 38 _resp.ContentType = _mimeType ?? MimePlain;39 _resp.ContentEncoding = Encoding.UTF8;40 _resp.StatusCode = (int)_statusCode;41 41 } 42 42 -
binary-improvements2/SpaceWizards.HttpListener
-
Property svn:ignore
set to
obj
-
Property svn:ignore
set to
Note:
See TracChangeset
for help on using the changeset viewer.