source: other-projects/playing-in-the-street/summer-2013/trunk/Microsoft.Samples.Kinect.Webserver/FileRequestHandlerFactory.cs@ 28896

Last change on this file since 28896 was 28896, checked in by davidb, 10 years ago

Core Web Server that connects to the Kinect device

File size: 1.8 KB
Line 
1// -----------------------------------------------------------------------
2// <copyright file="FileRequestHandlerFactory.cs" company="Microsoft">
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// </copyright>
5// -----------------------------------------------------------------------
6
7namespace Microsoft.Samples.Kinect.Webserver
8{
9 using System;
10 using System.Globalization;
11 using System.IO;
12
13 /// <summary>
14 /// Implementation of IHttpRequestHandlerFactory used to create instances of
15 /// <see cref="FileRequestHandler"/> objects.
16 /// </summary>
17 public class FileRequestHandlerFactory : IHttpRequestHandlerFactory
18 {
19 /// <summary>
20 /// Root directory in server's file system from which we're serving files.
21 /// </summary>
22 private readonly DirectoryInfo rootDirectory;
23
24 /// <summary>
25 /// Initializes a new instance of the <see cref="FileRequestHandlerFactory"/> class.
26 /// </summary>
27 /// <param name="rootDirectoryName">
28 /// Root directory name in server's file system from which files should be served.
29 /// The directory must exist at the time of the call.
30 /// </param>
31 internal FileRequestHandlerFactory(string rootDirectoryName)
32 {
33 if (!Directory.Exists(rootDirectoryName))
34 {
35 throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, @"The specified directory '{0}' does not exist", rootDirectoryName), "rootDirectoryName");
36 }
37
38 this.rootDirectory = new DirectoryInfo(rootDirectoryName);
39 }
40
41 public IHttpRequestHandler CreateHandler()
42 {
43 return new FileRequestHandler(this.rootDirectory);
44 }
45 }
46}
Note: See TracBrowser for help on using the repository browser.