@@ -224,51 +224,47 @@ public CSharpPlugin()
224224 Type type = GetType ( ) ;
225225 foreach ( MemberInfo member in type . GetMembers ( BindingFlags . NonPublic | BindingFlags . Instance ) )
226226 {
227- if ( member . MemberType != MemberTypes . Property && member . MemberType ! = MemberTypes . Field )
227+ if ( member . MemberType == MemberTypes . Property || member . MemberType = = MemberTypes . Field )
228228 {
229- continue ;
230- }
229+ if ( member . MemberType == MemberTypes . Property )
230+ {
231+ PropertyInfo property = member as PropertyInfo ;
232+ if ( ! property . CanWrite )
233+ {
234+ continue ;
235+ }
236+ }
237+ else
238+ {
239+ FieldInfo field = member as FieldInfo ;
240+ }
231241
232- if ( member . MemberType == MemberTypes . Property )
233- {
234- PropertyInfo property = member as PropertyInfo ;
235- if ( ! property . CanWrite )
242+ object [ ] reference_attributes = member . GetCustomAttributes ( typeof ( PluginReferenceAttribute ) , true ) ;
243+
244+ if ( reference_attributes . Length > 0 )
236245 {
237- continue ;
246+ PluginReferenceAttribute pluginReference = reference_attributes [ 0 ] as PluginReferenceAttribute ;
247+ pluginReferenceMembers [ pluginReference . Name ?? member . Name ] = member ;
238248 }
239249 }
240- else
250+ else if ( member . MemberType == MemberTypes . Method )
241251 {
242- FieldInfo field = member as FieldInfo ;
243- if ( field . IsInitOnly )
252+ MethodInfo method = member as MethodInfo ;
253+ object [ ] info_attributes = method . GetCustomAttributes ( typeof ( HookMethodAttribute ) , true ) ;
254+ if ( info_attributes . Length > 0 )
244255 {
245256 continue ;
246257 }
247- }
248258
249- object [ ] reference_attributes = member . GetCustomAttributes ( typeof ( PluginReferenceAttribute ) , true ) ;
250- if ( reference_attributes . Length > 0 )
251- {
252- PluginReferenceAttribute pluginReference = reference_attributes [ 0 ] as PluginReferenceAttribute ;
253- pluginReferenceMembers [ pluginReference . Name ?? member . Name ] = member ;
254- }
255- }
256- foreach ( MethodInfo method in type . GetMethods ( BindingFlags . NonPublic | BindingFlags . Instance ) )
257- {
258- object [ ] info_attributes = method . GetCustomAttributes ( typeof ( HookMethodAttribute ) , true ) ;
259- if ( info_attributes . Length > 0 )
260- {
261- continue ;
262- }
263-
264- if ( method . Name . Equals ( "OnFrame" ) )
265- {
266- HookedOnFrame = true ;
267- }
268- // Assume all private instance methods which are not explicitly hooked could be hooks
269- if ( method . DeclaringType . Name == type . Name )
270- {
271- AddHookMethod ( method . Name , method ) ;
259+ if ( method . Name . Equals ( "OnFrame" ) )
260+ {
261+ HookedOnFrame = true ;
262+ }
263+ // Assume all private instance methods which are not explicitly hooked could be hooks
264+ if ( method . DeclaringType . Name == type . Name )
265+ {
266+ AddHookMethod ( method . Name , method ) ;
267+ }
272268 }
273269 }
274270 }
0 commit comments