Statistics
| Branch: | Revision:

root / trunk / hammock / src / net35 / Hammock / Web / HttpPostParameter.cs @ 0eea575a

History | View | Annotate | Download (2.1 kB)

1
using System;
2
using System.IO;
3

    
4
namespace Hammock.Web
5
{
6
    public class HttpPostParameter : WebParameter
7
    {
8
        public HttpPostParameter(string name, string value) : base(name, value)
9
        {
10

    
11
        }
12

    
13
        public virtual HttpPostParameterType Type { get; private set; }
14
        public virtual string FileName { get; private set; }
15
        public virtual string FilePath { get; private set; }
16
        public virtual Stream FileStream { get; set; }
17
        public virtual string ContentType { get; private set; }
18
        public virtual string ContentDisposition { get; set; }
19

    
20
        public static HttpPostParameter CreateFile(string name, 
21
                                                   string fileName, 
22
                                                   string filePath, 
23
                                                   string contentType,
24
                                                   string contentDisposition)
25
        {
26
            var parameter = new HttpPostParameter(name, string.Empty)
27
                                {
28
                                    Type = HttpPostParameterType.File,
29
                                    FileName = fileName,
30
                                    FilePath = filePath,
31
                                    ContentType = contentType,
32
                                    ContentDisposition = contentDisposition
33
                                };
34
            return parameter;
35
        }
36

    
37
        public static HttpPostParameter CreateFile(string name, 
38
                                                   string fileName, 
39
                                                   Stream fileStream, 
40
                                                   string contentType,
41
                                                   string contentDisposition)
42
        {
43
            var parameter = new HttpPostParameter(name, string.Empty)
44
            {
45
                Type = HttpPostParameterType.File,
46
                FileName = fileName,
47
                FileStream = fileStream,
48
                ContentType = contentType,
49
                ContentDisposition = contentDisposition
50
            };
51

    
52
            return parameter;
53
        }
54
    }
55
}