예제 #1
0
        /// <summary>
        /// Wrap the given content in another type and send over this session.
        /// </summary>
        /// <param name="wrapType">the (mime-)type to wrap it in.</param>
        /// <param name="from">from-field</param>
        /// <param name="to">to-field</param>
        /// <param name="contentType">the (mime-)type to wrap.</param>
        /// <param name="content">actual content</param>
        /// <returns>the message-object that will be send, can be used
        ///     to abort large content.</returns>
        public OutgoingMessage SendWrappedMessage(string wrapType, string from, string to, string contentType, byte[] content)
        {
            Wrap wrap = Wrap.GetInstance();

            if (wrap.IsWrapperType(wrapType))
            {
                IWrappedMessage wm = wrap.GetWrapper(wrapType);
                return(SendMessage(new OutgoingMessage(wrapType, wm.Wrap(from, to, contentType, content))));
            }
            return(null);
        }
        public override Message Validate()
        {
            if (From != null)
            {
                Wrap            wrap       = Wrap.GetInstance();
                IWrappedMessage wm         = wrap.GetWrapper(Header.CPIM_TYPE);
                byte[]          newContent = wm.Wrap(From, To, ContentType, DataContainer.Get(0, Size));
                ContentType   = Header.CPIM_TYPE;
                DataContainer = new MemoryDataContainer(newContent);
                Size          = newContent.Length;
            }

            return(this);
        }