EntityBase and EntityCollectionBase WriteXml

Posts   
 
    
llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 21-Mar-2007 15:06:10   

Adapter.

Hello,

does EntityBase and EntityCollectionBase share a common parent or implement an interface for the WriteXml and ReadWml function?

Thanks,

-->because, I am having a generic function that can manipulate either Entity or EntityCollection and that use the Read and WriteXml and I don't want to do a cast:


        private static void SaveSingleProfile<T>(string username, T item)//, string fileName)
        {
            CreateProfileDirectory();
            using (StreamWriter writer = new StreamWriter(Settings.Default.UserParam_Common_ProfilePath + username + typeof(T).ToString()))
            {
                string xml = string.Empty;

                if (item is IEntity2)
                    ((IEntity2)item).WriteXml(XmlFormatAspect.Compact, out xml);
                if (item is IEntityCollection2)
                    ((IEntityCollection2)item).WriteXml(XmlFormatAspect.Compact, out xml);

                writer.Write(xml);
                writer.Close();
            }

        }

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 21-Mar-2007 15:33:57   

does EntityBase and EntityCollectionBase share a common parent or implement an interface for the WriteXml and ReadWml function?

IXmlSerializable

llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 21-Mar-2007 15:36:59   

So nice to have so quick answers!!!!!

Thanks Walaa!

llblPowa
User
Posts: 41
Joined: 19-Nov-2006
# Posted on: 22-Mar-2007 02:33:32   

Hello again,

Unfortunately EntityCollection and Entity does not implement the system.xml.serialization.IXmlSerializable interface (the function's signatures are different... ).

Any other idea?

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Mar-2007 08:16:28   

Go to the entityBase code and look for the following region:

#region IXmlSerializable Members