J
Jarlaxle
This is more of wanting to get some opinions and if anyone has run into the
same design issue.
I need to have about a hundred c# classes that simply represent an object
and contain data (no methods). These objects will be modified pretty often
by alot of different people and need to be serialized/deserialized to binary
and xml.
I basically have three options:
1. write the classes in c#
2. represent the classes in xml and auto-generate them
3. represent the classes in xsd and auto-generate them
option 1 can be done but gets very reptitive and messy when there are many
sub-objects.
option 2 gives a very clear representation of the object and is easy for
other people to modify/add new fields, however does not contain enough data
to distinguish the types that are generated (data type, array, etc.).
option 3 does the job but is so hard to visualize and maintain/modify and
will be hard for other people who don't have a grasp of xsd schema. plus xsd
schema is really to represent xml and not a programmable object.
I was thinking of representing my object with a hybrid of xml and xsd and
having a custom generator like xsd.exe create the c# objects. an object
could look like this...
<myobject>
<item1>xs:type=boolean</item1>
<item2 myattr1="xs:type=dateTime">xs:type=string</item2>
<item3>
<item4 xs:array>xs:type=mytype</item4>
</item3>
something like that...of course "xs:" could be something different but
indicates a code generator option. it would produce somethig like...
class myobject
{
public bool item1 {get; set;}
public item2Object {get;set;}
public item3Object {get;set;}
public class item2Object
{
[XmlAttribute]
public bool myattr1 {get; set;}
[XmlText]
public string Value {get;set;}
}
public class item3Object
{
public List<mytype> item4 {get; set;}
}
}
I think that would give a good flexible way of generating objects that could
be easily maintained and easily compared for backward compatibility problems.
any thoughts?
same design issue.
I need to have about a hundred c# classes that simply represent an object
and contain data (no methods). These objects will be modified pretty often
by alot of different people and need to be serialized/deserialized to binary
and xml.
I basically have three options:
1. write the classes in c#
2. represent the classes in xml and auto-generate them
3. represent the classes in xsd and auto-generate them
option 1 can be done but gets very reptitive and messy when there are many
sub-objects.
option 2 gives a very clear representation of the object and is easy for
other people to modify/add new fields, however does not contain enough data
to distinguish the types that are generated (data type, array, etc.).
option 3 does the job but is so hard to visualize and maintain/modify and
will be hard for other people who don't have a grasp of xsd schema. plus xsd
schema is really to represent xml and not a programmable object.
I was thinking of representing my object with a hybrid of xml and xsd and
having a custom generator like xsd.exe create the c# objects. an object
could look like this...
<myobject>
<item1>xs:type=boolean</item1>
<item2 myattr1="xs:type=dateTime">xs:type=string</item2>
<item3>
<item4 xs:array>xs:type=mytype</item4>
</item3>
something like that...of course "xs:" could be something different but
indicates a code generator option. it would produce somethig like...
class myobject
{
public bool item1 {get; set;}
public item2Object {get;set;}
public item3Object {get;set;}
public class item2Object
{
[XmlAttribute]
public bool myattr1 {get; set;}
[XmlText]
public string Value {get;set;}
}
public class item3Object
{
public List<mytype> item4 {get; set;}
}
}
I think that would give a good flexible way of generating objects that could
be easily maintained and easily compared for backward compatibility problems.
any thoughts?