[C#] Fieldinfo[]'s with Generic classes

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

[C#] Fieldinfo[]'s with Generic classes

Post by grimdoomer »

Well, I set up a class for my reflexives like so:

Code: Select all

public class Reflexive<T> : List<T> where T : Chunk
    {

}
And I harcoded my Tags like engineer. But when I get a Reflexive<Chunk> field type, and I try to do:

Code: Select all

foreach (FieldInfo f  in Tag.Fields)
{
     //Blah Blah Blah
     else if (f.FieldType.IsGenericType &&   f.FieldType.GetGenericTypeDefinition() == typeof(Reflexive<>))
     {
            //-----------More stuff not important

            //Right here, I get an array with 0 Entrys
            FieldInfo[] FFields = f.GetType().GetFields();
     }
}
I get an array with 0 entrys for the line with the comment.

Can any one help me with this?
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
xzodia




Translator Connoisseur Coagulator

Posts: 1981
Joined: Sun May 15, 2005 10:31 am
Location: UK
Contact:

Post by xzodia »

you need to specify the bindingflags
GetFields(BindingFlags.Public | BindingFlags.Instance)
Image
Halo 2 Plugins | Lock-on To Just About Anything | My Sites | Snow Hog
Old Plugins you have, upgrade you must...
Always Maintain a High Quality-To-Crap Ratio.
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

I did but I still get an empty array.

I need to get the Fields of T, but I dont know how.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
xzodia




Translator Connoisseur Coagulator

Posts: 1981
Joined: Sun May 15, 2005 10:31 am
Location: UK
Contact:

Post by xzodia »

are you sure its the fields you want and not the members?
Image
Halo 2 Plugins | Lock-on To Just About Anything | My Sites | Snow Hog
Old Plugins you have, upgrade you must...
Always Maintain a High Quality-To-Crap Ratio.
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

Yea, I need the fields so I can check for any nested TagReferences and add them to the TagReference list.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
Post Reply