Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deserialization
Message
De
25/09/2008 11:19:53
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Titre:
Deserialization
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01350589
Message ID:
01350589
Vues:
59
I am serializing an Entity object to a file based queue. When I need to save this data I have to deserialize it back into an entity object that has a DataSet, table etc. and is known by the business object. (This is MM stuff, but the question really is just about deserialization) I have the method below to deserialize the object, but I am needing to know if this process actually populates the object you deserialize it to or if it creates a new object. I hope that makes sense.

When I do this:
MyEntityType newEntity = oBusinessObject.NewEntity() 
I get an Entity that has all the needed attributes to be known by the framwork and is able to be saved by the framework. So if I create an entity this way and then hydrate it by calling xml.Deserialize() do I still have the entity I started with?
public TrackSpotEntity LoadFromQueue(string loadFile)
{
    // Generate a new Entity on the business object
    TrackSpotEntity saveEntity = this.NewEntity();

    if (File.Exists(loadFile))
    {
        // Hydrate Entity from XML file
        try 
        {
            FileStream file = File.Open(loadFile, System.IO.FileMode.Open);
            XmlSerializer xml = new XmlSerializer(typeof(TrackSpotEntity));
            saveEntity = (TrackSpotEntity)xml.Deserialize(file);
            file.Close();
            Debug.WriteLine("Loaded", "QueueObject");
        }
        catch (Exception ex)
        {
            LogException(ex);
        }
    }

    return saveEntity;
}
Tim
Timothy Bryan
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform