Hi Folks.
I=B4ve founded problems with the serialization. I=B4ve 2=20
Interfaces (code below) what can be implemented=B4s by any=20
class. I like the=20
serialize this objects, and to do this I create another=20
class (called VocabularyPersist) specialized to this.=20
This=20
class is marked
with Serializable attribute and implements ISerializable=20
interface to the control the Serializing. When the=20
GetObjectData is Invoked
I write to the SerializationInfo.AddValue the FullName of=20
the class what implement IVocabulary interface (code=20
below), and the version number=20
of layout this interface, to the control future versions.=20
Next Step I write the properties of the IVocabulary=20
Interface without problems.=20
After I wish write the ITerm indexes property. But how=20
the=20
SerializationInfo.AddValue require a pair name/value an=20
Exception is thrown
when the second ITerm is writed (because already exist=B4s=20
an information with same name).
Look the code below :
public void GetObjectData(SerializationInfo si,=20
StreamingContext context)
{
checkVocabulary(mVocabulary);
si.AddValue(cStrVersion, VocabularyInfo.Version);
si.AddValue(cStrClassName, mVocabulary.GetType
().FullName);
si.AddValue(cStrId, mVocabulary.Id);
si.AddValue(cStrName, mVocabulary.Name);
si.AddValue(cStrInternalId,=20
mVocabulary.InternalId);
si.AddValue(cStrDescription,=20
mVocabulary.Description);
si.AddValue(cStrResponsible,=20
mVocabulary.Responsible);
si.AddValue(cStrTotalTerms,=20
mVocabulary.totalTerms); =09
foreach(ITerm term in mVocabulary)
{ =09
si.AddValue(cStrTermName, term.Name); <--
-
------------ THE SECOND TERM RAISE EXCEPTION HERE.....
si.AddValue(cStrTermInternalId,=20
term.InternalId);
si.AddValue(cStrTermDefinition,=20
term.Definition);
si.AddValue(cStrTermComment,=20
term.Comment);
si.AddValue(cStrTermDataType,=20
term.DataType);
si.AddValue(cStrTermMandatory,=20
term.Mandatory);
}
}
Anybody have any suggestion what I solve this problem,=20
rather what don=B4t use Pair name/value to write property=B4s=20
ITerm ?
public interface IVocabulary : IEnumerable
{
string Id
{
get;
set;
}
=09
string Name
{
get;
set;
}
Guid InternalId
{
get;
}
string Description
{
get;
set;
}
string Namespace
{
get;
set;
}
string Responsible
{
get;
set;
}
int totalTerms
{
get;
}
=09
ITerm this[int index]
{
get;
}
ITerm newTerm();
void addTerm(ITerm term);
void addVocabulary(IVocabulary vocabulary);
int totalVocabularies
{
get;
}
IVocabulary getVocabulary(int index);=09
}
public interface ITerm
{
=09
string Name
{
get;
set;
}
Guid InternalId
{
get;
}
string Definition
{
get;
set;
}
=09
string Comment
{
get;
set;
}
Type DataType
{
get;
set;
}
bool Mandatory
{
get;
set;
}
IVocabulary Owner
{
get;
}
}=09
..