websocket-server – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Collections.Generic;
3 using System.Configuration;
4 using System.Linq;
5 using System.Text;
6 using System.IO;
7 using System.Reflection;
8 using System.Xml;
9  
10 namespace WebSockets.Server.Http
11 {
12 class MimeTypes : Dictionary<string,string>
13 {
14 public MimeTypes(string webRoot)
15 {
16 string configFileName = webRoot + @"\MimeTypes.config";
17 if (!File.Exists(configFileName))
18 {
19 throw new FileNotFoundException("Mime Types config file not found: " + configFileName);
20 }
21  
22 try
23 {
24 XmlDocument document = new XmlDocument();
25 document.Load(configFileName);
26 foreach (XmlNode node in document.SelectNodes("configuration/system.webServer/staticContent/mimeMap"))
27 {
28 string fileExtension = node.Attributes["fileExtension"].Value;
29 string mimeType = node.Attributes["mimeType"].Value;
30 this.Add(fileExtension, mimeType);
31 }
32 }
33 catch (Exception ex)
34 {
35 throw new ConfigurationErrorsException("Invalid Mime Types configuration file: " + configFileName, ex);
36 }
37 }
38 }
39 }