Engine Class

IT Hit WebDAV for .NET

Serves as the abstract base class for WebDAV engine.

For a list of all members of this type, see Engine Members.

System.Object
   ITHit.WebDAV.Server.Engine

[Visual Basic]
MustInherit Public Class Engine
[C#]
public abstract class Engine

Thread Safety

Instance members of this class are not thread safe. You must create a separate instance of Engine class for each request.

Remarks

The Engine class provides the core implementation for WebDAV engine.

When you inherit from the Engine class, you must override GetHierarchyItem method. In this method you will search for resource, folder, lock-null, version or history item in your storage by path provided and return it to WebDAV engine.

In each HTTP request you will create separate instance of your class derived from Engine class and call one of its Run overloaded methods. Via Run method parameters engine receives all necessary information about hosting environment. Engine parses XML send by WebDAV client, processes requests making calls to your implementations of WebDAV interfaces (IHierarchyItem, IFolder, IResource and other) and finally generates XML response.

The engine provides 3 overloaded Run methods implementations. Two of them are optimized for use in IIS/ASP.NET-based server and in HttpListener-based server. The third one can be used for running the engine in virtually any hosting environment.

By default WebDAV engine searches for License.lic file in the executing and calling assembly directories. To store your license in a different place you must override License property.

Example

IIS/ASP.NET-based server:

                
public class MyHttpHandler : IHttpHandler
{
    ...
    public void ProcessRequest(HttpContext context)
    {
        context.Response.BufferOutput = false;

        FileLogger.Level = LogLevel.Debug;
        // always create log file outside of the \bin folder if hosted in IIS\ASP.NET
        FileLogger.LogFile = context.Request.PhysicalApplicationPath + "WebDAVlog.txt";

        MyEngine engine = new MyEngine();
        engine.Run(HttpContext.Current);
    }
    ...
}
                
            

HttpListener-based server:

For asynchronous HttpListener server implementation see example in Run method description.

class Program
{
    static void Main(string[] args)
    {
        HttpListener listener = new HttpListener();
        listener.Prefixes.Add("http://localhost:8080/");
        listener.Start();
        while (true)
        {
            MyEngine engine = new MyEngine();
            HttpListenerContext context = listener.GetContext();
            engine.Run(context, listener.Prefixes);
            try
            {
                context.Response.Close();
            }
            catch
            {
                // client closed connection before the content was sent
            }
        }
    }
}

Requirements

Namespace: ITHit.WebDAV.Server

Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll)

See Also

Engine Members | ITHit.WebDAV.Server Namespace