Example #1
0
        private static SectionData getSectionData(MultiPartSection section)
        {
            string contentDisposition = section.Headers["Content-Disposition"];

            if (contentDisposition == null)
            {
                return(null);
            }
            string[] parts = contentDisposition.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(p => p.Trim())
                             .ToArray();
            var lookup = parts
                         .Select(p => p.Split(new char[] { '=' }, 2))
                         .Where(p => p.Length == 2)
                         .ToLookup(p => p[0], p => p[1].Trim(' ', '"'), StringComparer.CurrentCultureIgnoreCase);
            SectionData data = new SectionData();

            data.Name        = getName(lookup["name"].FirstOrDefault());
            data.FileName    = getName(lookup["filename"].FirstOrDefault());
            data.ContentType = section.Headers["Content-Type"];
            data.Contents    = copyData(section.Content);
            return(data);
        }
 private static SectionData getSectionData(MultiPartSection section)
 {
     string contentDisposition = section.Headers["Content-Disposition"];
     if (contentDisposition == null)
     {
         return null;
     }
     string[] parts = contentDisposition.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
         .Select(p => p.Trim())
         .ToArray();
     var lookup = parts
         .Select(p => p.Split(new char[] { '=' }, 2))
         .Where(p => p.Length == 2)
         .ToLookup(p => p[0], p => p[1].Trim(' ', '"'), StringComparer.CurrentCultureIgnoreCase);
     SectionData data = new SectionData();
     data.Name = getName(lookup["name"].FirstOrDefault());
     data.FileName = getName(lookup["filename"].FirstOrDefault());
     data.ContentType = section.Headers["Content-Type"];
     data.Contents = copyData(section.Content);
     return data;
 }