Changeset 389 for binary-improvements2/MapRendering/Web
- Timestamp:
- Aug 7, 2022, 1:11:51 AM (2 years ago)
- Location:
- binary-improvements2
- Files:
-
- 5 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/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
Note:
See TracChangeset
for help on using the changeset viewer.