Esempio n. 1
0
        public void Serialize(
            StreamWriter streamWriter,
            SerializationContext serializationContext,
            object value,
            PropertyMetaData propertyMetaData = null)
        {
            if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization)
            {
                var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize);
                arraySizeSerializer.Serialize(streamWriter, serializationContext, value, propertyMetaData);
            }

            var writeStringParam = propertyMetaData.Options.IsFixedSize
                                       ? (int?)propertyMetaData.Options.FixedSizeLength
                                       : null;

            streamWriter.WriteString((string)value, writeStringParam);
        }
        public void Serialize(
            StreamWriter streamWriter,
            SerializationContext serializationContext,
            object value,
            PropertyMetaData propertyMetaData = null)
        {
            if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization)
            {
                var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize);
                arraySizeSerializer.Serialize(
                    streamWriter, serializationContext, value, propertyMetaData: propertyMetaData);
            }

            var array = (Array)value;

            for (var i = 0; i < array.Length; i++)
            {
                this.typeSerializer.Serialize(
                    streamWriter, serializationContext, array.GetValue(i), propertyMetaData: propertyMetaData);
            }
        }
        public void Serialize(
            StreamWriter streamWriter, 
            SerializationContext serializationContext, 
            object value, 
            PropertyMetaData propertyMetaData = null)
        {
            if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization)
            {
                var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize);
                arraySizeSerializer.Serialize(streamWriter, serializationContext, value, propertyMetaData);
            }

            var writeStringParam = propertyMetaData.Options.IsFixedSize
                                       ? (int?)propertyMetaData.Options.FixedSizeLength
                                       : null;
            streamWriter.WriteString((string)value, writeStringParam);
        }
        public void Serialize(
            StreamWriter streamWriter,
            SerializationContext serializationContext,
            object value,
            PropertyMetaData propertyMetaData = null)
        {
            if (propertyMetaData.Options.SerializeSize != ArraySizeType.NoSerialization)
            {
                var arraySizeSerializer = new ArraySizeSerializer(propertyMetaData.Options.SerializeSize);
                arraySizeSerializer.Serialize(
                    streamWriter, serializationContext, value, propertyMetaData: propertyMetaData);
            }

            var array = (Array)value;
            for (var i = 0; i < array.Length; i++)
            {
                this.typeSerializer.Serialize(
                    streamWriter, serializationContext, array.GetValue(i), propertyMetaData: propertyMetaData);
            }
        }