olibara
Messages postés666Date d'inscriptiondimanche 16 décembre 2007StatutMembreDernière intervention11 mars 2010
-
2 févr. 2009 à 12:30
VINCEKA
Messages postés1Date d'inscriptionvendredi 10 février 2012StatutMembreDernière intervention 9 mai 2012
-
9 mai 2012 à 17:44
Bonjour
Je voudrais comprendre la methode la plus simple pour sauver le contenu d'une classe dans un fichier afin de la recuperer ensuite
Bien sur en bon véréran du C, je pourrais ecrire cela "a la main" mais je pense quand meme que .NET offre des methodes plus intégrée
J'ai donc essayé le code ci-dessous
Mais qui me donne une erreur
J'ai ensuite compris que je devais mettre la methode GetObjectData dans ma classe
Mais je commence a me demander si je ne fais pas fausse route
Si quelqu'un sait comment faire simplement et peut me guider, je serais le plus heureux de ce jour !
Merci
[Serializable()]
public class ImportDef : ISerializable // définition du template d'import
{
public string Country { get; set; } // country from import
public UInt32 LayerID { get; set; } // layer Id from import
public string LayerName { get; set; } // layer name from import
public int isValid { get; set; } // set to 1 if definition is valid
public bool useValue { get; set; } // false if value is not used (meta group Only)
public int ColCode { get; set; } // indice colonne code
public int ColValue { get; set; } // indice colonne valeur
public int ColGroup { get; set; } // Optionnel indice colonne Groupe
public bool optCount { get; set; } // true if value is count of lines
public bool optNoDup { get; set; } // Avoid Duplicate
public bool optGenVal { get; set; } // Automaticaly Generate Values from Input Key
public int HeaderRow { get; set; } // indice row header (NoHeader = -1)
public int FirstDataRow { get; set; } // indice first data row (default = -1)
public string Separators {get;set;} // Separateurs
public string FileName { get; set; } // full file name
};
Error 1 'Ogb.Import.ImportDef' does not implement interface member 'System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' D:\projets\MapScope.v2\Mapscope\Import\import.cs
cs_vagg
Messages postés102Date d'inscriptionvendredi 13 juin 2008StatutMembreDernière intervention24 janvier 2013 3 févr. 2009 à 10:06
J'utilise pour ma par une classe :
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace TonNameSpace
{
public class GenericXmlSerializer
{
public static void Serialize(object obj, string Path)
{
XmlSerializer oXmlSerializer = new XmlSerializer(obj.GetType());
StreamWriter oStreamWriter = new StreamWriter(Path);
oXmlSerializer.Serialize(oStreamWriter, obj);
oStreamWriter.Close();
}
public static object Deserialize(string Path, Type t)
{
XmlSerializer oXmlSerializer = new XmlSerializer(t);
StreamReader oStreamReader = new System.IO.StreamReader(Path);
object obj = oXmlSerializer.Deserialize(oStreamReader);
oStreamReader.Close();
return obj;
}
}
}
Ensuite te reste plus qu'à mettre les lignes qui suivent où tu en a besoin:
VINCEKA
Messages postés1Date d'inscriptionvendredi 10 février 2012StatutMembreDernière intervention 9 mai 2012 9 mai 2012 à 17:44
Bonjour à tous.Je suis actuellement sur un projet de développement d'un générateur d'application.Je voudrais avoir une démarche de conception solide me permettant la réutilisabilité et la maintenance de celle-ci. Merci de bien vouloir m'aider. si possible avoir des informations sur l'utilisation des DLL dans un projet comme le mien.