protected void RegisterParserMethods()
{
MethodInfo[] methods = this.GetType().GetMethods( BindingFlags.NonPublic | BindingFlags.Static );
// loop through all methods and look for ones marked with attributes
for ( int i = 0; i < methods.Length; i++ )
{
// get the current method in the loop
MethodInfo method = methods[ i ];
// see if the method should be used to parse one or more material attributes
MaterialAttributeParserAttribute[] parserAtts =
(MaterialAttributeParserAttribute[])method.GetCustomAttributes( typeof( MaterialAttributeParserAttribute ), true );
// loop through each one we found and register its parser
for ( int j = 0; j < parserAtts.Length; j++ )
{
MaterialAttributeParserAttribute parserAtt = parserAtts[ j ];
AxiomCollection<MethodInfo> parserList = null;
// determine which parser list we will add this handler to
switch ( parserAtt.Section )
{
case MaterialScriptSection.None:
parserList = rootAttribParsers;
break;
case MaterialScriptSection.Material:
parserList = materialAttribParsers;
break;
case MaterialScriptSection.Technique:
parserList = techniqueAttribParsers;
break;
case MaterialScriptSection.Pass:
parserList = passAttribParsers;
break;
case MaterialScriptSection.ProgramRef:
parserList = programRefAttribParsers;
break;
case MaterialScriptSection.Program:
parserList = programAttribParsers;
break;
case MaterialScriptSection.TextureUnit:
parserList = textureUnitAttribParsers;
break;
case MaterialScriptSection.DefaultParameters:
parserList = programDefaultParamAttribParsers;
break;
default:
parserList = null;
break;
} // switch
if ( parserList != null )
{
//parserList.Add( parserAtt.Name, Delegate.CreateDelegate( typeof( MaterialAttributeParserHandler ), method ) );
parserList.Add( parserAtt.Name, method );
}
} // for
} // for
}