Call IModelDoc2::Access3rdPartyStream extension method to access the 3rd party stream. Pass the boolean parameter to read or write stream.

Reading data

IThirdPartyStreamHandler::Stream property returns null for the stream which not exists on reading.

public override void OnLoadFromStream()
{
    using (var streamHandler = Model.Access3rdPartyStream(STREAM_NAME, false))
    {
        if (streamHandler.Stream != null)
        {
            using (var str = streamHandler.Stream)
            {
                var xmlSer = new XmlSerializer(typeof(RevData));
                var data = xmlSer.Deserialize(str) as RevData;
            }
        }
    }
}

Writing data

IThirdPartyStreamHandler::Stream will always return the pointer to the stream (stream is automatically created if it doesn’t exist).

public override void OnSaveToStream()
{
    using (var streamHandler = Model.Access3rdPartyStream(STREAM_NAME, true))
    {
        using (var str = streamHandler.Stream)
        {
            var xmlSer = new XmlSerializer(typeof(RevData));

            xmlSer.Serialize(str, m_RevData);
        }
    }
}