c# - Can you change the value of the Name property of a Type at runtime? -
is possible change/override name property of type?
given class definition:
class sample {}
can change value typeof(sample).name
returns?
i'm using custom serialization library, literally use typeof(t).name
in source code:
writer.writestartelement(typeof(t).name); writer.writevalue(item); writer.writeendelement();
no, cannot change .name
of type
@ runtime. however, serialization libraries allow have control of processing of names, either providing custom "binder" (etc), or annotating type attributes indicate preferred name use (note: libraries allow attributes also allow name provided via runtime configuration of serialization library).
an important question, then, is: serialization library being used here?
if serialization library doesn't support this, , cannot changed, alternative (short of renaming sample
) of create type (either hand, or via typebuilder
@ runtime) looks original type, different code, , similarly: create code translates between 2 types.
Comments
Post a Comment