Amnesia.SerializationUtil.SerializeToFixedByteArray C# (CSharp) Метод

SerializeToFixedByteArray() статический приватный Метод

static private SerializeToFixedByteArray ( object o, ISurrogateSelector selector ) : FixedByteArray
o object
selector ISurrogateSelector
Результат FixedByteArray
        static FixedByteArray SerializeToFixedByteArray(object o, ISurrogateSelector selector)
        {
            if (o == null)
                return new FixedByteArray(new byte[0], 0);

            FixedByteArray array = new FixedByteArray();

            BinaryFormatter formatter = new BinaryFormatter();

            if (selector != null)
                formatter.SurrogateSelector = selector;

            MemoryStream s = new MemoryStream();

            formatter.Serialize(s, o);
            array.Length = (int)s.Length;
            s.Close();

            array.Data = s.GetBuffer();
            return array;
        }