- Timestamp:
- Feb 16, 2023, 3:50:53 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/UrlHandlers/SseHandler.cs
r402 r404 4 4 using System.Reflection; 5 5 using System.Threading; 6 using Webserver.Permissions; 6 7 using Webserver.SSE; 7 8 … … 17 18 private bool shutdown; 18 19 20 private static readonly Type[] ctorTypes = { typeof (SseHandler) }; 21 private static readonly object[] ctorParams = new object[1]; 22 19 23 public SseHandler (string _moduleName = null) : base (_moduleName) { 20 Type[] ctorTypes = { typeof (SseHandler) }; 21 object[] ctorParams = { this }; 24 ctorParams[0] = this; 22 25 23 foreach (Type t in Assembly.GetExecutingAssembly ().GetTypes ()) { 24 if (t.IsAbstract || !t.IsSubclassOf (typeof (AbsEvent))) { 25 continue; 26 } 26 ReflectionHelpers.FindTypesImplementingBase (typeof (AbsEvent), apiFoundCallback); 27 } 27 28 28 ConstructorInfo ctor = t.GetConstructor (ctorTypes); 29 if (ctor == null) { 30 continue; 31 } 29 private void apiFoundCallback (Type _type) { 30 ConstructorInfo ctor = _type.GetConstructor (ctorTypes); 31 if (ctor == null) { 32 return; 33 } 32 34 33 AbsEvent apiInstance = (AbsEvent)ctor.Invoke (ctorParams); 34 AddEvent (apiInstance.Name, apiInstance); 35 } 35 AbsEvent apiInstance = (AbsEvent)ctor.Invoke (ctorParams); 36 AddEvent (apiInstance.Name, apiInstance); 36 37 } 37 38 … … 52 53 public void AddEvent (string _eventName, AbsEvent _eventInstance) { 53 54 events.Add (_eventName, _eventInstance); 54 WebPermissions.Instance.AddKnownModule ($"webevent.{_eventName}", _eventInstance.DefaultPermissionLevel ());55 AdminWebModules.Instance.AddKnownModule ($"webevent.{_eventName}", _eventInstance.DefaultPermissionLevel ()); 55 56 } 56 57 … … 89 90 90 91 private bool IsAuthorizedForEvent (string _eventName, int _permissionLevel) { 91 return WebPermissions.Instance.ModuleAllowedWithLevel ($"webevent.{_eventName}", _permissionLevel);92 return AdminWebModules.Instance.ModuleAllowedWithLevel ($"webevent.{_eventName}", _permissionLevel); 92 93 } 93 94
Note:
See TracChangeset
for help on using the changeset viewer.