XmlTextReader - how do I know the name of my variable

  • Thread starter Thread starter Ed Debrot
  • Start date Start date
E

Ed Debrot

I am trying to write a simple serializer/deserializer for a set of
objects/classes that I have. When I deserialize I'd like to write the actual
variable name to my XML file but I don't know how to determine this at
run-time. I know the standard XmlSerializer must do this because it writes
the variable name and not the class.

Any ideas? I have a feeling there is a standard way to determine the
variable name but I have not idea. Something like

{
int x;

x.name();
}

or something similar.
 
Variable name does not exist at run time. Fields and Peopreties do. Standard
serializer has no idea about the local variables either.
When you are serializing an object, typically you walk the list of the
fields or properties using reflection. Then you write to the output stream
the field name (FieldInfo.Name) and the field value (Field.GetValue() )
 
Ok, I'll look into this. But one more question. When you reference
Reflection, are you saying it is available in Compact Framework? I thought
it was not available in this environment.

thanks...
 
Emit is not available. Some other advanced features like walking the stack
are not. But the simple stuff like RuntimeType and
Fields/Properties/Events/Constructors/Methods is there
 
Back
Top