protected void RegisterCommands()
{
Type baseType = GetType();
do
{
Type[] types = baseType.GetNestedTypes( BindingFlags.NonPublic | BindingFlags.Public );
// loop through all methods and look for ones marked with attributes
for ( int i = 0; i < types.Length; i++ )
{
// get the current method in the loop
Type type = types[ i ];
// get as many command attributes as there are on this type
ScriptablePropertyAttribute[] commandAtts =
(ScriptablePropertyAttribute[])type.GetCustomAttributes( typeof( ScriptablePropertyAttribute ), true );
// loop through each one we found and register its command
for ( int j = 0; j < commandAtts.Length; j++ )
{
ScriptablePropertyAttribute commandAtt = commandAtts[ j ];
commandTable.Add( commandAtt.ScriptPropertyName, (IPropertyCommand)Activator.CreateInstance( type ) );
} // for
} // for
// get the base type of the current type
baseType = baseType.BaseType;
}
while ( baseType != typeof( object ) );
}