クラスがあります。そのクラスのオブジェクトを含むリストをシリアライズしてシリアライズしたい。バイナリフォーマッタを使いたい。これは私のクラスです:
[Serializable]
public class Section :ISerializable
{
private double ClearCover;
private string SectionName;
private double Diameter;
public double Height;
private double Width;
private double InternalDiameter;
private double ExternalDiameter;
private double InternalHeight;
private double ExternalHeight;
private double InternalWidth;
private double ExternalWidth;
private double WebWidth;
private double FlangeWidth;
private double FlangeThickness;
public double clearCover
{
get { return ClearCover; }
set { ClearCover = value; }
}
public string sectionName
{
get{return SectionName;}
set{SectionName=value;}
}
public double diameter
{
get { return Diameter; }
set { Diameter = value; }
}
public double height
{
set { Height = value; }
get { return Height; }
}
public double width
{
set { Width = value; }
get { return Width; }
}
public double internalDiameter
{
set { InternalDiameter = value; }
get { return InternalDiameter; }
}
public double externalDiameter
{
set { ExternalDiameter = value; }
get { return ExternalDiameter; }
}
public double internalHeight
{
set { InternalHeight = value; }
get { return InternalHeight; }
}
public double externalHeight
{
set { ExternalHeight = value; }
get { return ExternalHeight; }
}
public double internalWidth
{
set { InternalWidth = value; }
get { return InternalWidth; }
}
public double externalWidth
{
set { ExternalWidth = value; }
get { return ExternalWidth; }
}
public double flangeWidth
{
set { FlangeWidth = value; }
get { return FlangeWidth; }
}
public double flangeThickness
{
set { FlangeThickness = value; }
get { return FlangeThickness; }
}
public double webWidth
{
set { WebWidth = value; }
get { return WebWidth; }
}
public Section() { }
protected Section(SerializationInfo info, StreamingContext context)
{
sectionName = info.GetString("Section Name");
clearCover = info.GetDouble("Clear Cover");
diameter = info.GetDouble("Diameter");
//internalDiameter = info.GetDouble("Internal Diameter");
//externalDiameter = info.GetDouble("External Diameter");
height = info.GetDouble("Height");
width = info.GetDouble("Width");
internalHeight = info.GetDouble("Internal Height");
externalHeight = info.GetDouble("External Height");
internalWidth = info.GetDouble("Internal Width");
externalWidth = info.GetDouble("External Width");
flangeWidth = info.GetDouble("Flange Width");
flangeThickness = info.GetDouble("Flange Thickness");
webWidth = info.GetDouble("Web Width");
}
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Section Name", sectionName);
info.AddValue("Clear Cover", clearCover);
info.AddValue("Diameter",diameter);
//info.AddValue("Internal Diameter", internalDiameter);
//info.AddValue("External Diameter", externalDiameter);
info.AddValue("Height",height);
info.AddValue("Width",width);
info.AddValue("Internal Height",internalHeight);
info.AddValue("External Height",externalHeight);
info.AddValue("Internal Width",internalWidth);
info.AddValue("External Width",externalWidth);
info.AddValue("Flange Width",flangeWidth);
info.AddValue("Flange Thickness", flangeThickness);
info.AddValue("Web Width", webWidth);
}
}
シリアル化に問題はありません。ただし、逆シリアル化の場合、すべてではなく最初のオブジェクトを逆シリアル化できます。どうすればいいですか、助けてください!