예제 #1
0
        public override void Skip(CompactBinaryReader reader)
        {
            ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);

            decimalSurrogate.Skip(reader);
            decimalSurrogate.Skip(reader);
        }
예제 #2
0
        /// <summary>
        /// Deserializes an object from the specified compact binary writer.
        /// </summary>
        /// <param name="reader">Stream containing reader</param>
        /// <param name="cacheContext">Name of the cache</param>
        /// <param name="skip">True to skip the bytes returning null</param>
        static internal object Deserialize(CompactBinaryReader reader, string cacheContext, bool skip)
        {
            // read type handle
            short handle = reader.ReadInt16();

            reader.Context.CacheContext = cacheContext;
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, cacheContext);

            if (surrogate == null)
            {
                surrogate = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), cacheContext);
            }

            if (surrogate == null)
            {
                throw new CompactSerializationException("Type handle " + handle + "is not registered with Compact Serialization Framework");
            }
            if (!skip)
            {
                return(surrogate.Read(reader));
            }
            else
            {
                surrogate.Skip(reader);
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// Skips an object of type <see cref="object"/> from the current stream
        /// and advances the stream position.
        /// </summary>
        public override void SkipObject()
        {
            // read type handle
            short handle = reader.ReadInt16();
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, context.CacheContext);

            if (surrogate == null)
            {
                surrogate = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), context.CacheContext);
            }

            //If surrogate not found, returns defaultSurrogate
            //if (surrogate == null) throw new CompactSerializationException("Type handle " + handle + " is not registered with Compact Serialization Framework");

            try
            {
                surrogate.Skip(this);
            }
            catch (CompactSerializationException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new CompactSerializationException(e.Message);
            }
        }
예제 #4
0
        public override void Skip(CompactBinaryReader reader)
        {
            // read type handle
            short handle = reader.ReadInt16();

            // Find an appropriate surrogate by handle
            ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, null);

            if (typeSurr == null)
            {
                typeSurr = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), reader.Context.CacheContext);
            }

            int length = reader.ReadInt32();

            T?[] array = new T?[length];
            while (true)
            {
                int index = reader.ReadInt32();
                if (index < 0)
                {
                    break;
                }

                typeSurr.Skip(reader);
            }
        }
예제 #5
0
        /// <summary>
        /// Skips an object of type <see cref="object"/> from the current stream
        /// and advances the stream position.
        /// </summary>
        public override void SkipObject()
        {
            // read type handle
            short handle = reader.ReadInt16();
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, context.CacheContext);

            if (surrogate == null)
            {
                surrogate = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), context.CacheContext);
            }


            try
            {
                surrogate.Skip(this);
            }
            catch (CompactSerializationException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new CompactSerializationException(e.Message);
            }
        }
예제 #6
0
        public override void SkipObjectAs <T>()
        {
            // Find an appropriate surrogate by type
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForType(typeof(T), context.CacheContext);

            surrogate.Skip(this);
        }
예제 #7
0
        public override void Skip(CompactBinaryReader reader)
        {
            // Find an appropriate surrogate by handle
            short handle = reader.ReadInt16();
            ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.Context.CacheContext);

            typeSurr.Skip(reader);
        }