Example #1
0
        public object Deserialize(
            StreamReader streamReader,
            SerializationContext serializationContext,
            PropertyMetaData propertyMetaData = null)
        {
            object obj = null;
            long   streamReaderPosition = streamReader.Position;

            try
            {
                obj = this.DeserializerLambda(streamReader, serializationContext);
            }
            catch (Exception e)
            {
                Probe pb = serializationContext.BeginProbe();
                try
                {
                    streamReader.Position = streamReaderPosition;
                    obj = this.DeserializerLambda(streamReader, serializationContext);
                }
                catch (Exception)
                {
                }
                serializationContext.EndProbe(pb);
                throw new Exception("TypeSerializer failed (" + this.Type.ToString() + ")." + Environment.NewLine + e.Message + string.Join(Environment.NewLine, pb.DiagnosticInfo) + Environment.NewLine, e);
            }
            return(obj);
        }
        private Probe BeginProbeDeserialize(
            StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData)
        {
            var probe = serializationContext.BeginProbe();

            probe.DiagnosticInfo.Offset           = streamReader.Position;
            probe.DiagnosticInfo.PropertyMetaData = propertyMetaData;
            return(probe);
        }
        private Probe BeginProbeSerialize(
            StreamWriter streamWriter,
            SerializationContext serializationContext,
            object value,
            PropertyMetaData propertyMetaData)
        {
            var probe = serializationContext.BeginProbe();

            probe.DiagnosticInfo.Offset           = streamWriter.Position;
            probe.DiagnosticInfo.PropertyMetaData = propertyMetaData;
            probe.DiagnosticInfo.Value            = value;
            return(probe);
        }
 public object Deserialize(
     StreamReader streamReader,
     SerializationContext serializationContext,
     PropertyMetaData propertyMetaData = null)
 {
     object obj = null;
     long streamReaderPosition = streamReader.Position;
     try
     {
         obj = this.DeserializerLambda(streamReader, serializationContext);
     }
     catch (Exception e)
     {
         Probe pb = serializationContext.BeginProbe();
         try
         {
             streamReader.Position = streamReaderPosition;
             obj = this.DeserializerLambda(streamReader, serializationContext);
         }
         catch (Exception)
         {
         }
         serializationContext.EndProbe(pb);
         throw new Exception("TypeSerializer failed ("+this.Type.ToString()+")." + Environment.NewLine + e.Message + string.Join(Environment.NewLine, pb.DiagnosticInfo) + Environment.NewLine, e);
     }
     return obj;
 }
 private Probe BeginProbeSerialize(
     StreamWriter streamWriter, 
     SerializationContext serializationContext, 
     object value, 
     PropertyMetaData propertyMetaData)
 {
     var probe = serializationContext.BeginProbe();
     probe.DiagnosticInfo.Offset = streamWriter.Position;
     probe.DiagnosticInfo.PropertyMetaData = propertyMetaData;
     probe.DiagnosticInfo.Value = value;
     return probe;
 }
 private Probe BeginProbeDeserialize(
     StreamReader streamReader, SerializationContext serializationContext, PropertyMetaData propertyMetaData)
 {
     var probe = serializationContext.BeginProbe();
     probe.DiagnosticInfo.Offset = streamReader.Position;
     probe.DiagnosticInfo.PropertyMetaData = propertyMetaData;
     return probe;
 }