I have this code wich fills in data fields from a file,
recursivley down through any structures/classes
the difficulty is when I come acros a field wich is a structure,
wich can not be read as a binary blit.
I need to be able to pass this as a reference to
a function to carry on the recursion through each field...
I have tried to use TypeReferences but I get this error and
I cant find anything much about it.
public void GetFields(ref object destObj)
{
Type type = destObj.GetType ();
System.Reflecti on.FieldInfo[] fields = type.GetFields( );
foreach (System.Reflect ion.FieldInfo field in fields)
{
if(<<< tests to make sure we realy need to do this for this field
{>>>>)
System.Reflecti on.FieldInfo[] field_s=new FieldInfo[1]{field};
TypedReference
destRef=TypedRe ference.MakeTyp edReference(des tObj,field_s);
<<<< gives exception "TypedReference s cannot be redefined as
primitives." >>>>
}
}
}
can any one shed any light or offer any other way of doing it ?
I cant find any info or make sense of it.
can my sub function return a structure that it creates somehow
with only knowing at runtime ?
I manage to do that if the structure is blitable by using PtrToStructure
as sugested by Mattius, and the rest of it works fine if I avoid structures
that
cant be blitted.
the data in the files is an existing format and is a mixture of
direct binary values and complicated conversions.
thanks
Colin =^.^=