public void WriteObject(object obj)
{
var type = obj.GetType();
Write(type.Name);
if (type == typeof(string))
Write((string)obj);
else if (type == typeof(byte[]))
Write((byte[])obj);
else
throw new NotSupportedException("Serialization is not suuported for of object " + type.Name);
}