Ejemplo n.º 1
0
        /// <summary>
        /// This method converts the incoming stream to a searialization information.
        /// </summary>
        /// <param name="inStream">The incoming data stream.</param>
        /// <returns>Returns the serialization information.</returns>
        public static SerializationInfo GetSerializationInfo(Stream inStream)
        {
            if (!VerifyByteMarkers(inStream))
                throw new ContentFormatterException
                    ("The serialization byte markers are not present at the beginning of the stream.");

            IXimuraContentFormatterCapabilities header = new ContentFormatterCapabilities();

            header.Load(inStream);

            IXimuraContentSerializationReaderWriter rwHelper = header.RWHelper;

            Type contentType = RH.CreateTypeFromString(header.ContentType, null, true);

            if (contentType == null && header.SupportsBaseType)
                contentType = RH.CreateTypeFromString(header.ContentBaseType, null, true);

            //OK, the content type is still null
            if (contentType == null)
                throw new ContentFormatterException("The content type cannot be created.");

            SerializationInfo info = PrepareSerializationInfo(header, contentType);

            return info;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method is used to get the header object which can 
        /// parse or write to the stream.
        /// </summary>
        /// <param name="entity">The entity type.</param>
        /// <returns>A header object.</returns>
        protected virtual IXimuraContentFormatterCapabilities GetHeader(Content entity)
        {
            IXimuraContentFormatterCapabilities header = new ContentFormatterCapabilities();

            return header;
        }