[Serializable]
Public class solidbutton: button, iserializable
{
Public solidbutton (serializationinfo, streamingcontext ctxt)
{
This. location = new point (INT) info. getvalue ("X", typeof (INT), (INT) info. getvalue ("Y", typeof (INT )));
This. Text = (string) info. getvalue ("text", typeof (string ));
This. Height = (INT) info. getvalue ("height", typeof (INT ));
This. width = (INT) info. getvalue ("width", typeof (INT ));
This. Name = (string) info. getvalue ("name", typeof (string ));
}
Public solidbutton ()
{
}
Public void getobjectdata (serializationinfo info, streamingcontext ctxt)
{
Info. addvalue ("text", this. Text );
Info. addvalue ("X", this. Location. X );
Info. addvalue ("Y", this. Location. y );
Info. addvalue ("height", this. Height );
Info. addvalue ("width", this. width );
Info. addvalue ("name", this. Name );
}
}
/// <Summary>
/// Serialize the object and return the corresponding bytes
/// </Summary>
/// <Param name = "pobj"> object to be serialized </param>
/// <Returns> byte [] </returns>
Public byte [] objecttobyte (Object pobj)
{
If (pobj = NULL)
{
Return NULL;
}
System. Io. memorystream _ memory = new system. Io. memorystream ();
Binaryformatter formatter = new binaryformatter ();
Formatter. serialize (_ memory, pobj );
_ Memory. Position = 0;
Byte [] READ = new byte [_ memory. Length];
_ Memory. Read (read, 0, read. Length );
_ Memory. Close ();
Return read;
}
/// <Summary>
/// Serialize the object and return the corresponding string
/// </Summary>
/// <Param name = "pobj"> object to be serialized </param>
/// <Returns> </returns>
Public String objecttostring (Object pobj)
{
Return bytetostring (objecttobyte (pobj ));
}
/// <Summary>
/// Deserialize bytes into corresponding objects
/// </Summary>
/// <Param name = "pbytes"> byte stream </param>
/// <Returns> Object </returns>
Public object bytetoobject (byte [] pbytes)
{
Object _ newojb = NULL;
If (pbytes = NULL)
{
Return _ newojb;
}
System. Io. memorystream _ memory = new system. Io. memorystream (pbytes );
_ Memory. Position = 0;
Binaryformatter formatter = new binaryformatter ();
_ Newojb = formatter. deserialize (_ memory );
_ Memory. Close ();
Return _ newojb;
}
///
/// deserialize the string to the corresponding object
///
//
//
Public object stringtoobject (string pstr)
{< br> return bytetoobject (stringtobyte (pstr);
}