Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Serialization Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Serialization Question
Divers
Thread ID:
01464237
Message ID:
01464237
Vues:
83
I have a series of classes that make up a hierarchy of objects. I am serializing the collection to an XML file: The top level is RuleRoot :
[Serializable] 
[XmlRoot("Rules")]
public class RuleRoot
{
    [XmlElement("Items")]
    public List<RuleGroup> Groups { get; set; }

}
Then, in Groups I have:
[Serializable] 
[XmlRoot("Group")]
public class RuleGroup
{
    [XmlAttribute("ID")]
    public int GroupID { get; set; }

    [XmlAttribute("Name")]
    public string GroupName { get; set; }
        
    [XmlAttribute("Active")]
    public bool Active { get; set; }
        
    [XmlElement("Rules")]
    public List<Rule> Rules { get; set; }
}
This all works fine. But now I want to base all of my classes off of a base class:
{
    public abstract class _ItemBase
    {
        public ItemType Type
        {
            get;
            internal set;
        }

        public int ItemId
        {
            get;
            internal set;
        }

        private _Collection<_ItemBase> _Items = new _Collection<_ItemBase>();
        public _Collection<_ItemBase> Items
        {
            get { return _Items; }
            internal set { _Items = value; }
        }
    }
If I do this, then each object will inherit the Items collection, so in RuleRoot I no longer need Groups, and in RuleGroup I no longer
need Rules, and so on.

The question is, how do I then serialize this?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform