internal static SerializeableAlternateView GetSerializeableAlternateView(AlternateView av)
        {
            if (av == null)
            {
                return(null);
            }

            SerializeableAlternateView sav = new SerializeableAlternateView();

            sav.BaseUri   = av.BaseUri;
            sav.ContentId = av.ContentId;

            if (av.ContentStream != null)
            {
                byte[] bytes = new byte[av.ContentStream.Length];
                av.ContentStream.Read(bytes, 0, bytes.Length);
                sav.ContentStream = new MemoryStream(bytes);
            }

            sav.ContentType = SerializeableContentType.GetSerializeableContentType(av.ContentType);

            foreach (LinkedResource lr in av.LinkedResources)
            {
                sav.LinkedResources.Add(SerializeableLinkedResource.GetSerializeableLinkedResource(lr));
            }

            sav.TransferEncoding = av.TransferEncoding;
            return(sav);
        }
        internal static SerializeableAttachment GetSerializeableAttachment(Attachment att)
        {
            if (att == null)
            {
                return(null);
            }

            SerializeableAttachment saa = new SerializeableAttachment();

            saa.ContentId          = att.ContentId;
            saa.ContentDisposition = SerializeableContentDisposition.GetSerializeableContentDisposition(att.ContentDisposition);

            if (att.ContentStream != null)
            {
                byte[] bytes = new byte[att.ContentStream.Length];
                att.ContentStream.Read(bytes, 0, bytes.Length);

                saa.ContentStream = new MemoryStream(bytes);
            }

            saa.ContentType      = SerializeableContentType.GetSerializeableContentType(att.ContentType);
            saa.Name             = att.Name;
            saa.TransferEncoding = att.TransferEncoding;
            saa.NameEncoding     = att.NameEncoding;
            return(saa);
        }
        internal static SerializeableContentType GetSerializeableContentType(System.Net.Mime.ContentType ct)
        {
            if (ct == null)
            {
                return(null);
            }

            SerializeableContentType sct = new SerializeableContentType();

            sct.Boundary   = ct.Boundary;
            sct.CharSet    = ct.CharSet;
            sct.MediaType  = ct.MediaType;
            sct.Name       = ct.Name;
            sct.Parameters = SerializeableCollection.GetSerializeableCollection(ct.Parameters);

            return(sct);
        }
        internal static SerializeableLinkedResource GetSerializeableLinkedResource(LinkedResource lr)
        {
            if (lr == null)
            {
                return(null);
            }

            SerializeableLinkedResource slr = new SerializeableLinkedResource();

            slr.ContentId   = lr.ContentId;
            slr.ContentLink = lr.ContentLink;

            if (lr.ContentStream != null)
            {
                byte[] bytes = new byte[lr.ContentStream.Length];
                lr.ContentStream.Read(bytes, 0, bytes.Length);
                slr.ContentStream = new MemoryStream(bytes);
            }

            slr.ContentType      = SerializeableContentType.GetSerializeableContentType(lr.ContentType);
            slr.TransferEncoding = lr.TransferEncoding;

            return(slr);
        }