// -----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// -----------------------------------------------------------------------
namespace Microsoft.Samples.Kinect.Webserver
{
using System;
using System.Globalization;
using System.IO;
///
/// Implementation of IHttpRequestHandlerFactory used to create instances of
/// objects.
///
public class FileRequestHandlerFactory : IHttpRequestHandlerFactory
{
///
/// Root directory in server's file system from which we're serving files.
///
private readonly DirectoryInfo rootDirectory;
///
/// Initializes a new instance of the class.
///
///
/// Root directory name in server's file system from which files should be served.
/// The directory must exist at the time of the call.
///
internal FileRequestHandlerFactory(string rootDirectoryName)
{
if (!Directory.Exists(rootDirectoryName))
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, @"The specified directory '{0}' does not exist", rootDirectoryName), "rootDirectoryName");
}
this.rootDirectory = new DirectoryInfo(rootDirectoryName);
}
public IHttpRequestHandler CreateHandler()
{
return new FileRequestHandler(this.rootDirectory);
}
}
}