RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Configure/Initialize on Generic Classes (Fix)

mumuboy

Sorceror
If you add a Configure or Initialize function to a generic class it will cause a runtime exception. To fix this make the following changes in ScriptCompiler.cs under the function Invoke( string method )
Code:
public static void Invoke( string method )
{
List<MethodInfo> invoke = new List<MethodInfo>();
 
for( int a = 0; a < m_Assemblies.Length; ++a )
{
Type[] types = m_Assemblies[a].GetTypes();
 
for( int i = 0; i < types.Length; ++i )
{
Type type = types[i];
 
if ( !type.IsGenericType )
{
MethodInfo m = type.GetMethod( method, BindingFlags.Static | BindingFlags.Public );
 
if( m != null )
invoke.Add( m );
}
}
}
 
invoke.Sort( new CallPriorityComparer() );
 
for( int i = 0; i < invoke.Count; ++i )
invoke[i].Invoke( null, null );
}

While it is possible to execute Configure/Initialize method for all constructed types by executing it from the generic itself, it is not advisable.
 
Top