CS Plugin System Help
Posted: Tue Jan 13, 2009 3:51 pm
Well I'm working on a couple apps that depend on a modified version of shade45 and Anthonys CS plugin system. Now here is my issue. I parse out the tag, then I want to filter the reflexives into a list. But I can't seem to find the right object to get the value with. Here is my code:
Here is the exception:
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'HaloObjects.Reflexive`1[HaloObjects.sbsp+Collision_MaterialsBlock]' to type 'HaloObjects.Reflexive`1[HaloObjects.Chunk]'."
Note: I set the fields value with the Plugin object, but it doesn't work when I try to retrive it that way.
Code: Select all
public Chunk Plugin;
private void FilterReflexives()
{
FieldInfo[] fields = Plugin.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
for (int i = 0; i < fields.Length; i++)
{
FieldInfo f = fields[i];
if (f.FieldType.IsGenericType && (f.FieldType.GetGenericTypeDefinition() == typeof(Reflexive<>)))
{
Reflexives.Add((Reflexive<Chunk>)f.GetValue(Plugin));
Reflexives.AddRange(((Reflexive<Chunk>)f.GetValue(Plugin)).FilterReflexives().ToArray());
}
}
}
System.InvalidCastException was unhandled
Message="Unable to cast object of type 'HaloObjects.Reflexive`1[HaloObjects.sbsp+Collision_MaterialsBlock]' to type 'HaloObjects.Reflexive`1[HaloObjects.Chunk]'."
Note: I set the fields value with the Plugin object, but it doesn't work when I try to retrive it that way.