/// <summary> /// This method deserializes a blob in to the correct content entity. /// </summary> /// <param name="blob">The binary blob to deserialize.</param> /// <param name="index">The index.</param> /// <param name="length">The length.</param> /// <param name="formatter">The formatter to use.</param> /// <returns>A content object</returns> public static IXimuraContent DeserializeToContent(byte[] blob, int index, int length, IXimuraFormatter formatter, IXimuraPoolManager pMan) { using (MemoryStream memStream = new MemoryStream(blob, index, length)) { return DeserializeToContent(memStream, formatter, pMan); } }
/// <summary> /// This is the reset method to set the content to it's default state. /// </summary> public virtual void Reset() { mPoolManager = null; mPool = null; mCanLoad = true; mEntityType = ""; mEntitySubType = ""; mInfo = null; mIDVersion = Guid.Empty; mIDContent = Guid.Empty; mDirty = false; mOnInitialized = null; mInitialized = false; mInitializing = false; }
/// <summary> /// This method deserializes the stream in to the correct content entity. /// </summary> /// <param name="stream">The stream to deserialize from.</param> /// <param name="formatter">The formatter.</param> /// <param name="pMan">The pool manager to retrieve a new object.</param> /// <returns>The content entity.</returns> public static IXimuraContent DeserializeToContent(Stream stream, IXimuraFormatter formatter, IXimuraPoolManager pMan) { IXimuraContent content = formatter.Deserialize(stream, pMan) as IXimuraContent; return content; }
/// <summary> /// This method deserializes the stream in to the correct content entity. /// </summary> /// <param name="stream">The stream to deserialize from.</param> /// <returns>The content entity.</returns> public static IXimuraContent DeserializeToContent(Stream stream, IXimuraPoolManager pMan) { IXimuraFormatter formatter = ContentHelper.FormatterResolve(stream); return DeserializeToContent(stream, formatter, pMan); }
/// <summary> /// This method deserializes a blob in to the correct content entity. /// </summary> /// <param name="blob">The binary blob to deserialize.</param> /// <param name="index">The index.</param> /// <param name="length">The length.</param> /// <returns>A content object</returns> public static IXimuraContent DeserializeToContent(byte[] blob, int index, int length, IXimuraPoolManager pMan) { IXimuraFormatter formatter = ContentHelper.FormatterResolve(blob); return DeserializeToContent(blob, index, length, formatter, pMan); }
/// <summary> /// This method deserializes a blob in to the correct content entity. /// </summary> /// <param name="blob">The binary blob to deserialize.</param> /// <param name="formatter">The formatter to use.</param> /// <returns>A content object</returns> public static IXimuraContent DeserializeToContent(byte[] blob, IXimuraFormatter formatter, IXimuraPoolManager pMan) { return DeserializeToContent(blob, 0, blob.Length, formatter, pMan); }
/// <summary> /// This method deserializes the stream in to a content object. /// </summary> /// <param name="header">The header</param> /// <param name="pMan">The pool manaer containing the required pool.</param> /// <returns>Returns a deserialized object.</returns> protected virtual Content ContentDeserializeInternal( IXimuraContentFormatterCapabilities header, IXimuraPoolManager pMan) { IXimuraContentSerializationReaderWriter rwHelper = header.RWHelper; Type contentType = ResolveType(header.ContentType, header.AllowRelativeType); if (contentType == null && header.SupportsBaseType) contentType = ResolveType(header.ContentBaseType, header.AllowRelativeType); //OK, the content type is still null if (contentType == null) throw new ContentFormatterException("The content type cannot be created."); SerializationInfo info = PrepareSerializationInfo(header, contentType); Content content = null; if (pMan != null) { content = (Content)pMan.GetPoolManager(contentType).Get(info, Context); } else { object[] parameters = new object[] { info, Context }; Type[] typesArray = RH.getTypesfromObjectArray(parameters); ConstructorInfo TypeConstruct = contentType.GetConstructor(typesArray); content = TypeConstruct.Invoke(parameters) as Content; content.OnDeserialization(null); } return content as Content; }
/// <summary> /// This method deserializes the stream to a content object. /// </summary> /// <param name="inStream">The stream containing the data.</param> /// <param name="pMan">The pool manaer containing the required pool.</param> /// <returns>The deserialized object.</returns> public override object Deserialize(Stream inStream, IXimuraPoolManager pMan) { if (!VerifyByteMarkers(inStream)) throw new ContentFormatterException ("The serialization byte markers are not present at the beginning of the stream."); IXimuraContentFormatterCapabilities header = GetHeader(); header.Load(inStream); return ContentDeserializeInternal(header, pMan); }
/// <summary> /// This method deserializes the stream and returns the object from the pool if supplied. /// </summary> /// <param name="serializationStream">The stream to deserialize.</param> /// <param name="pMan">The pool manager. This can be null, in which case, a new object will be created.</param> /// <returns>The content object</returns> public virtual object Deserialize(Stream serializationStream, IXimuraPoolManager pMan) { throw new NotImplementedException("FormatterBase/Deserialize is not implemented."); }
/// <summary> /// This protected method disposes of the default pool manager for the application. /// </summary> protected virtual void PoolManagerStop() { PoolManager = null; }