Beispiel #1
0
        protected override void DeserializeImplementation(ref T value, IDataReader reader)
        {
            var formatter = FormatterEmitter.GetEmittedFormatter(typeof(T), reader.Context.Config.SerializationPolicy) as FormatterEmitter.RuntimeEmittedFormatter <T>;

            if (formatter == null)
            {
                return;
            }

            int       count = 0;
            string    name;
            EntryType entry;

            while ((entry = reader.PeekEntry(out name)) != EntryType.EndOfNode && entry != EntryType.EndOfArray && entry != EntryType.EndOfStream)
            {
                formatter.Read(ref value, name, entry, reader);

                count++;

                if (count > 1000)
                {
                    reader.Context.Config.DebugContext.LogError("Breaking out of infinite reading loop!");
                    break;
                }
            }
        }
Beispiel #2
0
        protected override void SerializeImplementation(ref T value, IDataWriter writer)
        {
            var formatter = FormatterEmitter.GetEmittedFormatter(typeof(T), writer.Context.Config.SerializationPolicy) as FormatterEmitter.RuntimeEmittedFormatter <T>;

            if (formatter == null)
            {
                return;
            }

            formatter.Write(ref value, writer);
        }