using System; using System.Collections.Generic; using System.Linq; namespace WebDAVSharp.Server.MethodHandlers { /// /// This class contains code to produce the built-in /// instances known by WebDAV#. /// internal static class WebDavMethodHandlers { private static readonly List _BuiltIn = new List(); /// /// Gets the collection of built-in /// HTTP method handler instances. /// public static IEnumerable BuiltIn { get { lock (_BuiltIn) { if (_BuiltIn.Count == 0) ScanAssemblies(); } return _BuiltIn; } } /// /// Scans the WebDAV# assemblies for known /// types. /// private static void ScanAssemblies() { IEnumerable methodHandlerTypes = from type in typeof(WebDavServer).Assembly.GetTypes() where !type.IsAbstract where typeof(IWebDavMethodHandler).IsAssignableFrom(type) select type; IEnumerable methodHandlerInstances = from type in methodHandlerTypes select (IWebDavMethodHandler)Activator.CreateInstance(type); _BuiltIn.AddRange(methodHandlerInstances); } } }