ContentHandlerFactory.cs
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//*************************************************************************************************
// ContentHandlerFactory.cs
// Owner: Mahipal Kante
//
// Creates appropriate handler for a given content type
//
// Copyright(c) Microsoft Corporation, 2010
//*************************************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebTest.WebService.Plugin.Runtime
{
/// <summary>
/// Creates appropriate handler for a given content type
/// </summary>
public class ContentHandlerFactory
{
/// <summary>
/// Creates appropriate handler for a given content type
/// </summary>
/// <param name="contentType">content type</param>
/// <returns></returns>
public static ContentHandler GetHandler(string contentType)
{
if (contentType.ToLower().Contains("msbin1"))
{
return new Msbin1ContentHandler(contentType.ToLower().Contains("soap"));
}
else if (contentType.ToLower().Contains("json"))
{
return new JsonContentHandler();
}
else if (contentType.ToLower().Contains("xml"))
{
return new ContentHandler();
}
else
{
return null;
}
}
}
}