public BinaryWriter(IBufferWriter <byte> bufferWriter, BinarySerializerOptions options)
 {
     _output  = bufferWriter ?? throw new ArgumentNullException(nameof(bufferWriter));
     _options = options;
 }
Ejemplo n.º 2
0
        // Create a property that is ignored at run-time. It uses the same type (typeof(sbyte)) to help
        // prevent issues with unsupported types and helps ensure we don't accidently (de)serialize it.
        public static BinaryPropertyInfo CreateIgnoredPropertyPlaceholder(TypeMap typeMap, MemberInfo memberInfo, BinarySerializerOptions options)
        {
            BinaryPropertyInfo binaryPropertyInfo = new BinaryPropertyInfo <sbyte>
            {
                Options    = options,
                MemberInfo = memberInfo
            };

            binaryPropertyInfo.DeterminePropertyName();
            binaryPropertyInfo.IsIgnored = true;
            binaryPropertyInfo.TypeMap   = typeMap;

            Debug.Assert(!binaryPropertyInfo.ShouldDeserialize);
            Debug.Assert(!binaryPropertyInfo.ShouldSerialize);

            return(binaryPropertyInfo);
        }
 public static object Deserialize(ReadOnlySpan <byte> bytes, BinarySerializerOptions options = null)
 {
     return(Deserialize(bytes, BinaryClassInfo.ObjectType, options));
 }
 public static TValue Deserialize <TValue>(ReadOnlySpan <byte> bytes, BinarySerializerOptions options = null)
 {
     return((TValue)Deserialize(bytes, typeof(TValue), options));
 }
#pragma warning disable IDE0060 // 删除未使用的参数
        public BinaryReader(ReadOnlySpan <byte> binaryData, BinarySerializerOptions options = default)
#pragma warning restore IDE0060 // 删除未使用的参数
            : this(binaryData, isFinalBlock : true, new BinaryReaderState())
        {
        }