Is it possible to perform "mixed" serialization of XML in .net?

I am developing several complex classes in VB.net (but you can write your answer in C # if you want: P) that contain data that needs to be loaded from XML. The obvious solution, of course, is to create a serializable class, therefore, to automate the boot process.

Now my problem is this: the XML structure is fixed, and I cannot change it, and it has some troubles that cause the pain to serialize. Here is an example of a tiny DTD snippet that better explains the problem:

<!ELEMENT Relationship ( AttributePairs | AscendCaption | DescendCaption | ErrPreventInsertOrUpdateChild | ErrPreventDeleteParent | ErrPreventUpdateParent |ExtendedProperties |HiddenProperties )* >
<!ATTLIST Relationship 

    CountAggregates CDATA #IMPLIED
    CountReplicates CDATA #IMPLIED
    OnParentUpdate (PreventIfChildren|UpdateChildren) #IMPLIED
    OnParentDelete (PreventIfChildren|DeleteChildren|NullChildrenForeignKey) #IMPLIED
    IsEnforce (True|False) #REQUIRED 
    OnChildInsertOrUpdate (PreventIfNoParent|InsertParentIfNone) #IMPLIED
    ChildRoleName CDATA #IMPLIED
    ParentRoleName CDATA #IMPLIED
    ParentAttributeGroupInstance CDATA #IMPLIED
    ChildAttributeGroupInstance CDATA #IMPLIED

>

<!--Lots of other sutff not needed for this example -->

As you can see, all of the above attributes can be easily serialized by simply declaring the corresponding property and decorating it with a tag <XmlAttribute()>. With the exception of:

IsEnforce (True | False) #REQUIRED

True False xml (- T F), .

... , , - IXMLSerializable , , , , "" /, , .

, , : MIX ? ..: , "" "" ? ( , , )

+3
2

private ( XmlIgnore) bool, , True/False, , - T/F, True/False, Y/N ..

enum.

+1

Source: https://habr.com/ru/post/1773945/


All Articles