Exemple #1
0
        private object ReadWithFormatter()
        {
            string typeName = ReadPropertyName();
            var    t        = TypeExtensions.GetTypeByAssemblyQualifiedName(typeName);

            IBinaryDataFormatter f;

            if (!BinaryDataFormatterService.Resolve(t, out f))
            {
                throw new InvalidOperationException($"Can't read {typeName} from binary data, formatter not found");
            }
            return(f.Read(t, this));
        }
Exemple #2
0
        private BinaryDataWriter WriteWithFormatter(object value)
        {
            Type t = value.GetType();

            if (!BinaryDataFormatterService.Resolve(t, out IBinaryDataFormatter f))
            {
                throw new InvalidOperationException($"Can't write {t} as binary data, formatter not found");
            }

            Write(ExportedDataTypes.serial);
            WritePropertyName(t.AssemblyQualifiedName);
            f.Write(this, value);
            return(this);
        }