-initial commit
-fixed: made original version work in console -added: MVC WebApi Controller based server -changed: modification needeed to make it work with Train2B
This commit is contained in:
commit
895efb2682
|
@ -0,0 +1,109 @@
|
||||||
|
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# mstest test results
|
||||||
|
TestResults
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
packages
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
[Bb]in
|
||||||
|
[Oo]bj
|
||||||
|
sql
|
||||||
|
TestResults
|
||||||
|
[Tt]est[Rr]esult*
|
||||||
|
*.Cache
|
||||||
|
ClientBin
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*.dbmdl
|
||||||
|
Generated_Code #added for RIA/Silverlight projects
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
*.db
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Client.WebDav;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Client
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This program will do a PROPFIND request to the WebDAV server.
|
||||||
|
/// The statuscode and statusdescription will be written to the console.
|
||||||
|
/// </summary>
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
// change according to your configuration
|
||||||
|
private const string Url = "http://localhost:8880/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mains the specified arguments.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">The arguments.</param>
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("PROPFIND " + Url);
|
||||||
|
|
||||||
|
// do the request and get the WebResponse
|
||||||
|
WebResponse response = WebDavMethod.Propfind(Url);
|
||||||
|
|
||||||
|
// cast to an HttpWebResponse
|
||||||
|
HttpWebResponse httpWebResponse = response as HttpWebResponse;
|
||||||
|
|
||||||
|
// if not null, write statuscodes to the console
|
||||||
|
if (httpWebResponse != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine((int)httpWebResponse.StatusCode + " " + httpWebResponse.StatusDescription);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("HttpWebResponse was null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("WebDAVSharp.Client")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("WebDAVSharp.Client")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("508bbb9d-cbf5-4245-a9d7-f4bb63f1fd7f")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,17 @@
|
||||||
|
Client
|
||||||
|
======
|
||||||
|
|
||||||
|
A console application that, by using the WebDAV methods, can do a request to a WebDAV server and read the response.
|
||||||
|
|
||||||
|
The client is developed in the .NET Framework 4.5 for the [WebDAV server of WebDAV#][1].
|
||||||
|
|
||||||
|
## Developed by ##
|
||||||
|
|
||||||
|
This version of WebDAV# has been developed by [Lieven Janssen][2] and [Ewout Merckx][3] at [Xplore+][4].
|
||||||
|
|
||||||
|
|
||||||
|
[1]: https://github.com/WebDAVSharp/WebDAVSharp.Server
|
||||||
|
[2]: https://www.linkedin.com/in/lievenjanssen/
|
||||||
|
[3]: https://www.linkedin.com/in/ewoutmerckx
|
||||||
|
[4]: http://xploreplus.com/
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{0F50A483-D669-4258-B471-E815E1CFA8FA}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>WebDAVSharp.Client</RootNamespace>
|
||||||
|
<AssemblyName>WebDAVSharp.Client</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="WebDav\WebDav.cs" />
|
||||||
|
<Compile Include="WebDav\WebDavConfig.cs" />
|
||||||
|
<Compile Include="WebDav\WebDavMethod.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDAVSharp.Client", "WebDAVSharp.Client.csproj", "{0F50A483-D669-4258-B471-E815E1CFA8FA}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0F50A483-D669-4258-B471-E815E1CFA8FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0F50A483-D669-4258-B471-E815E1CFA8FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0F50A483-D669-4258-B471-E815E1CFA8FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0F50A483-D669-4258-B471-E815E1CFA8FA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,112 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Client.WebDav
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The basics for talking to the WebDAV server
|
||||||
|
/// </summary>
|
||||||
|
internal static class WebDav
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get the credentials of the user
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The request URI</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The credentials as an instance of <see cref="CredentialCache" />
|
||||||
|
/// </returns>
|
||||||
|
internal static CredentialCache WebDavCredentialCache(string requestUri)
|
||||||
|
{
|
||||||
|
var myCredentialCache = new CredentialCache
|
||||||
|
{
|
||||||
|
{
|
||||||
|
new Uri(requestUri),
|
||||||
|
"Negotiate",
|
||||||
|
new NetworkCredential(WebDavConfig.UserName, WebDavConfig.Password, WebDavConfig.Domain)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return myCredentialCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a basic WebDav Request
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The requested URI as an <see cref="Uri" /></param>
|
||||||
|
/// <param name="method">The <see cref="string" /> defining the WebDAV method to be used</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The basic WebDav Request as an <see cref="HttpWebRequest" />
|
||||||
|
/// </returns>
|
||||||
|
internal static HttpWebRequest WebDavRequestBase(string requestUri, string method)
|
||||||
|
{
|
||||||
|
// Create the HttpWebRequest object.
|
||||||
|
var request = (HttpWebRequest)WebRequest.Create(requestUri);
|
||||||
|
|
||||||
|
request.UserAgent = "WebDAV-UnitTestProject/1.0.0";
|
||||||
|
|
||||||
|
// Add the network credentials to the request.
|
||||||
|
request.UseDefaultCredentials = true;
|
||||||
|
|
||||||
|
// Specify the WebDAV method.
|
||||||
|
request.Method = method;
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the response of the given <see cref="HttpWebRequest" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="HttpWebRequest" /></param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="WebResponse" /> of the <see cref="HttpWebRequest" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse WebDavResponse(HttpWebRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Send the WebDav method request, get the
|
||||||
|
// method response from the server.
|
||||||
|
WebResponse response = request.GetResponse();
|
||||||
|
Stream stream = response.GetResponseStream();
|
||||||
|
Encoding encode = Encoding.GetEncoding("utf-8");
|
||||||
|
|
||||||
|
// Pipes the stream to a higher level stream reader with the required encoding format.
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
var readStream = new StreamReader(stream, encode);
|
||||||
|
var read = new Char[256];
|
||||||
|
String str = "";
|
||||||
|
// Reads 256 characters at a time.
|
||||||
|
int count = readStream.Read(read, 0, 256);
|
||||||
|
while (count > 0)
|
||||||
|
{
|
||||||
|
// Dumps the 256 characters on a string and displays the string to the console.
|
||||||
|
str += new String(read, 0, count);
|
||||||
|
count = readStream.Read(read, 0, 256);
|
||||||
|
}
|
||||||
|
// Releases the resources of the Stream.
|
||||||
|
readStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the HttpWebResponse object.
|
||||||
|
response.Close();
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
catch (WebException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return ex.Response;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Catch any exceptions. Any error codes from the WebDAV
|
||||||
|
// method request on the server will be caught here, also.
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Client.WebDav
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The parameters for the configuration must be defined here
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavConfig
|
||||||
|
{
|
||||||
|
internal static readonly string UserName = "your_username";
|
||||||
|
internal static readonly string Password = "your_password";
|
||||||
|
internal static readonly string Domain = "your_domain";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,241 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Cache;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Client.WebDav
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The WebDAV methods to use are defined in this class
|
||||||
|
/// </summary>
|
||||||
|
internal static class WebDavMethod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Propfind method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="depth">The <see cref="string" /> for the Depth header</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Propfind(string requestUri, string depth = "", string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "PROPFIND");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
request.Headers.Add("Depth", depth);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV MkCol method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse MkCol(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "MKCOL");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Delete method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Delete(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "DELETE");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Put method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Put(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "PUT");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Copy method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="destinationUri">The <see cref="string" /> for the Destination header</param>
|
||||||
|
/// <param name="overwrite">The <see cref="bool" /> for the Overwrite header</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Copy(string requestUri, string destinationUri, bool overwrite = false)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "COPY");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.Headers.Add("Destination", destinationUri);
|
||||||
|
request.Headers.Add("Overwrite", overwrite ? "T" : "F");
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Move method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="destinationUri">The <see cref="string" /> for the Destination header</param>
|
||||||
|
/// <param name="overwrite">The <see cref="bool" /> for the Overwrite header</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Move(string requestUri, string destinationUri, bool overwrite = false)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "MOVE");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.Headers.Add("Destination", destinationUri);
|
||||||
|
request.Headers.Add("Overwrite", overwrite ? "T" : "F");
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Lock method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Lock(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "LOCK");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
request.ContentType = "text/xml; charset=\"utf-8\"";
|
||||||
|
request.Timeout = 3600;
|
||||||
|
|
||||||
|
request.Headers.Add("Depth", "0"); //can also be infinity
|
||||||
|
request.Headers.Add("Pragma", "no-cache");
|
||||||
|
|
||||||
|
// send content
|
||||||
|
var encoding = new UTF8Encoding();
|
||||||
|
byte[] byte1 = encoding.GetBytes(content);
|
||||||
|
Stream newStream = request.GetRequestStream();
|
||||||
|
newStream.Write(byte1, 0, byte1.Length);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Unlock method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Unlock(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "UNLOCK");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Options method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Options(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "OPTIONS");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Head method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Head(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "HEAD");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Proppatch method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Proppatch(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "PROPPATCH");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
request.ContentType = "text/xml; charset=\"utf-8\"";
|
||||||
|
|
||||||
|
// send content
|
||||||
|
var encoding = new UTF8Encoding();
|
||||||
|
byte[] byte1 = encoding.GetBytes(content);
|
||||||
|
Stream newStream = request.GetRequestStream();
|
||||||
|
newStream.Write(byte1, 0, byte1.Length);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Get method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Get(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "GET");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# mstest test results
|
||||||
|
TestResults
|
||||||
|
|
||||||
|
# GhostDoc
|
||||||
|
*.sln.GhostDoc.xml
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
packages
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
[Bb]in
|
||||||
|
[Oo]bj
|
||||||
|
sql
|
||||||
|
TestResults
|
||||||
|
[Tt]est[Rr]esult*
|
||||||
|
*.Cache
|
||||||
|
ClientBin
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*.dbmdl
|
||||||
|
Generated_Code #added for RIA/Silverlight projects
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
*.db
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<solution>
|
||||||
|
<add key="disableSourceControlIntegration" value="true" />
|
||||||
|
</solution>
|
||||||
|
</configuration>
|
Binary file not shown.
|
@ -0,0 +1,144 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||||
|
|
||||||
|
<!-- Enable the restore command to run before builds -->
|
||||||
|
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||||
|
|
||||||
|
<!-- Property that enables building a package from a project -->
|
||||||
|
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||||
|
|
||||||
|
<!-- Determines if package restore consent is required to restore packages -->
|
||||||
|
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||||
|
|
||||||
|
<!-- Download NuGet.exe if it does not already exist -->
|
||||||
|
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||||
|
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
|
||||||
|
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
|
||||||
|
<!--
|
||||||
|
<PackageSource Include="https://www.nuget.org/api/v2/" />
|
||||||
|
<PackageSource Include="https://my-nuget-source/nuget/" />
|
||||||
|
-->
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||||
|
<!-- Windows specific commands -->
|
||||||
|
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||||
|
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||||
|
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
|
||||||
|
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
|
||||||
|
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- NuGet command -->
|
||||||
|
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||||
|
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||||
|
|
||||||
|
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||||
|
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
|
||||||
|
|
||||||
|
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
|
||||||
|
|
||||||
|
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||||
|
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||||
|
|
||||||
|
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
|
||||||
|
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
|
||||||
|
|
||||||
|
<!-- Commands -->
|
||||||
|
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||||
|
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||||
|
|
||||||
|
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||||
|
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||||
|
RestorePackages;
|
||||||
|
$(BuildDependsOn);
|
||||||
|
</BuildDependsOn>
|
||||||
|
|
||||||
|
<!-- Make the build depend on restore packages -->
|
||||||
|
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||||
|
$(BuildDependsOn);
|
||||||
|
BuildPackage;
|
||||||
|
</BuildDependsOn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="CheckPrerequisites">
|
||||||
|
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||||
|
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||||
|
<!--
|
||||||
|
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||||
|
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||||
|
parallel builds will have to wait for it to complete.
|
||||||
|
-->
|
||||||
|
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_DownloadNuGet">
|
||||||
|
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||||
|
<Exec Command="$(RestoreCommand)"
|
||||||
|
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||||
|
|
||||||
|
<Exec Command="$(RestoreCommand)"
|
||||||
|
LogStandardErrorAsError="true"
|
||||||
|
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||||
|
<Exec Command="$(BuildCommand)"
|
||||||
|
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||||
|
|
||||||
|
<Exec Command="$(BuildCommand)"
|
||||||
|
LogStandardErrorAsError="true"
|
||||||
|
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||||
|
<ParameterGroup>
|
||||||
|
<OutputFilename ParameterType="System.String" Required="true" />
|
||||||
|
</ParameterGroup>
|
||||||
|
<Task>
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Using Namespace="System" />
|
||||||
|
<Using Namespace="System.IO" />
|
||||||
|
<Using Namespace="System.Net" />
|
||||||
|
<Using Namespace="Microsoft.Build.Framework" />
|
||||||
|
<Using Namespace="Microsoft.Build.Utilities" />
|
||||||
|
<Code Type="Fragment" Language="cs">
|
||||||
|
<![CDATA[
|
||||||
|
try {
|
||||||
|
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||||
|
|
||||||
|
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||||
|
WebClient webClient = new WebClient();
|
||||||
|
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Log.LogErrorFromException(ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</Code>
|
||||||
|
</Task>
|
||||||
|
</UsingTask>
|
||||||
|
</Project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,112 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The console harness.
|
||||||
|
/// </summary>
|
||||||
|
public static class ConsoleHarness
|
||||||
|
{
|
||||||
|
#region Public Methods and Operators
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The run.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">
|
||||||
|
/// The args.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="service">
|
||||||
|
/// The service.
|
||||||
|
/// </param>
|
||||||
|
public static void Run(string[] args, IWindowsService service)
|
||||||
|
{
|
||||||
|
string serviceName = service.GetType().Name;
|
||||||
|
bool isRunning = true;
|
||||||
|
|
||||||
|
// simulate starting the windows service
|
||||||
|
service.OnStart(args);
|
||||||
|
|
||||||
|
// let it run as long as Q is not pressed
|
||||||
|
while (isRunning)
|
||||||
|
{
|
||||||
|
WriteToConsole(ConsoleColor.Yellow, "Enter either [Q]uit, [P]ause, [R]esume : ");
|
||||||
|
isRunning = HandleConsoleInput(service, Console.ReadLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop and shutdown
|
||||||
|
service.OnStop();
|
||||||
|
service.OnShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The write to console.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="foregroundColor">
|
||||||
|
/// The foreground color.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="format">
|
||||||
|
/// The format.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="formatArguments">
|
||||||
|
/// The format arguments.
|
||||||
|
/// </param>
|
||||||
|
public static void WriteToConsole(ConsoleColor foregroundColor, string format, params object[] formatArguments)
|
||||||
|
{
|
||||||
|
ConsoleColor originalColor = Console.ForegroundColor;
|
||||||
|
Console.ForegroundColor = foregroundColor;
|
||||||
|
|
||||||
|
Console.WriteLine(format, formatArguments);
|
||||||
|
Console.Out.Flush();
|
||||||
|
|
||||||
|
Console.ForegroundColor = originalColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The handle console input.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="service">
|
||||||
|
/// The service.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="line">
|
||||||
|
/// The line.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="bool" />.
|
||||||
|
/// </returns>
|
||||||
|
private static bool HandleConsoleInput(IWindowsService service, string line)
|
||||||
|
{
|
||||||
|
bool canContinue = true;
|
||||||
|
|
||||||
|
// check input
|
||||||
|
if (line != null)
|
||||||
|
{
|
||||||
|
switch (line.ToUpper())
|
||||||
|
{
|
||||||
|
case "Q":
|
||||||
|
canContinue = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "P":
|
||||||
|
service.OnPause();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "R":
|
||||||
|
service.OnContinue();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
WriteToConsole(ConsoleColor.Red, "Did not understand that input, try again.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return canContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The interface that any windows service should implement to be used
|
||||||
|
/// with the GenericWindowsService executable.
|
||||||
|
/// </summary>
|
||||||
|
public interface IWindowsService : IDisposable
|
||||||
|
{
|
||||||
|
#region Public Methods and Operators
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when a service gets a request to resume
|
||||||
|
/// after a pause is issued.
|
||||||
|
/// </summary>
|
||||||
|
void OnContinue();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when a service gets a request to pause,
|
||||||
|
/// but not stop completely.
|
||||||
|
/// </summary>
|
||||||
|
void OnPause();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when the machine the service is running on
|
||||||
|
/// is being shutdown.
|
||||||
|
/// </summary>
|
||||||
|
void OnShutdown();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when the service gets a request to start.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">
|
||||||
|
/// Any command line arguments
|
||||||
|
/// </param>
|
||||||
|
void OnStart(string[] args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when the service gets a request to stop.
|
||||||
|
/// </summary>
|
||||||
|
void OnStop();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for the Type class
|
||||||
|
/// </summary>
|
||||||
|
public static class TypeExtensions
|
||||||
|
{
|
||||||
|
#region Public Methods and Operators
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the configuration from assembly attributes
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">
|
||||||
|
/// The type of the custom attribute to find.
|
||||||
|
/// </typeparam>
|
||||||
|
/// <param name="typeWithAttributes">
|
||||||
|
/// The calling assembly to search.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// The custom attribute of type T, if found.
|
||||||
|
/// </returns>
|
||||||
|
public static T GetAttribute<T>(this Type typeWithAttributes) where T : Attribute
|
||||||
|
{
|
||||||
|
return GetAttributes<T>(typeWithAttributes).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the configuration from assembly attributes
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">
|
||||||
|
/// The type of the custom attribute to find.
|
||||||
|
/// </typeparam>
|
||||||
|
/// <param name="typeWithAttributes">
|
||||||
|
/// The calling assembly to search.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// An enumeration of attributes of type T that were found.
|
||||||
|
/// </returns>
|
||||||
|
public static IEnumerable<T> GetAttributes<T>(this Type typeWithAttributes) where T : Attribute
|
||||||
|
{
|
||||||
|
// Try to find the configuration attribute for the default logger if it exists
|
||||||
|
object[] configAttributes = Attribute.GetCustomAttributes(typeWithAttributes, typeof (T), false);
|
||||||
|
|
||||||
|
// get just the first one
|
||||||
|
if (configAttributes.Length <= 0) yield break;
|
||||||
|
foreach (T attribute in configAttributes)
|
||||||
|
{
|
||||||
|
yield return attribute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
using System;
|
||||||
|
using System.ServiceProcess;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The windows service attribute.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class WindowsServiceAttribute : Attribute
|
||||||
|
{
|
||||||
|
#region Constructors and Destructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WindowsServiceAttribute" /> class.
|
||||||
|
/// Marks an IWindowsService with configuration and installation attributes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">
|
||||||
|
/// The name of the windows service.
|
||||||
|
/// </param>
|
||||||
|
public WindowsServiceAttribute(string name)
|
||||||
|
{
|
||||||
|
// set name and default description and display name to name.
|
||||||
|
Name = name;
|
||||||
|
Description = name;
|
||||||
|
DisplayName = name;
|
||||||
|
|
||||||
|
// default all other attributes.
|
||||||
|
CanStop = true;
|
||||||
|
CanShutdown = true;
|
||||||
|
CanPauseAndContinue = true;
|
||||||
|
StartMode = ServiceStartMode.Manual;
|
||||||
|
EventLogSource = null;
|
||||||
|
Password = null;
|
||||||
|
UserName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if service supports pause and continue (defaults to true).
|
||||||
|
/// </summary>
|
||||||
|
public bool CanPauseAndContinue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if service supports shutdown event (defaults to true).
|
||||||
|
/// </summary>
|
||||||
|
public bool CanShutdown { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if service supports stop event (defaults to true).
|
||||||
|
/// </summary>
|
||||||
|
public bool CanStop { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A textural description of the service name (defaults to Name).
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The displayable name that shows in service manager (defaults to Name).
|
||||||
|
/// </summary>
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies the event log source to set the service's EventLog to. If this is
|
||||||
|
/// empty or null (the default) no event log source is set. If set, will auto-log
|
||||||
|
/// start and stop events.
|
||||||
|
/// </summary>
|
||||||
|
public string EventLogSource { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the service.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The password to run the service under (defaults to null). Ignored
|
||||||
|
/// if the UserName is empty or null, this property is ignored.
|
||||||
|
/// </summary>
|
||||||
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The method to start the service when the machine reboots (defaults to Manual).
|
||||||
|
/// </summary>
|
||||||
|
public ServiceStartMode StartMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The user to run the service under (defaults to null). A null or empty
|
||||||
|
/// UserName field causes the service to run as ServiceAccount.LocalService.
|
||||||
|
/// </summary>
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
public partial class WindowsServiceHarness
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (this.components != null))
|
||||||
|
{
|
||||||
|
this.components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.ServiceName = "APPA.RawInvoiceSystemService";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,136 @@
|
||||||
|
using System;
|
||||||
|
using System.ServiceProcess;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A generic Windows Service that can handle any assembly that
|
||||||
|
/// implements IWindowsService (including AbstractWindowsService)
|
||||||
|
/// </summary>
|
||||||
|
public partial class WindowsServiceHarness : ServiceBase
|
||||||
|
{
|
||||||
|
#region Constructors and Destructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WindowsServiceHarness" /> class.
|
||||||
|
/// Constructor a generic windows service from the given class
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceImplementation">
|
||||||
|
/// Service implementation.
|
||||||
|
/// </param>
|
||||||
|
public WindowsServiceHarness(IWindowsService serviceImplementation)
|
||||||
|
{
|
||||||
|
// make sure service passed in is valid
|
||||||
|
if (serviceImplementation == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serviceImplementation), "IWindowsService cannot be null in call to GenericWindowsService");
|
||||||
|
}
|
||||||
|
|
||||||
|
// set instance and backward instance
|
||||||
|
ServiceImplementation = serviceImplementation;
|
||||||
|
|
||||||
|
// configure our service
|
||||||
|
ConfigureServiceFromAttributes(serviceImplementation);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the class implementing the windows service
|
||||||
|
/// </summary>
|
||||||
|
public IWindowsService ServiceImplementation { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override service control on continue
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnContinue()
|
||||||
|
{
|
||||||
|
// perform class specific behavior
|
||||||
|
ServiceImplementation.OnContinue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when service is paused
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnPause()
|
||||||
|
{
|
||||||
|
// perform class specific behavior
|
||||||
|
ServiceImplementation.OnPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the Operating System is shutting down
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnShutdown()
|
||||||
|
{
|
||||||
|
// perform class specific behavior
|
||||||
|
ServiceImplementation.OnShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when service is requested to start
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">
|
||||||
|
/// The startup arguments array.
|
||||||
|
/// </param>
|
||||||
|
protected override void OnStart(string[] args)
|
||||||
|
{
|
||||||
|
ServiceImplementation.OnStart(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when service is requested to stop
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnStop()
|
||||||
|
{
|
||||||
|
ServiceImplementation.OnStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set configuration data
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceImplementation">
|
||||||
|
/// The service with configuration settings.
|
||||||
|
/// </param>
|
||||||
|
private void ConfigureServiceFromAttributes(IWindowsService serviceImplementation)
|
||||||
|
{
|
||||||
|
var attribute = serviceImplementation.GetType().GetAttribute<WindowsServiceAttribute>();
|
||||||
|
|
||||||
|
if (attribute != null)
|
||||||
|
{
|
||||||
|
// wire up the event log source, if provided
|
||||||
|
if (!string.IsNullOrWhiteSpace(attribute.EventLogSource))
|
||||||
|
{
|
||||||
|
// assign to the base service's EventLog property for auto-log events.
|
||||||
|
EventLog.Source = attribute.EventLogSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
CanStop = attribute.CanStop;
|
||||||
|
CanPauseAndContinue = attribute.CanPauseAndContinue;
|
||||||
|
CanShutdown = attribute.CanShutdown;
|
||||||
|
|
||||||
|
// we don't handle: laptop power change event
|
||||||
|
CanHandlePowerEvent = false;
|
||||||
|
|
||||||
|
// we don't handle: Term Services session event
|
||||||
|
CanHandleSessionChangeEvent = false;
|
||||||
|
|
||||||
|
// always auto-event-log
|
||||||
|
AutoLog = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
string.Format("IWindowsService implementer {0} must have a WindowsServiceAttribute.", serviceImplementation.GetType().FullName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
public partial class WindowsServiceInstaller
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (this.components != null))
|
||||||
|
{
|
||||||
|
this.components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,229 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Configuration.Install;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.ServiceProcess;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A generic windows service installer
|
||||||
|
/// </summary>
|
||||||
|
[RunInstaller(true)]
|
||||||
|
public partial class WindowsServiceInstaller : Installer
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the type of the windows service to install.
|
||||||
|
/// </summary>
|
||||||
|
public WindowsServiceAttribute Configuration { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors and Destructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WindowsServiceInstaller" /> class.
|
||||||
|
/// Creates a blank windows service installer with configuration in ServiceImplementation
|
||||||
|
/// </summary>
|
||||||
|
public WindowsServiceInstaller()
|
||||||
|
: this(typeof (IWindowsService))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WindowsServiceInstaller" /> class.
|
||||||
|
/// Creates a windows service installer using the type specified.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowsServiceType">
|
||||||
|
/// The type of the windows service to install.
|
||||||
|
/// </param>
|
||||||
|
public WindowsServiceInstaller(Type windowsServiceType)
|
||||||
|
{
|
||||||
|
if (!windowsServiceType.GetInterfaces().Contains(typeof (IWindowsService)))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Type to install must implement IWindowsService.", nameof(windowsServiceType));
|
||||||
|
}
|
||||||
|
|
||||||
|
var attribute = windowsServiceType.GetAttribute<WindowsServiceAttribute>();
|
||||||
|
|
||||||
|
if (attribute == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Type to install must be marked with a WindowsServiceAttribute.", nameof(windowsServiceType));
|
||||||
|
}
|
||||||
|
|
||||||
|
Configuration = attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Methods and Operators
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a transacted installation at run-time of the AutoCounterInstaller and any other listed installers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="otherInstallers">The other installers to include in the transaction</param>
|
||||||
|
/// <typeparam name="T">The IWindowsService implementer to install.</typeparam>
|
||||||
|
public static void RuntimeInstall<T>() where T : IWindowsService
|
||||||
|
{
|
||||||
|
string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location;
|
||||||
|
|
||||||
|
using (var ti = new TransactedInstaller())
|
||||||
|
{
|
||||||
|
ti.Installers.Add(new WindowsServiceInstaller(typeof (T)));
|
||||||
|
ti.Context = new InstallContext(null, new[] {path});
|
||||||
|
ti.Install(new Hashtable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a transacted un-installation at run-time of the AutoCounterInstaller and any other listed installers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="otherInstallers">
|
||||||
|
/// The other installers to include in the transaction
|
||||||
|
/// </param>
|
||||||
|
/// <typeparam name="T">
|
||||||
|
/// The IWindowsService implementer to install.
|
||||||
|
/// </typeparam>
|
||||||
|
public static void RuntimeUnInstall<T>(params Installer[] otherInstallers) where T : IWindowsService
|
||||||
|
{
|
||||||
|
string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location;
|
||||||
|
|
||||||
|
using (var ti = new TransactedInstaller())
|
||||||
|
{
|
||||||
|
ti.Installers.Add(new WindowsServiceInstaller(typeof (T)));
|
||||||
|
ti.Context = new InstallContext(null, new[] {path});
|
||||||
|
ti.Uninstall(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Installer class, to use run InstallUtil against this .exe
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="savedState">
|
||||||
|
/// The saved state for the installation.
|
||||||
|
/// </param>
|
||||||
|
public override void Install(IDictionary savedState)
|
||||||
|
{
|
||||||
|
ConsoleHarness.WriteToConsole(ConsoleColor.White, "Installing service {0}.", Configuration.Name);
|
||||||
|
|
||||||
|
// install the service
|
||||||
|
ConfigureInstallers();
|
||||||
|
base.Install(savedState);
|
||||||
|
|
||||||
|
// wire up the event log source, if provided
|
||||||
|
if (!string.IsNullOrWhiteSpace(Configuration.EventLogSource))
|
||||||
|
{
|
||||||
|
// create the source if it doesn't exist
|
||||||
|
if (!EventLog.SourceExists(Configuration.EventLogSource))
|
||||||
|
{
|
||||||
|
EventLog.CreateEventSource(Configuration.EventLogSource, "Application");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rolls back to the state of the counter, and performs the normal rollback.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="savedState">
|
||||||
|
/// The saved state for the installation.
|
||||||
|
/// </param>
|
||||||
|
public override void Rollback(IDictionary savedState)
|
||||||
|
{
|
||||||
|
ConsoleHarness.WriteToConsole(ConsoleColor.White, "Rolling back service {0}.", Configuration.Name);
|
||||||
|
|
||||||
|
// load the assembly file name and the config
|
||||||
|
ConfigureInstallers();
|
||||||
|
base.Rollback(savedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the counters, then calls the base uninstall.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="savedState">
|
||||||
|
/// The saved state for the installation.
|
||||||
|
/// </param>
|
||||||
|
public override void Uninstall(IDictionary savedState)
|
||||||
|
{
|
||||||
|
ConsoleHarness.WriteToConsole(ConsoleColor.White, "Un-Installing service {0}.", Configuration.Name);
|
||||||
|
|
||||||
|
// load the assembly file name and the config
|
||||||
|
ConfigureInstallers();
|
||||||
|
base.Uninstall(savedState);
|
||||||
|
|
||||||
|
// wire up the event log source, if provided
|
||||||
|
if (!string.IsNullOrWhiteSpace(Configuration.EventLogSource))
|
||||||
|
{
|
||||||
|
// create the source if it doesn't exist
|
||||||
|
if (EventLog.SourceExists(Configuration.EventLogSource))
|
||||||
|
{
|
||||||
|
EventLog.DeleteEventSource(Configuration.EventLogSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method to configure the installers
|
||||||
|
/// </summary>
|
||||||
|
private void ConfigureInstallers()
|
||||||
|
{
|
||||||
|
// load the assembly file name and the config
|
||||||
|
Installers.Add(ConfigureProcessInstaller());
|
||||||
|
Installers.Add(ConfigureServiceInstaller());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to configure a process installer for this windows service
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Process installer for this service</returns>
|
||||||
|
private ServiceProcessInstaller ConfigureProcessInstaller()
|
||||||
|
{
|
||||||
|
var result = new ServiceProcessInstaller();
|
||||||
|
|
||||||
|
// if a user name is not provided, will run under local service acct
|
||||||
|
if (string.IsNullOrEmpty(Configuration.UserName))
|
||||||
|
{
|
||||||
|
result.Account = ServiceAccount.LocalService;
|
||||||
|
result.Username = null;
|
||||||
|
result.Password = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// otherwise, runs under the specified user authority
|
||||||
|
result.Account = ServiceAccount.User;
|
||||||
|
result.Username = Configuration.UserName;
|
||||||
|
result.Password = Configuration.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to configure a service installer for this windows service
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Process installer for this service</returns>
|
||||||
|
private ServiceInstaller ConfigureServiceInstaller()
|
||||||
|
{
|
||||||
|
// create and config a service installer
|
||||||
|
var result = new ServiceInstaller
|
||||||
|
{
|
||||||
|
ServiceName = Configuration.Name,
|
||||||
|
DisplayName = Configuration.DisplayName,
|
||||||
|
Description = Configuration.Description,
|
||||||
|
StartType = Configuration.StartMode
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.ServiceProcess;
|
||||||
|
using WebDAVSharp.FileExample.Framework;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// if install was a command line flag, then run the installer at runtime.
|
||||||
|
if (args.Contains("-install", StringComparer.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
WindowsServiceInstaller.RuntimeInstall<ServiceImplementation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if uninstall was a command line flag, run uninstaller at runtime.
|
||||||
|
else if (args.Contains("-uninstall", StringComparer.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
WindowsServiceInstaller.RuntimeUnInstall<ServiceImplementation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, fire up the service as either console or windows service based on UserInteractive property.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var implementation = new ServiceImplementation();
|
||||||
|
|
||||||
|
// if started from console, file explorer, etc, run as console app.
|
||||||
|
if (Environment.UserInteractive)
|
||||||
|
{
|
||||||
|
ConsoleHarness.Run(args, implementation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise run as a windows service
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
|
||||||
|
ServiceBase.Run(new WindowsServiceHarness(implementation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ConsoleHarness.WriteToConsole(ConsoleColor.Red, "An exception occurred in Main(): {0}", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("WebDAVSharp.FileExample")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("WebDAVSharp.FileExample")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
|
||||||
|
[assembly: Guid("7a312385-a2f0-4c71-9b7d-a22ab0aa7a00")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,16 @@
|
||||||
|
Example
|
||||||
|
=======
|
||||||
|
|
||||||
|
A little project that shows how to start the WebDAV# server.
|
||||||
|
|
||||||
|
This example project is developed in the .NET Framework 4.5 for the [WebDAV server of WebDAV#][1].
|
||||||
|
|
||||||
|
## Developed by ##
|
||||||
|
|
||||||
|
This version of WebDAV# has been developed by [Lieven Janssen][2] and [Ewout Merckx][3] at [Xplore+][4].
|
||||||
|
|
||||||
|
|
||||||
|
[1]: https://github.com/WebDAVSharp/WebDAVSharp.Server
|
||||||
|
[2]: https://www.linkedin.com/in/lievenjanssen/
|
||||||
|
[3]: https://www.linkedin.com/in/ewoutmerckx
|
||||||
|
[4]: http://xploreplus.com/
|
|
@ -0,0 +1,101 @@
|
||||||
|
using System.ServiceProcess;
|
||||||
|
//using Common.Logging;
|
||||||
|
using WebDAVSharp.FileExample.Framework;
|
||||||
|
using WebDAVSharp.Server;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
using WebDAVSharp.Server.Stores.DiskStore;
|
||||||
|
//using WebDAVSharp.Server.Stores.Locks;
|
||||||
|
//using WebDAVSharp.Server.Stores.Locks.Interfaces;
|
||||||
|
#if DEBUG
|
||||||
|
using Common.Logging;
|
||||||
|
using Common.Logging.Configuration;
|
||||||
|
using Common.Logging.Simple;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace WebDAVSharp.FileExample
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The actual implementation of the windows service goes here...
|
||||||
|
/// </summary>
|
||||||
|
[WindowsService("WebDavSharp.FileExample",
|
||||||
|
DisplayName = "WebDavSharp.FileExample",
|
||||||
|
Description = "WebDavSharp.FileExample",
|
||||||
|
EventLogSource = "WebDavSharp.FileExample",
|
||||||
|
StartMode = ServiceStartMode.Automatic)]
|
||||||
|
public class ServiceImplementation : IWindowsService
|
||||||
|
{
|
||||||
|
// IMPORTANT !!
|
||||||
|
// change these variables to your wanted configuration
|
||||||
|
private const string Localpath = @"D:\_Coding\Art-IST\FileStores\webdav";
|
||||||
|
private const string Url = "http://localhost:8880/";
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when the service gets a request to start.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">Any command line arguments</param>
|
||||||
|
public void OnStart(string[] args)
|
||||||
|
{
|
||||||
|
InitConsoleLogger();
|
||||||
|
StartServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when the service gets a request to stop.
|
||||||
|
/// </summary>
|
||||||
|
public void OnStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when a service gets a request to pause,
|
||||||
|
/// but not stop completely.
|
||||||
|
/// </summary>
|
||||||
|
public void OnPause()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when a service gets a request to resume
|
||||||
|
/// after a pause is issued.
|
||||||
|
/// </summary>
|
||||||
|
public void OnContinue()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called when the machine the service is running on
|
||||||
|
/// is being shutdown.
|
||||||
|
/// </summary>
|
||||||
|
public void OnShutdown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
private static void InitConsoleLogger()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
// create properties
|
||||||
|
NameValueCollection properties = new NameValueCollection();
|
||||||
|
properties["showDateTime"] = "true";
|
||||||
|
// set Adapter
|
||||||
|
LogManager.Adapter =
|
||||||
|
new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the server.
|
||||||
|
/// Authentication used: Negotiate
|
||||||
|
/// </summary>
|
||||||
|
private static void StartServer()
|
||||||
|
{
|
||||||
|
//IWebDavStoreItemLock lockSystem = new WebDavStoreItemLock();
|
||||||
|
IWebDavStore store = new WebDavDiskStore(Localpath);
|
||||||
|
WebDavServer server = new WebDavServer(store);
|
||||||
|
server.Start(Url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>WebDAVSharp.FileExample</RootNamespace>
|
||||||
|
<AssemblyName>WebDAVSharp.FileExample</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Common.Logging, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Common.Logging.2.2.0\lib\net40\Common.Logging.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Common.Logging.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>packages\Common.Logging.Core.2.2.0\lib\net40\Common.Logging.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.configuration" />
|
||||||
|
<Reference Include="System.Configuration.Install" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.ServiceProcess" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Framework\ConsoleHarness.cs" />
|
||||||
|
<Compile Include="Framework\IWindowsService.cs" />
|
||||||
|
<Compile Include="Framework\TypeExtensions.cs" />
|
||||||
|
<Compile Include="Framework\WindowsServiceAttribute.cs" />
|
||||||
|
<Compile Include="Framework\WindowsServiceHarness.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Framework\WindowsServiceHarness.Designer.cs">
|
||||||
|
<DependentUpon>WindowsServiceHarness.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Framework\WindowsServiceInstaller.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Framework\WindowsServiceInstaller.Designer.cs">
|
||||||
|
<DependentUpon>WindowsServiceInstaller.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ServiceImplementation.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WebDAVSharp.Server-master\WebDAVSharp.Server.csproj">
|
||||||
|
<Project>{be8a04dd-c704-40b2-8ad2-3655b429fae1}</Project>
|
||||||
|
<Name>WebDAVSharp.Server</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25123.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDAVSharp.FileExample", "WebDAVSharp.FileExample.csproj", "{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDAVSharp.Server", "..\WebDAVSharp.Server\WebDAVSharp.Server.csproj", "{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
ReleaseBinaries|Any CPU = ReleaseBinaries|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}.ReleaseBinaries|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7A312385-A2F0-4C71-9B7D-A22AB0AA7A00}.ReleaseBinaries|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.ReleaseBinaries|Any CPU.ActiveCfg = ReleaseBinaries|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.ReleaseBinaries|Any CPU.Build.0 = ReleaseBinaries|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Common.Logging" version="2.2.0" targetFramework="net452" />
|
||||||
|
<package id="Common.Logging.Core" version="3.2.0" targetFramework="net452" />
|
||||||
|
</packages>
|
|
@ -0,0 +1,112 @@
|
||||||
|
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# mstest test results
|
||||||
|
TestResults
|
||||||
|
|
||||||
|
# GhostDoc
|
||||||
|
*.sln.GhostDoc.xml
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
packages
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
[Bb]in
|
||||||
|
[Oo]bj
|
||||||
|
sql
|
||||||
|
TestResults
|
||||||
|
[Tt]est[Rr]esult*
|
||||||
|
*.Cache
|
||||||
|
ClientBin
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*.dbmdl
|
||||||
|
Generated_Code #added for RIA/Silverlight projects
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
*.db
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "WebDAVSharp.Server"]
|
||||||
|
path = WebDAVSharp.Server
|
||||||
|
url = https://github.com/WebDAVSharp/WebDAVSharp.Server.git
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<solution>
|
||||||
|
<add key="disableSourceControlIntegration" value="true" />
|
||||||
|
</solution>
|
||||||
|
</configuration>
|
Binary file not shown.
|
@ -0,0 +1,151 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||||
|
|
||||||
|
<!-- Enable the restore command to run before builds -->
|
||||||
|
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||||
|
|
||||||
|
<!-- Property that enables building a package from a project -->
|
||||||
|
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||||
|
|
||||||
|
<!-- Determines if package restore consent is required to restore packages -->
|
||||||
|
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||||
|
|
||||||
|
<!-- Download NuGet.exe if it does not already exist -->
|
||||||
|
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||||
|
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
|
||||||
|
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
|
||||||
|
<!--
|
||||||
|
<PackageSource Include="https://www.nuget.org/api/v2/" />
|
||||||
|
<PackageSource Include="https://my-nuget-source/nuget/" />
|
||||||
|
-->
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||||
|
<!-- Windows specific commands -->
|
||||||
|
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||||
|
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||||
|
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesProjectConfig>packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Choose>
|
||||||
|
<When Condition="Exists('$(PackagesProjectConfig)')">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesConfig>$(PackagesProjectConfig)</PackagesConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<When Condition="Exists('packages.config')">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesConfig>packages.config</PackagesConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
</Choose>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- NuGet command -->
|
||||||
|
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||||
|
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||||
|
|
||||||
|
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||||
|
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
|
||||||
|
|
||||||
|
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
|
||||||
|
|
||||||
|
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||||
|
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||||
|
|
||||||
|
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
|
||||||
|
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
|
||||||
|
|
||||||
|
<!-- Commands -->
|
||||||
|
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||||
|
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||||
|
|
||||||
|
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||||
|
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||||
|
RestorePackages;
|
||||||
|
$(BuildDependsOn);
|
||||||
|
</BuildDependsOn>
|
||||||
|
|
||||||
|
<!-- Make the build depend on restore packages -->
|
||||||
|
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||||
|
$(BuildDependsOn);
|
||||||
|
BuildPackage;
|
||||||
|
</BuildDependsOn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="CheckPrerequisites">
|
||||||
|
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||||
|
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||||
|
<!--
|
||||||
|
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||||
|
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||||
|
parallel builds will have to wait for it to complete.
|
||||||
|
-->
|
||||||
|
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_DownloadNuGet">
|
||||||
|
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||||
|
<Exec Command="$(RestoreCommand)"
|
||||||
|
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||||
|
|
||||||
|
<Exec Command="$(RestoreCommand)"
|
||||||
|
LogStandardErrorAsError="true"
|
||||||
|
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||||
|
<Exec Command="$(BuildCommand)"
|
||||||
|
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||||
|
|
||||||
|
<Exec Command="$(BuildCommand)"
|
||||||
|
LogStandardErrorAsError="true"
|
||||||
|
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||||
|
<ParameterGroup>
|
||||||
|
<OutputFilename ParameterType="System.String" Required="true" />
|
||||||
|
</ParameterGroup>
|
||||||
|
<Task>
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Using Namespace="System" />
|
||||||
|
<Using Namespace="System.IO" />
|
||||||
|
<Using Namespace="System.Net" />
|
||||||
|
<Using Namespace="Microsoft.Build.Framework" />
|
||||||
|
<Using Namespace="Microsoft.Build.Utilities" />
|
||||||
|
<Code Type="Fragment" Language="cs">
|
||||||
|
<![CDATA[
|
||||||
|
try {
|
||||||
|
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||||
|
|
||||||
|
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||||
|
WebClient webClient = new WebClient();
|
||||||
|
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Log.LogErrorFromException(ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</Code>
|
||||||
|
</Task>
|
||||||
|
</UsingTask>
|
||||||
|
</Project>
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("WebDAVTests")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("WebDAVTests")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("3849d2e8-4a04-452d-9df2-8c46dac06e05")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,14 @@
|
||||||
|
Tests
|
||||||
|
=====
|
||||||
|
|
||||||
|
These tests are developed in the .NET Framework 4.5 for the [WebDAV server of WebDAV#][1].
|
||||||
|
|
||||||
|
## Developed by ##
|
||||||
|
|
||||||
|
This version of WebDAV# has been developed by [Lieven Janssen][2] and [Ewout Merckx][3] at [Xplore+][4].
|
||||||
|
|
||||||
|
|
||||||
|
[1]: https://github.com/WebDAVSharp/WebDAVSharp.Server
|
||||||
|
[2]: https://www.linkedin.com/in/lievenjanssen/
|
||||||
|
[3]: https://www.linkedin.com/in/ewoutmerckx
|
||||||
|
[4]: http://xploreplus.com/
|
|
@ -0,0 +1,113 @@
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
|
||||||
|
namespace WebDAVTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests if the exceptions have the right statuscodes
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class UnitTestExceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavConflictException" /> has the statuscode 409 Conflict.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_Conflict_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavConflictException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.Conflict, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavForbiddenException" /> has the statuscode 403 Forbidden.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_Forbidden_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavForbiddenException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.Forbidden, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavInternalServerException" /> has the statuscode 500 Internal Server Error.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_InternalServer_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavInternalServerException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.InternalServerError, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavLengthRequiredException" /> has the statuscode 411 Length Required.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_LengthRequired_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavLengthRequiredException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.LengthRequired, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavMethodNotAllowedException" /> has the statuscode 405 Method Not Allowed.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_MethodNotAllowed_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavMethodNotAllowedException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.MethodNotAllowed, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavNotFoundException" /> has the statuscode 404 Not Found.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_NotFound_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavNotFoundException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.NotFound, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavNotImplementedException" /> has the statuscode 501 Not Implemented.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_NotImplemented_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavNotImplementedException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.NotImplemented, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavPreconditionFailedException" /> has the statuscode 412 Precondition Failed.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_PreconditionFailed_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavPreconditionFailedException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.PreconditionFailed, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavUnauthorizedException" /> has the statuscode 401 Unauthorized.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_Unauthorized_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavUnauthorizedException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.Unauthorized, exception.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the <see cref="WebDavUnsupportedMediaTypeException" /> has the statuscode 415 Unsupported Media Type.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void Exception_UnsupportedMediaType_Test()
|
||||||
|
{
|
||||||
|
var exception = new WebDavUnsupportedMediaTypeException();
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.UnsupportedMediaType, exception.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,125 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using WebDAVSharp.Server;
|
||||||
|
using WebDAVTests.Utilities;
|
||||||
|
|
||||||
|
namespace WebDAVTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to check the time it takes for making and deleting 100 collections
|
||||||
|
/// and for putting and deleting 1000 files
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class UnitTestSpeed
|
||||||
|
{
|
||||||
|
private WebDavServer _server;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The first method to be executed.
|
||||||
|
/// This will start the WebDAV _server.
|
||||||
|
/// </summary>
|
||||||
|
[TestInitialize]
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_server = WebDav.StartWebDavServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test where 100 folders are created and deleted afterwards.
|
||||||
|
/// Methods: Propfind, MkCol, Delete.
|
||||||
|
/// The time needed for this test is show in the Test Explorer.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void SpeedTest_MkColAndDelete100Folders()
|
||||||
|
{
|
||||||
|
HttpWebResponse httpWebResponse = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
// create uri to file or folder
|
||||||
|
var uri = new Uri(WebDavConfig.WebDavTestBaseUri, Path.GetRandomFileName());
|
||||||
|
|
||||||
|
// search for the file or folder
|
||||||
|
var response = WebDavMethod.Propfind(uri.ToString(), "0");
|
||||||
|
httpWebResponse = response as HttpWebResponse;
|
||||||
|
|
||||||
|
// if there is a file or folder at the URI, create it
|
||||||
|
if (httpWebResponse != null && (int)httpWebResponse.StatusCode != (int)WebDavStatusCode.MultiStatus)
|
||||||
|
{
|
||||||
|
WebDavMethod.MkCol(uri.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the response for deleting the folder
|
||||||
|
response = WebDavMethod.Delete(uri.ToString());
|
||||||
|
httpWebResponse = response as HttpWebResponse;
|
||||||
|
|
||||||
|
// if response is null, fail the _test
|
||||||
|
if (httpWebResponse == null)
|
||||||
|
{
|
||||||
|
Assert.Fail("The HttpWebResponse equals null.");
|
||||||
|
}
|
||||||
|
else if ((int)HttpStatusCode.OK != (int)httpWebResponse.StatusCode)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpWebResponse == null)
|
||||||
|
{
|
||||||
|
Assert.Fail("The HttpWebResponse equals null.");
|
||||||
|
}
|
||||||
|
// check the result
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.OK, (int)httpWebResponse.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test where 1000 files are created and deleted afterwards.
|
||||||
|
/// Methods: Propfind, Put, Delete.
|
||||||
|
/// The time needed for this test is show in the Test Explorer.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void SpeedTest_PutAndDelete1000Files()
|
||||||
|
{
|
||||||
|
HttpWebResponse httpWebResponse = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
// create uri to file or folder
|
||||||
|
var uri = new Uri(WebDavConfig.WebDavTestBaseUri, Path.GetRandomFileName());
|
||||||
|
|
||||||
|
// search for the file or folder
|
||||||
|
var response = WebDavMethod.Propfind(uri.ToString(), "0");
|
||||||
|
httpWebResponse = response as HttpWebResponse;
|
||||||
|
|
||||||
|
// if there is a file or folder at the URI, create it
|
||||||
|
if (httpWebResponse != null && (int)httpWebResponse.StatusCode != (int)WebDavStatusCode.MultiStatus)
|
||||||
|
{
|
||||||
|
WebDavMethod.Put(uri.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the response for deleting the folder
|
||||||
|
response = WebDavMethod.Delete(uri.ToString());
|
||||||
|
httpWebResponse = response as HttpWebResponse;
|
||||||
|
|
||||||
|
// if response is null, fail the _test
|
||||||
|
if (httpWebResponse == null)
|
||||||
|
{
|
||||||
|
Assert.Fail("The HttpWebResponse equals null.");
|
||||||
|
}
|
||||||
|
else if ((int)HttpStatusCode.OK != (int)httpWebResponse.StatusCode)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (httpWebResponse == null)
|
||||||
|
{
|
||||||
|
Assert.Fail("The HttpWebResponse equals null.");
|
||||||
|
}
|
||||||
|
// check the result
|
||||||
|
Assert.AreEqual((int)HttpStatusCode.OK, (int)httpWebResponse.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
namespace WebDAVTests.Utilities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains the values of status codes defined for Http (WebDav).
|
||||||
|
/// </summary>
|
||||||
|
public enum WebDavStatusCode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to Http status 207 (WebDav).
|
||||||
|
/// WebDAVSharp.Server.Utilities.WebDavStatusCode.MultiStatus provides status for multiple independent operations.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For more information, see <see href="http://www.webdav.org/specs/rfc2518.html#STATUS_207" />.
|
||||||
|
/// </remarks>
|
||||||
|
MultiStatus = 207,
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to Http status 422 (WebDav).
|
||||||
|
/// WebDAVSharp.Server.Utilities.WebDavStatusCode.UnprocessableEntity means the server understands the content type of the request entity (hence a 415 (<see cref="System.Net.HttpStatusCode.UnsupportedMediaType"/>) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (<see cref="System.Net.HttpStatusCode.BadRequest"/>) status code is inappropriate) but was unable to process the contained instructions.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For more information, see <see href="http://www.webdav.org/specs/rfc2518.html#STATUS_422"/>.
|
||||||
|
/// </remarks>
|
||||||
|
UnprocessableEntity = 422,
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to Http status 423 (WebDav).
|
||||||
|
/// WebDAVSharp.Server.Utilities.WebDavStatusCode.Locked means the source or destination resource of a method is locked.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For more information, see <see href="http://www.webdav.org/specs/rfc2518.html#STATUS_423"/>.
|
||||||
|
/// </remarks>
|
||||||
|
Locked = 423,
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to Http status 424 (WebDav).
|
||||||
|
/// WebDAVSharp.Server.Utilities.WebDavStatusCode.FailedDependency means that the method could not be performed on the resource because the requested action depended on another action and that action failed.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For more information, see <see href="http://www.webdav.org/specs/rfc2518.html#STATUS_424"/>.
|
||||||
|
/// </remarks>
|
||||||
|
FailedDependency = 424,
|
||||||
|
/// <summary>
|
||||||
|
/// Equivalent to Http status 507 (WebDav).
|
||||||
|
/// WebDAVSharp.Server.Utilities.WebDavStatusCode.InsufficientStorage means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For more information, see <see href="http://www.webdav.org/specs/rfc2518.html#STATUS_507" />.
|
||||||
|
/// </remarks>
|
||||||
|
InsufficientStorage = 507,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{DE145971-1D80-4CC1-8338-0DF2FE24A207}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>WebDAVTests</RootNamespace>
|
||||||
|
<AssemblyName>WebDAVTests</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||||
|
<IsCodedUITest>False</IsCodedUITest>
|
||||||
|
<TestProjectType>UnitTest</TestProjectType>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||||
|
<RestorePackages>true</RestorePackages>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Choose>
|
||||||
|
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||||
|
</ItemGroup>
|
||||||
|
</When>
|
||||||
|
<Otherwise>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Otherwise>
|
||||||
|
</Choose>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="UnitTestExceptions.cs" />
|
||||||
|
<Compile Include="UnitTestSpeed.cs" />
|
||||||
|
<Compile Include="UnitTestMethods.cs" />
|
||||||
|
<Compile Include="WebDav.cs" />
|
||||||
|
<Compile Include="WebDavConfig.cs" />
|
||||||
|
<Compile Include="WebDavMethod.cs" />
|
||||||
|
<Compile Include="Utilities\WebDavStatusCode.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="WebDAVSharp.Server\WebDAVSharp.Server.csproj">
|
||||||
|
<Project>{be8a04dd-c704-40b2-8ad2-3655b429fae1}</Project>
|
||||||
|
<Name>WebDAVSharp.Server</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Choose>
|
||||||
|
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
</When>
|
||||||
|
</Choose>
|
||||||
|
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25123.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDAVSharp.Tests", "WebDAVSharp.Tests.csproj", "{DE145971-1D80-4CC1-8338-0DF2FE24A207}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDAVSharp.Server", "..\WebDAVSharp.Server\WebDAVSharp.Server.csproj", "{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
ReleaseBinaries|Any CPU = ReleaseBinaries|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{DE145971-1D80-4CC1-8338-0DF2FE24A207}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DE145971-1D80-4CC1-8338-0DF2FE24A207}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DE145971-1D80-4CC1-8338-0DF2FE24A207}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DE145971-1D80-4CC1-8338-0DF2FE24A207}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DE145971-1D80-4CC1-8338-0DF2FE24A207}.ReleaseBinaries|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DE145971-1D80-4CC1-8338-0DF2FE24A207}.ReleaseBinaries|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.ReleaseBinaries|Any CPU.ActiveCfg = ReleaseBinaries|Any CPU
|
||||||
|
{BE8A04DD-C704-40B2-8AD2-3655B429FAE1}.ReleaseBinaries|Any CPU.Build.0 = ReleaseBinaries|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,126 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using WebDAVSharp.Server;
|
||||||
|
using WebDAVSharp.Server.Stores.DiskStore;
|
||||||
|
|
||||||
|
namespace WebDAVTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The basics for talking to the WebDAV server
|
||||||
|
/// </summary>
|
||||||
|
internal static class WebDav
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the WebDAV server.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="WebDavServer"/></returns>
|
||||||
|
internal static WebDavServer StartWebDavServer()
|
||||||
|
{
|
||||||
|
var server = new WebDavServer(new WebDavDiskStore(WebDavConfig.WebDavLocalPath));
|
||||||
|
server.Start(WebDavConfig.WebDavUri.ToString());
|
||||||
|
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the credentials of the user
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The request URI</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The credentials as an instance of <see cref="CredentialCache" />
|
||||||
|
/// </returns>
|
||||||
|
internal static CredentialCache WebDavCredentialCache(string requestUri)
|
||||||
|
{
|
||||||
|
var myCredentialCache = new CredentialCache
|
||||||
|
{
|
||||||
|
{
|
||||||
|
new Uri(requestUri),
|
||||||
|
"Negotiate",
|
||||||
|
new NetworkCredential(WebDavConfig.UserName, WebDavConfig.Password, WebDavConfig.Domain)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return myCredentialCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a basic WebDav Request
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The requested URI as an <see cref="Uri" /></param>
|
||||||
|
/// <param name="method">The <see cref="string" /> defining the WebDAV method to be used</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The basic WebDav Request as an <see cref="HttpWebRequest" />
|
||||||
|
/// </returns>
|
||||||
|
internal static HttpWebRequest WebDavRequestBase(string requestUri, string method)
|
||||||
|
{
|
||||||
|
// Create the HttpWebRequest object.
|
||||||
|
var request = (HttpWebRequest)WebRequest.Create(requestUri);
|
||||||
|
|
||||||
|
request.UserAgent = "WebDAV-UnitTestProject/1.0.0";
|
||||||
|
|
||||||
|
// Add the network credentials to the request.
|
||||||
|
request.UseDefaultCredentials = true;
|
||||||
|
|
||||||
|
// Specify the WebDAV method.
|
||||||
|
request.Method = method;
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the response of the given <see cref="HttpWebRequest" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="HttpWebRequest" /></param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="WebResponse" /> of the <see cref="HttpWebRequest" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse WebDavResponse(HttpWebRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Send the WebDav method request, get the
|
||||||
|
// method response from the server.
|
||||||
|
WebResponse response = request.GetResponse();
|
||||||
|
Stream stream = response.GetResponseStream();
|
||||||
|
Encoding encode = Encoding.GetEncoding("utf-8");
|
||||||
|
|
||||||
|
// Pipes the stream to a higher level stream reader with the required encoding format.
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
var readStream = new StreamReader(stream, encode);
|
||||||
|
var read = new Char[256];
|
||||||
|
String str = "";
|
||||||
|
// Reads 256 characters at a time.
|
||||||
|
int count = readStream.Read(read, 0, 256);
|
||||||
|
while (count > 0)
|
||||||
|
{
|
||||||
|
// Dumps the 256 characters on a string and displays the string to the console.
|
||||||
|
str += new String(read, 0, count);
|
||||||
|
count = readStream.Read(read, 0, 256);
|
||||||
|
}
|
||||||
|
// Releases the resources of the Stream.
|
||||||
|
readStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the HttpWebResponse object.
|
||||||
|
response.Close();
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
catch (WebException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return ex.Response;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Catch any exceptions. Any error codes from the WebDAV
|
||||||
|
// method request on the server will be caught here, also.
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace WebDAVTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The parameters for the configuration must be defined here
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavConfig
|
||||||
|
{
|
||||||
|
internal static readonly string WebDavLocalPath = "c:/";
|
||||||
|
internal static readonly Uri WebDavUri = new Uri("http://localhost:8880/");
|
||||||
|
internal static readonly Uri WebDavTestBaseUri = new Uri(WebDavUri, "your_folder/");
|
||||||
|
internal static readonly string UserName = "your_username";
|
||||||
|
internal static readonly string Password = "your_password";
|
||||||
|
internal static readonly string Domain = "your_domain";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,241 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Cache;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVTests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The WebDAV methods to use are defined in this class
|
||||||
|
/// </summary>
|
||||||
|
internal static class WebDavMethod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Propfind method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="depth">The <see cref="string" /> for the Depth header</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Propfind(string requestUri, string depth = "", string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "PROPFIND");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
request.Headers.Add("Depth", depth);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV MkCol method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse MkCol(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "MKCOL");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Delete method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Delete(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "DELETE");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Put method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Put(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "PUT");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Copy method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="destinationUri">The <see cref="string" /> for the Destination header</param>
|
||||||
|
/// <param name="overwrite">The <see cref="bool" /> for the Overwrite header</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Copy(string requestUri, string destinationUri, bool overwrite = false)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "COPY");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.Headers.Add("Destination", destinationUri);
|
||||||
|
request.Headers.Add("Overwrite", overwrite ? "T" : "F");
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Move method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="destinationUri">The <see cref="string" /> for the Destination header</param>
|
||||||
|
/// <param name="overwrite">The <see cref="bool" /> for the Overwrite header</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Move(string requestUri, string destinationUri, bool overwrite = false)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "MOVE");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.Headers.Add("Destination", destinationUri);
|
||||||
|
request.Headers.Add("Overwrite", overwrite ? "T" : "F");
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Lock method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Lock(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "LOCK");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
request.ContentType = "text/xml; charset=\"utf-8\"";
|
||||||
|
request.Timeout = 3600;
|
||||||
|
|
||||||
|
request.Headers.Add("Depth", "0"); //can also be infinity
|
||||||
|
request.Headers.Add("Pragma", "no-cache");
|
||||||
|
|
||||||
|
// send content
|
||||||
|
var encoding = new UTF8Encoding();
|
||||||
|
byte[] byte1 = encoding.GetBytes(content);
|
||||||
|
Stream newStream = request.GetRequestStream();
|
||||||
|
newStream.Write(byte1, 0, byte1.Length);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Unlock method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Unlock(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "UNLOCK");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Options method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Options(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "OPTIONS");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Head method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Head(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "HEAD");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Proppatch method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <param name="content">The <see cref="string" /> of the body content</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Proppatch(string requestUri, string content = "")
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "PROPPATCH");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
request.ContentLength = content.Length;
|
||||||
|
request.ContentType = "text/xml; charset=\"utf-8\"";
|
||||||
|
|
||||||
|
// send content
|
||||||
|
var encoding = new UTF8Encoding();
|
||||||
|
byte[] byte1 = encoding.GetBytes(content);
|
||||||
|
Stream newStream = request.GetRequestStream();
|
||||||
|
newStream.Write(byte1, 0, byte1.Length);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute a WebDAV Get method on the requested URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestUri">The <see cref="Uri" /> for the request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The response as a <see cref="WebResponse" />
|
||||||
|
/// </returns>
|
||||||
|
internal static WebResponse Get(string requestUri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = WebDav.WebDavRequestBase(requestUri, "GET");
|
||||||
|
request.Credentials = WebDav.WebDavCredentialCache(requestUri);
|
||||||
|
|
||||||
|
return WebDav.WebDavResponse(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,109 @@
|
||||||
|
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# mstest test results
|
||||||
|
TestResults
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
packages
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
[Bb]in
|
||||||
|
[Oo]bj
|
||||||
|
sql
|
||||||
|
TestResults
|
||||||
|
[Tt]est[Rr]esult*
|
||||||
|
*.Cache
|
||||||
|
ClientBin
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*.dbmdl
|
||||||
|
Generated_Code #added for RIA/Silverlight projects
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
*.db
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<solution>
|
||||||
|
<add key="disableSourceControlIntegration" value="true" />
|
||||||
|
</solution>
|
||||||
|
</configuration>
|
Binary file not shown.
|
@ -0,0 +1,151 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||||
|
|
||||||
|
<!-- Enable the restore command to run before builds -->
|
||||||
|
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||||
|
|
||||||
|
<!-- Property that enables building a package from a project -->
|
||||||
|
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||||
|
|
||||||
|
<!-- Determines if package restore consent is required to restore packages -->
|
||||||
|
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||||
|
|
||||||
|
<!-- Download NuGet.exe if it does not already exist -->
|
||||||
|
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||||
|
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
|
||||||
|
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
|
||||||
|
<!--
|
||||||
|
<PackageSource Include="https://www.nuget.org/api/v2/" />
|
||||||
|
<PackageSource Include="https://my-nuget-source/nuget/" />
|
||||||
|
-->
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||||
|
<!-- Windows specific commands -->
|
||||||
|
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||||
|
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||||
|
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesProjectConfig>packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Choose>
|
||||||
|
<When Condition="Exists('$(PackagesProjectConfig)')">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesConfig>$(PackagesProjectConfig)</PackagesConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
<When Condition="Exists('packages.config')">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackagesConfig>packages.config</PackagesConfig>
|
||||||
|
</PropertyGroup>
|
||||||
|
</When>
|
||||||
|
</Choose>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- NuGet command -->
|
||||||
|
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||||
|
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||||
|
|
||||||
|
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||||
|
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
|
||||||
|
|
||||||
|
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
|
||||||
|
|
||||||
|
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||||
|
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||||
|
|
||||||
|
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
|
||||||
|
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
|
||||||
|
|
||||||
|
<!-- Commands -->
|
||||||
|
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||||
|
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||||
|
|
||||||
|
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||||
|
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||||
|
RestorePackages;
|
||||||
|
$(BuildDependsOn);
|
||||||
|
</BuildDependsOn>
|
||||||
|
|
||||||
|
<!-- Make the build depend on restore packages -->
|
||||||
|
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||||
|
$(BuildDependsOn);
|
||||||
|
BuildPackage;
|
||||||
|
</BuildDependsOn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="CheckPrerequisites">
|
||||||
|
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||||
|
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||||
|
<!--
|
||||||
|
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||||
|
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||||
|
parallel builds will have to wait for it to complete.
|
||||||
|
-->
|
||||||
|
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="_DownloadNuGet">
|
||||||
|
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||||
|
<Exec Command="$(RestoreCommand)"
|
||||||
|
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||||
|
|
||||||
|
<Exec Command="$(RestoreCommand)"
|
||||||
|
LogStandardErrorAsError="true"
|
||||||
|
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||||
|
<Exec Command="$(BuildCommand)"
|
||||||
|
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||||
|
|
||||||
|
<Exec Command="$(BuildCommand)"
|
||||||
|
LogStandardErrorAsError="true"
|
||||||
|
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||||
|
<ParameterGroup>
|
||||||
|
<OutputFilename ParameterType="System.String" Required="true" />
|
||||||
|
</ParameterGroup>
|
||||||
|
<Task>
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Using Namespace="System" />
|
||||||
|
<Using Namespace="System.IO" />
|
||||||
|
<Using Namespace="System.Net" />
|
||||||
|
<Using Namespace="Microsoft.Build.Framework" />
|
||||||
|
<Using Namespace="Microsoft.Build.Utilities" />
|
||||||
|
<Code Type="Fragment" Language="cs">
|
||||||
|
<![CDATA[
|
||||||
|
try {
|
||||||
|
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||||
|
|
||||||
|
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||||
|
WebClient webClient = new WebClient();
|
||||||
|
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Log.LogErrorFromException(ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</Code>
|
||||||
|
</Task>
|
||||||
|
</UsingTask>
|
||||||
|
</Project>
|
|
@ -0,0 +1,111 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This
|
||||||
|
/// <see cref="IHttpListener" /> implementation wraps around a
|
||||||
|
/// <see cref="HttpListener" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HttpListenerAdapter : WebDavDisposableBase, IHttpListener, IAdapter<HttpListener>
|
||||||
|
{
|
||||||
|
private readonly HttpListener _listener;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="HttpListenerAdapter" /> class.
|
||||||
|
/// </summary>
|
||||||
|
internal HttpListenerAdapter()
|
||||||
|
{
|
||||||
|
_listener = new HttpListener
|
||||||
|
{
|
||||||
|
AuthenticationSchemes = AuthenticationSchemes.Ntlm,
|
||||||
|
UnsafeConnectionNtlmAuthentication = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases unmanaged and - optionally - managed resources
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (_listener.IsListening)
|
||||||
|
_listener.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Waits for a request to come in to the web server and returns a
|
||||||
|
/// <see cref="IHttpListenerContext" /> adapter around it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="abortEvent">A
|
||||||
|
/// <see cref="EventWaitHandle" /> to use for aborting the wait. If this
|
||||||
|
/// event becomes set before a request comes in, this method will return
|
||||||
|
/// <c>null</c>.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A
|
||||||
|
/// <see cref="IHttpListenerContext" /> adapter object for a request;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if the wait for a request was aborted due to
|
||||||
|
/// <paramref name="abortEvent" /> being set.
|
||||||
|
/// </returns>
|
||||||
|
/// <exception cref="System.ArgumentNullException">abortEvent</exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="abortEvent" /> is <c>null</c>.</exception>
|
||||||
|
public IHttpListenerContext GetContext(EventWaitHandle abortEvent)
|
||||||
|
{
|
||||||
|
if (abortEvent == null)
|
||||||
|
throw new ArgumentNullException("abortEvent");
|
||||||
|
|
||||||
|
IAsyncResult ar = _listener.BeginGetContext(null, null);
|
||||||
|
int index = WaitHandle.WaitAny(new[] {abortEvent, ar.AsyncWaitHandle});
|
||||||
|
if (index != 1) return null;
|
||||||
|
HttpListenerContext context = _listener.EndGetContext(ar);
|
||||||
|
return new HttpListenerContextAdapter(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the internal instance that was adapted for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The adapted instance.
|
||||||
|
/// </value>
|
||||||
|
public HttpListener AdaptedInstance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Uniform Resource Identifier (
|
||||||
|
/// <see cref="Uri" />) prefixes handled by the
|
||||||
|
/// adapted
|
||||||
|
/// <see cref="HttpListener" /> object.
|
||||||
|
/// </summary>
|
||||||
|
public HttpListenerPrefixCollection Prefixes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _listener.Prefixes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows the adapted <see cref="HttpListener" /> to receive incoming requests.
|
||||||
|
/// </summary>
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
_listener.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Causes the adapted <see cref="HttpListener" /> to stop receiving incoming requests.
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
_listener.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This
|
||||||
|
/// <see cref="IHttpListenerContext" /> implementation wraps around a
|
||||||
|
/// <see cref="HttpListenerContext" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HttpListenerContextAdapter : IHttpListenerContext, IAdapter<HttpListenerContext>
|
||||||
|
{
|
||||||
|
private readonly HttpListenerContext _context;
|
||||||
|
private readonly HttpListenerRequestAdapter _request;
|
||||||
|
private readonly HttpListenerResponseAdapter _response;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="HttpListenerContextAdapter" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The <see cref="HttpListenerContext" /> to adapt for WebDAV#.</param>
|
||||||
|
/// <exception cref="System.ArgumentNullException">context</exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="context" /> is <c>null</c>.</exception>
|
||||||
|
public HttpListenerContextAdapter(HttpListenerContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
throw new ArgumentNullException("context");
|
||||||
|
|
||||||
|
_context = context;
|
||||||
|
_request = new HttpListenerRequestAdapter(context.Request);
|
||||||
|
_response = new HttpListenerResponseAdapter(context.Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the internal instance that was adapted for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The adapted instance.
|
||||||
|
/// </value>
|
||||||
|
public HttpListenerContext AdaptedInstance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="IHttpListenerRequest" /> request adapter.
|
||||||
|
/// </summary>
|
||||||
|
public IHttpListenerRequest Request
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="IHttpListenerResponse" /> response adapter.
|
||||||
|
/// </summary>
|
||||||
|
public IHttpListenerResponse Response
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This
|
||||||
|
/// <see cref="IHttpListenerRequest" /> implementation wraps around a
|
||||||
|
/// <see cref="HttpListenerRequest" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HttpListenerRequestAdapter : IHttpListenerRequest
|
||||||
|
{
|
||||||
|
private readonly HttpListenerRequest _request;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="HttpListenerRequestAdapter" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="HttpListenerRequest" /> to adapt for WebDAV#.</param>
|
||||||
|
/// <exception cref="System.ArgumentNullException">request</exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="request" /> is <c>null</c>.</exception>
|
||||||
|
public HttpListenerRequestAdapter(HttpListenerRequest request)
|
||||||
|
{
|
||||||
|
if (request == null)
|
||||||
|
throw new ArgumentNullException("request");
|
||||||
|
|
||||||
|
_request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the internal instance that was adapted for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The adapted instance.
|
||||||
|
/// </value>
|
||||||
|
public HttpListenerRequest AdaptedInstance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the client IP address and port number from which the request originated.
|
||||||
|
/// </summary>
|
||||||
|
public IPEndPoint RemoteEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.RemoteEndPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="Uri" /> object requested by the client.
|
||||||
|
/// </summary>
|
||||||
|
public Uri Url
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.Url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the HTTP method specified by the client.
|
||||||
|
/// </summary>
|
||||||
|
public string HttpMethod
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.HttpMethod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of header name/value pairs sent in the request.
|
||||||
|
/// </summary>
|
||||||
|
public NameValueCollection Headers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.Headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Stream" /> that contains the body data sent by the client.
|
||||||
|
/// </summary>
|
||||||
|
public Stream InputStream
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.InputStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the content <see cref="Encoding" /> that can be used with data sent with the request.
|
||||||
|
/// </summary>
|
||||||
|
public Encoding ContentEncoding
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.ContentEncoding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the length of the body data included in the request.
|
||||||
|
/// </summary>
|
||||||
|
public long ContentLength64
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _request.ContentLength64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This
|
||||||
|
/// <see cref="IHttpListenerResponse" /> implementation wraps around a
|
||||||
|
/// <see cref="HttpListenerResponse" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HttpListenerResponseAdapter : IHttpListenerResponse
|
||||||
|
{
|
||||||
|
private readonly HttpListenerResponse _response;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="HttpListenerResponseAdapter" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Response">The <see cref="HttpListenerResponse" /> to adapt for WebDAV#.</param>
|
||||||
|
/// <exception cref="System.ArgumentNullException">Response</exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="Response" /> is <c>null</c>.</exception>
|
||||||
|
public HttpListenerResponseAdapter(HttpListenerResponse Response)
|
||||||
|
{
|
||||||
|
if (Response == null)
|
||||||
|
throw new ArgumentNullException("Response");
|
||||||
|
|
||||||
|
_response = Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the internal instance that was adapted for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The adapted instance.
|
||||||
|
/// </value>
|
||||||
|
public HttpListenerResponse AdaptedInstance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTP status code to be returned to the client.
|
||||||
|
/// </summary>
|
||||||
|
public int StatusCode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response.StatusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_response.StatusCode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a text description of the HTTP <see cref="StatusCode">status code</see> returned to the client.
|
||||||
|
/// </summary>
|
||||||
|
public string StatusDescription
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response.StatusDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_response.StatusDescription = value ?? string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Stream" /> object to which a response can be written.
|
||||||
|
/// </summary>
|
||||||
|
public Stream OutputStream
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response.OutputStream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="Encoding" /> for this response's <see cref="OutputStream" />.
|
||||||
|
/// </summary>
|
||||||
|
public Encoding ContentEncoding
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response.ContentEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_response.ContentEncoding = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of bytes in the body data included in the response.
|
||||||
|
/// </summary>
|
||||||
|
public long ContentLength64
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _response.ContentLength64;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_response.ContentLength64 = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the response to the client and releases the resources held by the adapted
|
||||||
|
/// <see cref="HttpListenerResponse" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
_response.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends a value to the specified HTTP header to be sent with the response.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the HTTP header to append the <paramref name="value" /> to.</param>
|
||||||
|
/// <param name="value">The value to append to the <paramref name="name" /> header.</param>
|
||||||
|
public void AppendHeader(string name, string value)
|
||||||
|
{
|
||||||
|
_response.AppendHeader(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This interface is implemented by other adapters in the WebDAV#
|
||||||
|
/// project, to facilitate access to the underlying adapted object.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of internal instance that is adapted.</typeparam>
|
||||||
|
public interface IAdapter<out T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the internal instance that was adapted for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The adapted instance.
|
||||||
|
/// </value>
|
||||||
|
T AdaptedInstance
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is an interface-version of the parts of
|
||||||
|
/// <see cref="HttpListener" /> that
|
||||||
|
/// the
|
||||||
|
/// <see cref="WebDavServer" /> requires to operator.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The main purpose of this interface is to facilitate unit-testing.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IHttpListener : IAdapter<HttpListener>, IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Waits for a request to come in to the web server and returns a
|
||||||
|
/// <see cref="IHttpListenerContext" /> adapter around it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="abortEvent">A
|
||||||
|
/// <see cref="EventWaitHandle" /> to use for aborting the wait. If this
|
||||||
|
/// event becomes set before a request comes in, this method will return
|
||||||
|
/// <c>null</c>.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A
|
||||||
|
/// <see cref="IHttpListenerContext" /> adapter object for a request;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if the wait for a request was aborted due to
|
||||||
|
/// <paramref name="abortEvent" /> being set.
|
||||||
|
/// </returns>
|
||||||
|
IHttpListenerContext GetContext(EventWaitHandle abortEvent);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Uniform Resource Identifier (
|
||||||
|
/// <see cref="Uri" />) prefixes handled by the
|
||||||
|
/// adapted
|
||||||
|
/// <see cref="HttpListener" /> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The prefixes.
|
||||||
|
/// </value>
|
||||||
|
HttpListenerPrefixCollection Prefixes
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows the adapted <see cref="HttpListener" /> to receive incoming requests.
|
||||||
|
/// </summary>
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Causes the adapted <see cref="HttpListener" /> to stop receiving incoming requests.
|
||||||
|
/// </summary>
|
||||||
|
void Stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is an interface-version of the parts of
|
||||||
|
/// <see cref="HttpListenerContext" /> that
|
||||||
|
/// the
|
||||||
|
/// <see cref="WebDavServer" /> requires to operator.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The main purpose of this interface is to facilitate unit-testing.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IHttpListenerContext : IAdapter<HttpListenerContext>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="IHttpListenerRequest" /> request adapter.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The request.
|
||||||
|
/// </value>
|
||||||
|
IHttpListenerRequest Request
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="IHttpListenerResponse" /> response adapter.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The response.
|
||||||
|
/// </value>
|
||||||
|
IHttpListenerResponse Response
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is an interface-version of the parts of
|
||||||
|
/// <see cref="HttpListenerRequest" /> that
|
||||||
|
/// the
|
||||||
|
/// <see cref="WebDavServer" /> requires to operator.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The main purpose of this interface is to facilitate unit-testing.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IHttpListenerRequest : IAdapter<HttpListenerRequest>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the client IP address and port number from which the request originated.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The remote end point.
|
||||||
|
/// </value>
|
||||||
|
IPEndPoint RemoteEndPoint
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="Uri" /> object requested by the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The URL.
|
||||||
|
/// </value>
|
||||||
|
Uri Url
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the HTTP method specified by the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The HTTP method.
|
||||||
|
/// </value>
|
||||||
|
string HttpMethod
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of header name/value pairs sent in the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The headers.
|
||||||
|
/// </value>
|
||||||
|
NameValueCollection Headers
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Stream" /> that contains the body data sent by the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The input stream.
|
||||||
|
/// </value>
|
||||||
|
Stream InputStream
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the content <see cref="Encoding" /> that can be used with data sent with the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The content encoding.
|
||||||
|
/// </value>
|
||||||
|
Encoding ContentEncoding
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the length of the body data included in the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The content length64.
|
||||||
|
/// </value>
|
||||||
|
long ContentLength64
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Adapters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is an interface-version of the parts of
|
||||||
|
/// <see cref="HttpListenerResponse" /> that
|
||||||
|
/// the
|
||||||
|
/// <see cref="WebDavServer" /> requires to operator.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The main purpose of this interface is to facilitate unit-testing.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IHttpListenerResponse : IAdapter<HttpListenerResponse>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTP status code to be returned to the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The status code.
|
||||||
|
/// </value>
|
||||||
|
int StatusCode
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a text description of the HTTP <see cref="StatusCode">status code</see> returned to the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The status description.
|
||||||
|
/// </value>
|
||||||
|
string StatusDescription
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Stream" /> object to which a response can be written.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The output stream.
|
||||||
|
/// </value>
|
||||||
|
Stream OutputStream
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the <see cref="Encoding" /> for this response's <see cref="OutputStream" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The content encoding.
|
||||||
|
/// </value>
|
||||||
|
Encoding ContentEncoding
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of bytes in the body data included in the response.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The content length64.
|
||||||
|
/// </value>
|
||||||
|
long ContentLength64
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the response to the client and releases the resources held by the adapted
|
||||||
|
/// <see cref="HttpListenerResponse" /> instance.
|
||||||
|
/// </summary>
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends a value to the specified HTTP header to be sent with the response.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the HTTP header to append the <paramref name="value" /> to.</param>
|
||||||
|
/// <param name="value">The value to append to the <paramref name="name" /> header.</param>
|
||||||
|
void AppendHeader(string name, string value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,397 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature">
|
||||||
|
<Class Name="WebDAVSharp.Server.Adapters.HttpListenerAdapter">
|
||||||
|
<Position X="22.5" Y="25.25" Width="4.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAACASAgAAAAAAAAAAAAAAAAAAICAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Adapters\HttpListenerAdapter.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Adapters.HttpListenerContextAdapter" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="92.5" Y="0.5" Width="2.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAABQBCAAQAAAAAAAAAAAgAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Adapters\HttpListenerContextAdapter.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Adapters.HttpListenerRequestAdapter" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="94.25" Y="0.5" Width="2.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAQAAAAQIAAAAAACABAAAAACAEAAAAAECA=</HashCode>
|
||||||
|
<FileName>Adapters\HttpListenerRequestAdapter.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Adapters.HttpListenerResponseAdapter" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="96" Y="0.5" Width="2.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAgAAAAAQACAAAAAAEAAAAABAABAAIAAAAACAACA=</HashCode>
|
||||||
|
<FileName>Adapters\HttpListenerResponseAdapter.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavConflictException">
|
||||||
|
<Position X="9.75" Y="13" Width="5.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavConflictException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavException">
|
||||||
|
<Position X="32.25" Y="8.5" Width="6.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>ACAAAgAAAAAAAAAAAAACAAggAAAAAAAAIAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavForbiddenException">
|
||||||
|
<Position X="29.25" Y="13" Width="5.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavForbiddenException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavInternalServerException">
|
||||||
|
<Position X="42.5" Y="13" Width="5.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavInternalServerException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavLengthRequiredException">
|
||||||
|
<Position X="49" Y="13" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavLengthRequiredException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavMethodNotAllowedException">
|
||||||
|
<Position X="55.75" Y="13" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavMethodNotAllowedException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavNotFoundException">
|
||||||
|
<Position X="62.5" Y="13" Width="5.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavNotFoundException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavNotImplementedException">
|
||||||
|
<Position X="3" Y="13" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavNotImplementedException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavPreconditionFailedException">
|
||||||
|
<Position X="16" Y="13" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavPreconditionFailedException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavUnauthorizedException">
|
||||||
|
<Position X="22.75" Y="13" Width="5.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavUnauthorizedException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Exceptions.WebDavUnsupportedMediaTypeException">
|
||||||
|
<Position X="35.5" Y="13" Width="6.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Exceptions\WebDavUnsupportedMediaTypeException.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.LockProperty" Collapsed="true">
|
||||||
|
<Position X="97.75" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAACAAACAAAEAAAAAAAAAAAAAAAIkAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>LockProperty.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.WebDavDisposableBase">
|
||||||
|
<Position X="28" Y="22.5" Width="2.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAACAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAA=</HashCode>
|
||||||
|
<FileName>WebDavDisposableBase.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.WebDavExtensions" Collapsed="true">
|
||||||
|
<Position X="96" Y="1.5" Width="1.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAEAAAAAAAAIAAAAAAAgAAAAAAAAABAA=</HashCode>
|
||||||
|
<FileName>WebDavExtensions.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.WebDavProperty" Collapsed="true">
|
||||||
|
<Position X="92.5" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAIAAAAAAAAAEAAAAAAQAAgAAIAAAAABgAABAAAA=</HashCode>
|
||||||
|
<FileName>WebDavProperty.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.WebDavServer">
|
||||||
|
<Position X="27.5" Y="25.25" Width="8.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAARAAAACACAkAAABABAEAIAAAAAACAIACAAQBAIAA=</HashCode>
|
||||||
|
<FileName>WebDavServer.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavCopyMethodHandler">
|
||||||
|
<Position X="11" Y="3.75" Width="7.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAEAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavCopyMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavDeleteMethodHandler">
|
||||||
|
<Position X="28" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavDeleteMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavGetMethodHandler">
|
||||||
|
<Position X="41.5" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavGetMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavHeadMethodHandler">
|
||||||
|
<Position X="58.5" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavHeadMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavLockMethodHandler">
|
||||||
|
<Position X="72" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavLockMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavMethodHandlerBase">
|
||||||
|
<Position X="44.5" Y="0.5" Width="6.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAEAgAAAQAAAACQAAAAAAAAACAAAAAAIAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavMethodHandlerBase.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavMethodHandlers" Collapsed="true">
|
||||||
|
<Position X="97.75" Y="1.5" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAgAAAAAAAAAAAAAAAAACAAAAAAAAAAAIAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavMethodHandlers.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavMkColMethodHandler">
|
||||||
|
<Position X="4.25" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavMkColMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavMoveMethodHandler">
|
||||||
|
<Position X="19" Y="3.75" Width="8.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAABAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavMoveMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavOptionsMethodHandler">
|
||||||
|
<Position X="34.75" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavOptionsMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavPropfindMethodHandler">
|
||||||
|
<Position X="48.25" Y="3.75" Width="9.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>oAAAgDAIAAAAAEAAAhAAAgAAEAAEAAAABgAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavPropfindMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavProppatchMethodHandler">
|
||||||
|
<Position X="65.25" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavProppatchMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavPutMethodHandler">
|
||||||
|
<Position X="78.75" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavPutMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.MethodHandlers.WebDavUnlockMethodHandler">
|
||||||
|
<Position X="85.5" Y="3.75" Width="6" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\WebDavUnlockMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.BaseClasses.WebDavStoreBase" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="94.25" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAQACAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Stores\BaseClasses\WebDavStoreBase.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.BaseClasses.WebDavStoreDocumentBase">
|
||||||
|
<Position X="0.75" Y="20" Width="5.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Stores\BaseClasses\WebDavStoreDocumentBase.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.BaseClasses.WebDavStoreItemBase">
|
||||||
|
<Position X="8" Y="15.5" Width="5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>QAACIAAAAAAAAAAAgEAAAAQAAAAIQCAAAAAAAAAEAEA=</HashCode>
|
||||||
|
<FileName>Stores\BaseClasses\WebDavStoreItemBase.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.DiskStore.WebDavDiskStore" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="94.25" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAIAAAgA=</HashCode>
|
||||||
|
<FileName>Stores\DiskStore\WebDavDiskStore.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.DiskStore.WebDavDiskStoreCollection">
|
||||||
|
<Position X="7" Y="24.5" Width="6.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>QgAAAAAAAAQASAAAAQAAAAAAABMAAAAAAAgAAAAIAAA=</HashCode>
|
||||||
|
<FileName>Stores\DiskStore\WebDavDiskStoreCollection.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.DiskStore.WebDavDiskStoreDocument">
|
||||||
|
<Position X="14.5" Y="24.5" Width="5.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>EAAAAAAAAAAAgAQAAAQAAAAAAAAQAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Stores\DiskStore\WebDavDiskStoreDocument.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Stores.DiskStore.WebDavDiskStoreItem">
|
||||||
|
<Position X="11" Y="20" Width="5.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>QAAAAAAAAAACAAAAgAAAAAQAAAgIACAAAEAAAAAEAEA=</HashCode>
|
||||||
|
<FileName>Stores\DiskStore\WebDavDiskStoreItem.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="WebDAVSharp.Server.Utilities.Md5Util" Collapsed="true">
|
||||||
|
<Position X="92.5" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAIAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Utilities\Md5Util.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Adapters.IAdapter<T>">
|
||||||
|
<Position X="7.25" Y="6.5" Width="2.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Adapters\IAdapter.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Adapters.IHttpListener">
|
||||||
|
<Position X="4.5" Y="8.25" Width="4.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAACAAAgAAAAAAAAAAAAAAAAAAICAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Adapters\IHttpListener.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Adapters.IHttpListenerContext">
|
||||||
|
<Position X="9.5" Y="8.25" Width="3" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAABAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Adapters\IHttpListenerContext.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Adapters.IHttpListenerRequest">
|
||||||
|
<Position X="13.25" Y="8.25" Width="2.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAIAAAAAACABAAAAACAEAAAAAECA=</HashCode>
|
||||||
|
<FileName>Adapters\IHttpListenerRequest.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Adapters.IHttpListenerResponse">
|
||||||
|
<Position X="0.5" Y="8.25" Width="3.25" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAgAAAAAAAAAAAAAAEAAAAABAABAAIAAAAACAACA=</HashCode>
|
||||||
|
<FileName>Adapters\IHttpListenerResponse.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.MethodHandlers.IWebDavMethodHandler" Collapsed="true">
|
||||||
|
<Position X="92.5" Y="3.75" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>MethodHandlers\IWebDavMethodHandler.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Stores.IWebDavStore" Collapsed="true">
|
||||||
|
<Position X="94.25" Y="3.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Stores\IWebDavStore.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Stores.IWebDavStoreCollection">
|
||||||
|
<Position X="18.25" Y="18.5" Width="6.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AgAAAAAAAAAASAAAAQAAAAAAAAMAAAAAAAAAAAAIAAA=</HashCode>
|
||||||
|
<FileName>Stores\IWebDavStoreCollection.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Stores.IWebDavStoreDocument">
|
||||||
|
<Position X="25.75" Y="18.5" Width="3" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>EAAAAAAAAAAAgAQAAAQAAAAAAAAQAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Stores\IWebDavStoreDocument.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="WebDAVSharp.Server.Stores.IWebDavStoreItem">
|
||||||
|
<Position X="21.75" Y="15.5" Width="3.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>QAAAAAAAAAAAAAAAgEAAAAQAAAAIAAAAAAAAAAAEAEA=</HashCode>
|
||||||
|
<FileName>Stores\IWebDavStoreItem.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Enum Name="WebDAVSharp.Server.Utilities.WebDavStatusCode" Collapsed="true">
|
||||||
|
<Position X="92.5" Y="4.75" Width="1.75" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<HashCode>AAAAAAAgAAQAAAAEAAAAAAAAAAAAACAAABAAAAAAAAA=</HashCode>
|
||||||
|
<FileName>Utilities\WebDavStatusCode.cs</FileName>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Font Name="Segoe UI" Size="9" />
|
||||||
|
</ClassDiagram>
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when a request cannot be completed due to a conflict with the requested
|
||||||
|
/// resource.
|
||||||
|
/// Statuscode: 409 Conflict.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavConflictException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavConflictException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavConflictException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.Conflict, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception, or a descendant, is thrown when requests fail, specifying the status code
|
||||||
|
/// that the server should return back to the client.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavException : HttpException
|
||||||
|
{
|
||||||
|
private const string StatusCodeKey = "StatusCode";
|
||||||
|
private const string StatusDescriptionKey = "StatusDescription";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
public WebDavException()
|
||||||
|
: this(HttpStatusCode.InternalServerError)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
public WebDavException(string message)
|
||||||
|
: this(HttpStatusCode.InternalServerError, message)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavException(string message, Exception innerException)
|
||||||
|
: this(HttpStatusCode.InternalServerError, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||||
|
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||||
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="info" /> parameter is null.</exception>
|
||||||
|
/// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult" /> is zero (0).</exception>
|
||||||
|
protected WebDavException(SerializationInfo info, StreamingContext context)
|
||||||
|
: base(info, context)
|
||||||
|
{
|
||||||
|
StatusCode = info.GetInt32(StatusCodeKey);
|
||||||
|
StatusDescription = info.GetString(StatusDescriptionKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="statusCode">The HTTP status code that this <see cref="WebDavException" /> maps to.</param>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavException(HttpStatusCode statusCode, string message = null, Exception innerException = null)
|
||||||
|
: base(GetMessage(statusCode, message), innerException)
|
||||||
|
{
|
||||||
|
StatusCode = (int)statusCode;
|
||||||
|
StatusDescription = HttpWorkerRequest.GetStatusDescription((int)statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the HTTP status code that this <see cref="WebDavException" /> maps to.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The status code.
|
||||||
|
/// </value>
|
||||||
|
public int StatusCode
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the status description for the HTTP <see cref="StatusCode" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The status description.
|
||||||
|
/// </value>
|
||||||
|
public string StatusDescription
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with information about the exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
|
||||||
|
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
|
||||||
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="info" /> parameter is a null reference (Nothing in Visual Basic).</exception>
|
||||||
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
|
||||||
|
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||||
|
{
|
||||||
|
base.GetObjectData(info, context);
|
||||||
|
info.AddValue(StatusCodeKey, StatusCode);
|
||||||
|
info.AddValue(StatusDescriptionKey, StatusDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="statusCode">The status code.</param>
|
||||||
|
/// <param name="message">The message.</param>
|
||||||
|
/// <returns>The message and the status description.</returns>
|
||||||
|
private static string GetMessage(HttpStatusCode statusCode, string message)
|
||||||
|
{
|
||||||
|
string format = "%s";
|
||||||
|
if (!String.IsNullOrWhiteSpace(message))
|
||||||
|
format = message;
|
||||||
|
|
||||||
|
return format.Replace("%s", HttpWorkerRequest.GetStatusDescription((int)statusCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Statuscode: 403 Forbidden.
|
||||||
|
/// </summary>
|
||||||
|
public class WebDavForbiddenException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavForbiddenException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavForbiddenException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.Forbidden, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when the server throws a different exception than the standard
|
||||||
|
/// ones that
|
||||||
|
/// <see cref="WebDavServer" /> knows how to respond to.
|
||||||
|
/// Statuscode: 500 Internal Server Error.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavInternalServerException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavInternalServerException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavInternalServerException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.InternalServerError, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Statuscode: 411 Length Required.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavLengthRequiredException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavLengthRequiredException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavLengthRequiredException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.LengthRequired, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when a request uses a HTTP method to request or manipulate a resource
|
||||||
|
/// for which the specified HTTP method is not allowed.
|
||||||
|
/// Statuscode: 405 Method Not Allowed.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavMethodNotAllowedException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavMethodNotAllowedException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavMethodNotAllowedException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.MethodNotAllowed, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when a request tries to access a resource that does not exist.
|
||||||
|
/// Statuscode: 404 Not Found.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavNotFoundException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavNotFoundException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavNotFoundException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.NotFound, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when a request uses a HTTP method or functionality that has yet to
|
||||||
|
/// be implemented.
|
||||||
|
/// Statuscode: 501 Not Implemented.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavNotImplementedException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavNotImplementedException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavNotImplementedException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.NotImplemented, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when one of the preconditions failed.
|
||||||
|
/// Statuscode: 412 Precondition Failed.
|
||||||
|
/// </summary>
|
||||||
|
public class WebDavPreconditionFailedException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavPreconditionFailedException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavPreconditionFailedException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.PreconditionFailed, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when the user is not authorized to execute the request.
|
||||||
|
/// Statuscode: 401 Unauthorized.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavUnauthorizedException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavNotFoundException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavUnauthorizedException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.Unauthorized, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This exception is thrown when the media type is unsupported.
|
||||||
|
/// Statuscode: 415 Unsupported Media Type
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class WebDavUnsupportedMediaTypeException : WebDavException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavUnsupportedMediaTypeException" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The exception message stating the reason for the exception being thrown.</param>
|
||||||
|
/// <param name="innerException">The
|
||||||
|
/// <see cref="Exception" /> that is the cause for this exception;
|
||||||
|
/// or
|
||||||
|
/// <c>null</c> if no inner exception is specified.</param>
|
||||||
|
public WebDavUnsupportedMediaTypeException(string message = null, Exception innerException = null)
|
||||||
|
: base(HttpStatusCode.UnsupportedMediaType, message, innerException)
|
||||||
|
{
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,49 @@
|
||||||
|
namespace WebDAVSharp.Server
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The property with all the information of a lock
|
||||||
|
/// </summary>
|
||||||
|
internal class LockProperty
|
||||||
|
{
|
||||||
|
public string Locktype { get; set; }
|
||||||
|
public string Lockscope { get; set; }
|
||||||
|
public string Depth { get; set; }
|
||||||
|
public string Owner { get; set; }
|
||||||
|
public string Timeout { get; set; }
|
||||||
|
public string Locktoken { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The standard constructor
|
||||||
|
/// </summary>
|
||||||
|
public LockProperty()
|
||||||
|
{
|
||||||
|
Locktype = string.Empty;
|
||||||
|
Lockscope = string.Empty;
|
||||||
|
Depth = string.Empty;
|
||||||
|
Owner = string.Empty;
|
||||||
|
Timeout = string.Empty;
|
||||||
|
Locktoken = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The constructor with all the specific values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="locktype">The locktype of the lock</param>
|
||||||
|
/// <param name="lockscope">The lockscope of the lock</param>
|
||||||
|
/// <param name="depth">The depth of the lock</param>
|
||||||
|
/// <param name="owner">The owner of the lock</param>
|
||||||
|
/// <param name="timeout">The timeout of the lock</param>
|
||||||
|
/// <param name="locktoken">The locktoken.</param>
|
||||||
|
public LockProperty(string locktype, string lockscope, string depth, string owner, string timeout, string locktoken)
|
||||||
|
{
|
||||||
|
Locktype = locktype;
|
||||||
|
Lockscope = lockscope;
|
||||||
|
Depth = depth;
|
||||||
|
Owner = owner;
|
||||||
|
Timeout = timeout;
|
||||||
|
Locktoken = locktoken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This interface must be implemented by a class that will respond
|
||||||
|
/// to requests from a client by handling specific HTTP methods.
|
||||||
|
/// </summary>
|
||||||
|
public interface IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>COPY</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavCopyMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"COPY"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavMethodNotAllowedException"></exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
IWebDavStoreItem source = context.Request.Url.GetItem(server, store);
|
||||||
|
if (source is IWebDavStoreDocument || source is IWebDavStoreCollection)
|
||||||
|
CopyItem(server, context, store, source);
|
||||||
|
else
|
||||||
|
throw new WebDavMethodNotAllowedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies the item.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The server.</param>
|
||||||
|
/// <param name="context">The context.</param>
|
||||||
|
/// <param name="store">The store.</param>
|
||||||
|
/// <param name="source">The source.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavForbiddenException"></exception>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavPreconditionFailedException"></exception>
|
||||||
|
private static void CopyItem(WebDavServer server, IHttpListenerContext context, IWebDavStore store,
|
||||||
|
IWebDavStoreItem source)
|
||||||
|
{
|
||||||
|
Uri destinationUri = GetDestinationHeader(context.Request);
|
||||||
|
IWebDavStoreCollection destinationParentCollection = GetParentCollection(server, store, destinationUri);
|
||||||
|
|
||||||
|
bool copyContent = (GetDepthHeader(context.Request) != 0);
|
||||||
|
bool isNew = true;
|
||||||
|
|
||||||
|
string destinationName = Uri.UnescapeDataString(destinationUri.Segments.Last().TrimEnd('/', '\\'));
|
||||||
|
IWebDavStoreItem destination = destinationParentCollection.GetItemByName(destinationName);
|
||||||
|
|
||||||
|
if (destination != null)
|
||||||
|
{
|
||||||
|
if (source.ItemPath == destination.ItemPath)
|
||||||
|
throw new WebDavForbiddenException();
|
||||||
|
if (!GetOverwriteHeader(context.Request))
|
||||||
|
throw new WebDavPreconditionFailedException();
|
||||||
|
if (destination is IWebDavStoreCollection)
|
||||||
|
destinationParentCollection.Delete(destination);
|
||||||
|
isNew = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
destinationParentCollection.CopyItemHere(source, destinationName, copyContent);
|
||||||
|
|
||||||
|
context.SendSimpleResponse(isNew ? HttpStatusCode.Created : HttpStatusCode.NoContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>DELETE</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavDeleteMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"DELETE"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
// Get the parent collection of the item
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
// Get the item from the collection
|
||||||
|
IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url);
|
||||||
|
|
||||||
|
// Deletes the item
|
||||||
|
collection.Delete(item);
|
||||||
|
context.SendSimpleResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>GET</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class WebDavGetMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the verbs handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"GET"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavNotFoundException"></exception>
|
||||||
|
/// <exception cref="WebDavNotFoundException"><para>
|
||||||
|
/// <paramref name="context" /> specifies a request for a store item that does not exist.</para>
|
||||||
|
/// <para>- or -</para>
|
||||||
|
/// <para>
|
||||||
|
/// <paramref name="context" /> specifies a request for a store item that is not a document.</para></exception>
|
||||||
|
/// <exception cref="WebDavConflictException"><paramref name="context" /> specifies a request for a store item using a collection path that does not exist.</exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url);
|
||||||
|
IWebDavStoreDocument doc = item as IWebDavStoreDocument;
|
||||||
|
if (doc == null)
|
||||||
|
throw new WebDavNotFoundException();
|
||||||
|
|
||||||
|
long docSize = doc.Size;
|
||||||
|
if (docSize == 0)
|
||||||
|
{
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
context.Response.ContentLength64 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (Stream stream = doc.OpenReadStream())
|
||||||
|
{
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
|
||||||
|
if (docSize > 0)
|
||||||
|
context.Response.ContentLength64 = docSize;
|
||||||
|
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int inBuffer;
|
||||||
|
while ((inBuffer = stream.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
context.Response.OutputStream.Write(buffer, 0, inBuffer);
|
||||||
|
}
|
||||||
|
context.Response.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>PROPFIND</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavHeadMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"HEAD"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDavNotFoundException"><para>
|
||||||
|
/// <paramref name="context" /> specifies a request for a store item that does not exist.</para>
|
||||||
|
/// <para>- or -</para>
|
||||||
|
/// <para>
|
||||||
|
/// <paramref name="context" /> specifies a request for a store item that is not a document.</para></exception>
|
||||||
|
/// <exception cref="WebDavConflictException"><paramref name="context" /> specifies a request for a store item using a collection path that does not exist.</exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
// Get the parent collection of the item
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
// Get the item from the collection
|
||||||
|
IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url);
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Send the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// HttpStatusCode doesn't contain WebDav status codes, but HttpWorkerRequest can handle these WebDav status codes
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
context.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription((int)HttpStatusCode.OK);
|
||||||
|
|
||||||
|
// set the headers of the response
|
||||||
|
context.Response.ContentLength64 = 0;
|
||||||
|
context.Response.AppendHeader("Content-Type", "text/html");
|
||||||
|
context.Response.AppendHeader("Last-Modified", item.ModificationDate.ToUniversalTime().ToString("R"));
|
||||||
|
|
||||||
|
context.Response.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,191 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Xml;
|
||||||
|
using Common.Logging;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>LOCK</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavLockMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"LOCK"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavPreconditionFailedException"></exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
ILog log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Retreive al the information from the request
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// read the headers
|
||||||
|
int depth = GetDepthHeader(context.Request);
|
||||||
|
string timeout = GetTimeoutHeader(context.Request);
|
||||||
|
|
||||||
|
// Initiate the XmlNamespaceManager and the XmlNodes
|
||||||
|
XmlNamespaceManager manager = null;
|
||||||
|
XmlNode lockscopeNode = null, locktypeNode = null, ownerNode = null;
|
||||||
|
|
||||||
|
// try to read the body
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.UTF8);
|
||||||
|
string requestBody = reader.ReadToEnd();
|
||||||
|
|
||||||
|
if (!requestBody.Equals("") && requestBody.Length != 0)
|
||||||
|
{
|
||||||
|
XmlDocument requestDocument = new XmlDocument();
|
||||||
|
requestDocument.LoadXml(requestBody);
|
||||||
|
|
||||||
|
if (requestDocument.DocumentElement != null && requestDocument.DocumentElement.LocalName != "prop" &&
|
||||||
|
requestDocument.DocumentElement.LocalName != "lockinfo")
|
||||||
|
{
|
||||||
|
log.Debug("LOCK method without prop or lockinfo element in xml document");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = new XmlNamespaceManager(requestDocument.NameTable);
|
||||||
|
manager.AddNamespace("D", "DAV:");
|
||||||
|
manager.AddNamespace("Office", "schemas-microsoft-com:office:office");
|
||||||
|
manager.AddNamespace("Repl", "http://schemas.microsoft.com/repl/");
|
||||||
|
manager.AddNamespace("Z", "urn:schemas-microsoft-com:");
|
||||||
|
|
||||||
|
// Get the lockscope, locktype and owner as XmlNodes from the XML document
|
||||||
|
lockscopeNode = requestDocument.DocumentElement.SelectSingleNode("D:lockscope", manager);
|
||||||
|
locktypeNode = requestDocument.DocumentElement.SelectSingleNode("D:locktype", manager);
|
||||||
|
ownerNode = requestDocument.DocumentElement.SelectSingleNode("D:owner", manager);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new WebDavPreconditionFailedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Warn(ex.Message);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Lock the file or folder
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
bool isNew = false;
|
||||||
|
|
||||||
|
// Get the parent collection of the item
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get the item from the collection
|
||||||
|
IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
collection.CreateDocument(context.Request.Url.Segments.Last().TrimEnd('/', '\\'));
|
||||||
|
isNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Create the body for the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// Create the basic response XmlDocument
|
||||||
|
XmlDocument responseDoc = new XmlDocument();
|
||||||
|
string responseXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:prop " +
|
||||||
|
"xmlns:D=\"DAV:\"><D:lockdiscovery><D:activelock/></D:lockdiscovery></D:prop>";
|
||||||
|
responseDoc.LoadXml(responseXml);
|
||||||
|
|
||||||
|
// Select the activelock XmlNode
|
||||||
|
XmlNode activelock = responseDoc.DocumentElement.SelectSingleNode("D:lockdiscovery/D:activelock", manager);
|
||||||
|
|
||||||
|
// Import the given nodes
|
||||||
|
activelock.AppendChild(responseDoc.ImportNode(lockscopeNode, true));
|
||||||
|
activelock.AppendChild(responseDoc.ImportNode(locktypeNode, true));
|
||||||
|
activelock.AppendChild(responseDoc.ImportNode(ownerNode, true));
|
||||||
|
|
||||||
|
// Add the additional elements, e.g. the header elements
|
||||||
|
|
||||||
|
// The timeout element
|
||||||
|
WebDavProperty timeoutProperty = new WebDavProperty("timeout", timeout);
|
||||||
|
activelock.AppendChild(timeoutProperty.ToXmlElement(responseDoc));
|
||||||
|
|
||||||
|
// The depth element
|
||||||
|
WebDavProperty depthProperty = new WebDavProperty("depth", (depth == 0 ? "0" : "Infinity"));
|
||||||
|
activelock.AppendChild(depthProperty.ToXmlElement(responseDoc));
|
||||||
|
|
||||||
|
// The locktoken element
|
||||||
|
WebDavProperty locktokenProperty = new WebDavProperty("locktoken", "");
|
||||||
|
XmlElement locktokenElement = locktokenProperty.ToXmlElement(responseDoc);
|
||||||
|
WebDavProperty hrefProperty = new WebDavProperty("href", "opaquelocktoken:e71d4fae-5dec-22df-fea5-00a0c93bd5eb1");
|
||||||
|
locktokenElement.AppendChild(hrefProperty.ToXmlElement(responseDoc));
|
||||||
|
activelock.AppendChild(locktokenElement);
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Send the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// convert the StringBuilder
|
||||||
|
string resp = responseDoc.InnerXml;
|
||||||
|
byte[] responseBytes = Encoding.UTF8.GetBytes(resp);
|
||||||
|
|
||||||
|
if (isNew)
|
||||||
|
{
|
||||||
|
// HttpStatusCode doesn't contain WebDav status codes, but HttpWorkerRequest can handle these WebDav status codes
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.Created;
|
||||||
|
context.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription((int)HttpStatusCode.Created);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// HttpStatusCode doesn't contain WebDav status codes, but HttpWorkerRequest can handle these WebDav status codes
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
context.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription((int)HttpStatusCode.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set the headers of the response
|
||||||
|
context.Response.ContentLength64 = responseBytes.Length;
|
||||||
|
context.Response.AdaptedInstance.ContentType = "text/xml";
|
||||||
|
|
||||||
|
// the body
|
||||||
|
context.Response.OutputStream.Write(responseBytes, 0, responseBytes.Length);
|
||||||
|
|
||||||
|
context.Response.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is the base class for <see cref="IWebDavMethodHandler" /> implementations.
|
||||||
|
/// </summary>
|
||||||
|
internal abstract class WebDavMethodHandlerBase
|
||||||
|
{
|
||||||
|
private const int DepthInfinity = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the parent collection from the requested
|
||||||
|
/// <see cref="Uri" />.
|
||||||
|
/// <see cref="WebDavException" /> 409 Conflict possible.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <param name="childUri">The <see cref="Uri" /> object containing the specific location of the child</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The parrent collection as an <see cref="IWebDavStoreCollection" />
|
||||||
|
/// </returns>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavUnauthorizedException"></exception>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavConflictException">
|
||||||
|
/// </exception>
|
||||||
|
/// <exception cref="WebDavUnauthorizedException">When the user is unauthorized and doesn't have access</exception>
|
||||||
|
/// <exception cref="WebDavConflictException">When the parent collection doesn't exist</exception>
|
||||||
|
public static IWebDavStoreCollection GetParentCollection(WebDavServer server, IWebDavStore store, Uri childUri)
|
||||||
|
{
|
||||||
|
Uri parentCollectionUri = childUri.GetParentUri();
|
||||||
|
IWebDavStoreCollection collection;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
collection = parentCollectionUri.GetItem(server, store) as IWebDavStoreCollection;
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
throw new WebDavUnauthorizedException();
|
||||||
|
}
|
||||||
|
catch(WebDavNotFoundException)
|
||||||
|
{
|
||||||
|
throw new WebDavConflictException();
|
||||||
|
}
|
||||||
|
if (collection == null)
|
||||||
|
throw new WebDavConflictException();
|
||||||
|
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the item in the collection from the requested
|
||||||
|
/// <see cref="Uri" />.
|
||||||
|
/// <see cref="WebDavException" /> 409 Conflict possible.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collection">The parent collection as a <see cref="IWebDavStoreCollection" /></param>
|
||||||
|
/// <param name="childUri">The <see cref="Uri" /> object containing the specific location of the child</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="IWebDavStoreItem" /> from the <see cref="IWebDavStoreCollection" />
|
||||||
|
/// </returns>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavUnauthorizedException">If user is not authorized to get access to the item</exception>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavNotFoundException">If item not found.</exception>
|
||||||
|
public static IWebDavStoreItem GetItemFromCollection(IWebDavStoreCollection collection, Uri childUri)
|
||||||
|
{
|
||||||
|
IWebDavStoreItem item;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item = collection.GetItemByName(Uri.UnescapeDataString(childUri.Segments.Last().TrimEnd('/', '\\')));
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
throw new WebDavUnauthorizedException();
|
||||||
|
}
|
||||||
|
catch (WebDavNotFoundException)
|
||||||
|
{
|
||||||
|
throw new WebDavNotFoundException();
|
||||||
|
}
|
||||||
|
if (item == null)
|
||||||
|
throw new WebDavNotFoundException();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Depth header : 0, 1 or infinity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="IHttpListenerContext" /> with the response included</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The values 0, 1 or -1 (for infinity)
|
||||||
|
/// </returns>
|
||||||
|
public static int GetDepthHeader(IHttpListenerRequest request)
|
||||||
|
{
|
||||||
|
// get the value of the depth header as a string
|
||||||
|
string depth = request.Headers["Depth"];
|
||||||
|
|
||||||
|
// check if the string is valid or not infinity
|
||||||
|
// if so, try to parse it to an int
|
||||||
|
if (String.IsNullOrEmpty(depth) || depth.Equals("infinity"))
|
||||||
|
return DepthInfinity;
|
||||||
|
int value;
|
||||||
|
if (!int.TryParse(depth, out value))
|
||||||
|
return DepthInfinity;
|
||||||
|
if (value == 0 || value == 1)
|
||||||
|
return value;
|
||||||
|
// else, return the infinity value
|
||||||
|
return DepthInfinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Overwrite header : T or F
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="IHttpListenerRequest"/> has the header included</param>
|
||||||
|
/// <returns>The <see cref="bool"/> true if overwrite, false if no overwrite</returns>
|
||||||
|
public static bool GetOverwriteHeader(IHttpListenerRequest request)
|
||||||
|
{
|
||||||
|
// get the value of the Overwrite header as a string
|
||||||
|
string overwrite = request.Headers["Overwrite"];
|
||||||
|
|
||||||
|
// check if the string is valid and if it equals T
|
||||||
|
return overwrite != null && overwrite.Equals("T");
|
||||||
|
// else, return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Timeout header : Second-number
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request with the request included</param>
|
||||||
|
/// <returns>The value of the Timeout header as a string</returns>
|
||||||
|
public static string GetTimeoutHeader(IHttpListenerRequest request)
|
||||||
|
{
|
||||||
|
// get the value of the timeout header as a string
|
||||||
|
string timeout = request.Headers["Timeout"];
|
||||||
|
|
||||||
|
// check if the string is valid or not infinity
|
||||||
|
// if so, try to parse it to an int
|
||||||
|
if (!String.IsNullOrEmpty(timeout) && !timeout.Equals("infinity") &&
|
||||||
|
!timeout.Equals("Infinite, Second-4100000000"))
|
||||||
|
return timeout;
|
||||||
|
// else, return the timeout value as if it was requested to be 4 days
|
||||||
|
return "Second-345600";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Destination header as an URI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="IHttpListenerRequest"/> has the header included</param>
|
||||||
|
/// <returns>The <see cref="Uri"/> containing the destination</returns>
|
||||||
|
public static Uri GetDestinationHeader(IHttpListenerRequest request)
|
||||||
|
{
|
||||||
|
// get the value of the Destination header as a string
|
||||||
|
string destinationUri = request.Headers["Destination"];
|
||||||
|
|
||||||
|
// check if the string is valid
|
||||||
|
if (!String.IsNullOrEmpty(destinationUri))
|
||||||
|
return new Uri(destinationUri);
|
||||||
|
// else, throw exception
|
||||||
|
throw new WebDavConflictException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains code to produce the built-in
|
||||||
|
/// <see cref="IWebDavMethodHandler"/> instances known by WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal static class WebDavMethodHandlers
|
||||||
|
{
|
||||||
|
private static readonly List<IWebDavMethodHandler> _BuiltIn = new List<IWebDavMethodHandler>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of built-in <see cref="IWebDavMethodHandler"/>
|
||||||
|
/// HTTP method handler instances.
|
||||||
|
/// </summary>
|
||||||
|
public static IEnumerable<IWebDavMethodHandler> BuiltIn
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_BuiltIn)
|
||||||
|
{
|
||||||
|
if (_BuiltIn.Count == 0)
|
||||||
|
ScanAssemblies();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _BuiltIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scans the WebDAV# assemblies for known <see cref="IWebDavMethodHandler"/>
|
||||||
|
/// types.
|
||||||
|
/// </summary>
|
||||||
|
private static void ScanAssemblies()
|
||||||
|
{
|
||||||
|
IEnumerable<Type> methodHandlerTypes = from type in typeof (WebDavServer).Assembly.GetTypes()
|
||||||
|
where !type.IsAbstract
|
||||||
|
where typeof(IWebDavMethodHandler).IsAssignableFrom(type)
|
||||||
|
select type;
|
||||||
|
|
||||||
|
IEnumerable<IWebDavMethodHandler> methodHandlerInstances =
|
||||||
|
from type in methodHandlerTypes
|
||||||
|
select (IWebDavMethodHandler)Activator.CreateInstance(type);
|
||||||
|
|
||||||
|
_BuiltIn.AddRange(methodHandlerInstances);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>MKCOL</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavMkColMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"MKCOL"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavUnsupportedMediaTypeException"></exception>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavMethodNotAllowedException"></exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
if (context.Request.ContentLength64 > 0)
|
||||||
|
throw new WebDavUnsupportedMediaTypeException();
|
||||||
|
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
string collectionName = Uri.UnescapeDataString(
|
||||||
|
context.Request.Url.Segments.Last().TrimEnd('/', '\\')
|
||||||
|
);
|
||||||
|
if (collection.GetItemByName(collectionName) != null)
|
||||||
|
throw new WebDavMethodNotAllowedException();
|
||||||
|
|
||||||
|
collection.CreateCollection(collectionName);
|
||||||
|
|
||||||
|
context.SendSimpleResponse(HttpStatusCode.Created);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>MOVE</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavMoveMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"MOVE"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
var source = context.Request.Url.GetItem(server, store);
|
||||||
|
|
||||||
|
MoveItem(server, context, store, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Moves the
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <param name="sourceWebDavStoreItem">The <see cref="IWebDavStoreItem" /> that will be moved</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavForbiddenException">If the source path is the same as the destination path</exception>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavPreconditionFailedException">If one of the preconditions failed</exception>
|
||||||
|
private void MoveItem(WebDavServer server, IHttpListenerContext context, IWebDavStore store,
|
||||||
|
IWebDavStoreItem sourceWebDavStoreItem)
|
||||||
|
{
|
||||||
|
Uri destinationUri = GetDestinationHeader(context.Request);
|
||||||
|
IWebDavStoreCollection destinationParentCollection = GetParentCollection(server, store, destinationUri);
|
||||||
|
|
||||||
|
bool isNew = true;
|
||||||
|
|
||||||
|
string destinationName = Uri.UnescapeDataString(destinationUri.Segments.Last().TrimEnd('/', '\\'));
|
||||||
|
IWebDavStoreItem destination = destinationParentCollection.GetItemByName(destinationName);
|
||||||
|
if (destination != null)
|
||||||
|
{
|
||||||
|
if (sourceWebDavStoreItem.ItemPath == destination.ItemPath)
|
||||||
|
throw new WebDavForbiddenException();
|
||||||
|
// if the overwrite header is F, statuscode = precondition failed
|
||||||
|
if (!GetOverwriteHeader(context.Request))
|
||||||
|
throw new WebDavPreconditionFailedException();
|
||||||
|
// else delete destination and set isNew to false
|
||||||
|
destinationParentCollection.Delete(destination);
|
||||||
|
isNew = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
destinationParentCollection.MoveItemHere(sourceWebDavStoreItem, destinationName);
|
||||||
|
|
||||||
|
// send correct response
|
||||||
|
context.SendSimpleResponse(isNew ? HttpStatusCode.Created : HttpStatusCode.NoContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>OPTIONS</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavOptionsMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"OPTIONS"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
List<string> verbsAllowed = new List<string> { "OPTIONS", "TRACE", "GET", "HEAD", "POST", "COPY", "PROPFIND", "LOCK", "UNLOCK" };
|
||||||
|
|
||||||
|
List<string> verbsPublic = new List<string> { "OPTIONS", "GET", "HEAD", "PROPFIND", "PROPPATCH", "MKCOL", "PUT", "DELETE", "COPY", "MOVE", "LOCK", "UNLOCK" };
|
||||||
|
|
||||||
|
foreach (string verb in verbsAllowed)
|
||||||
|
context.Response.AppendHeader("Allow", verb);
|
||||||
|
|
||||||
|
foreach (string verb in verbsPublic)
|
||||||
|
context.Response.AppendHeader("Public", verb);
|
||||||
|
|
||||||
|
// Sends 200 OK
|
||||||
|
context.SendSimpleResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,434 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Xml;
|
||||||
|
using Common.Logging;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
using WebDAVSharp.Server.Utilities;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>PROPFIND</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavPropfindMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
private ILog _log;
|
||||||
|
private Uri _requestUri;
|
||||||
|
private List<WebDavProperty> _requestedProperties;
|
||||||
|
private List<IWebDavStoreItem> _webDavStoreItems;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"PROPFIND"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavUnauthorizedException"></exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Retreive all the information from the request
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// Read the headers, ...
|
||||||
|
bool isPropname = false;
|
||||||
|
int depth = GetDepthHeader(context.Request);
|
||||||
|
_requestUri = GetRequestUri(context.Request.Url.ToString());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_webDavStoreItems = GetWebDavStoreItems(context.Request.Url.GetItem(server, store), depth);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
throw new WebDavUnauthorizedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the XmlDocument from the request
|
||||||
|
XmlDocument requestDoc = GetXmlDocument(context.Request);
|
||||||
|
|
||||||
|
// See what is requested
|
||||||
|
_requestedProperties = new List<WebDavProperty>();
|
||||||
|
if (requestDoc.DocumentElement != null)
|
||||||
|
{
|
||||||
|
if (requestDoc.DocumentElement.LocalName != "propfind")
|
||||||
|
_log.Debug("PROPFIND method without propfind in xml document");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlNode n = requestDoc.DocumentElement.FirstChild;
|
||||||
|
if (n == null)
|
||||||
|
_log.Debug("propfind element without children");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (n.LocalName)
|
||||||
|
{
|
||||||
|
case "allprop":
|
||||||
|
_requestedProperties = GetAllProperties();
|
||||||
|
break;
|
||||||
|
case "propname":
|
||||||
|
isPropname = true;
|
||||||
|
_requestedProperties = GetAllProperties();
|
||||||
|
break;
|
||||||
|
case "prop":
|
||||||
|
foreach (XmlNode child in n.ChildNodes)
|
||||||
|
_requestedProperties.Add(new WebDavProperty(child.LocalName, "", child.NamespaceURI));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_requestedProperties.Add(new WebDavProperty(n.LocalName, "", n.NamespaceURI));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_requestedProperties = GetAllProperties();
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Create the body for the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
XmlDocument responseDoc = ResponseDocument(context, isPropname);
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Send the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
SendResponse(context, responseDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region RetrieveInformation
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the URI to the location
|
||||||
|
/// If no slash at the end of the URI, this method adds one
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri">The <see cref="string" /> that contains the URI</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="Uri" /> that contains the given uri
|
||||||
|
/// </returns>
|
||||||
|
private static Uri GetRequestUri(string uri)
|
||||||
|
{
|
||||||
|
return new Uri(uri.EndsWith("/") ? uri : uri + "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert the given
|
||||||
|
/// <see cref="IWebDavStoreItem" /> to a
|
||||||
|
/// <see cref="List{T}" /> of
|
||||||
|
/// <see cref="IWebDavStoreItem" />
|
||||||
|
/// This list depends on the "Depth" header
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iWebDavStoreItem">The <see cref="IWebDavStoreItem" /> that needs to be converted</param>
|
||||||
|
/// <param name="depth">The "Depth" header</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="List{T}" /> of <see cref="IWebDavStoreItem" />
|
||||||
|
/// </returns>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavConflictException"></exception>
|
||||||
|
private static List<IWebDavStoreItem> GetWebDavStoreItems(IWebDavStoreItem iWebDavStoreItem, int depth)
|
||||||
|
{
|
||||||
|
ILog _log = LogManager.GetCurrentClassLogger();
|
||||||
|
List<IWebDavStoreItem> list = new List<IWebDavStoreItem>();
|
||||||
|
|
||||||
|
//IWebDavStoreCollection
|
||||||
|
// if the item is a collection
|
||||||
|
IWebDavStoreCollection collection = iWebDavStoreItem as IWebDavStoreCollection;
|
||||||
|
if (collection != null)
|
||||||
|
{
|
||||||
|
list.Add(collection);
|
||||||
|
if (depth == 0)
|
||||||
|
return list;
|
||||||
|
foreach (IWebDavStoreItem item in collection.Items)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list.Add(item);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.Debug(ex.Message + "\r\n" + ex.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
// if the item is not a document, throw conflict exception
|
||||||
|
if (!(iWebDavStoreItem is IWebDavStoreDocument))
|
||||||
|
throw new WebDavConflictException();
|
||||||
|
|
||||||
|
// add the item to the list
|
||||||
|
list.Add(iWebDavStoreItem);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads the XML body of the
|
||||||
|
/// <see cref="IHttpListenerRequest" />
|
||||||
|
/// and converts it to an
|
||||||
|
/// <see cref="XmlDocument" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The <see cref="IHttpListenerRequest" /></param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="XmlDocument" /> that contains the request body
|
||||||
|
/// </returns>
|
||||||
|
private XmlDocument GetXmlDocument(IHttpListenerRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StreamReader reader = new StreamReader(request.InputStream, Encoding.UTF8);
|
||||||
|
string requestBody = reader.ReadToEnd();
|
||||||
|
reader.Close();
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(requestBody))
|
||||||
|
{
|
||||||
|
var xmlDocument = new XmlDocument();
|
||||||
|
xmlDocument.LoadXml(requestBody);
|
||||||
|
return xmlDocument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
_log.Warn("XmlDocument has not been read correctly");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new XmlDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the standard properties for an Propfind allprop request to a <see cref="List{T}" /> of <see cref="WebDavProperty" />
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The list with all the <see cref="WebDavProperty" />
|
||||||
|
/// </returns>
|
||||||
|
private List<WebDavProperty> GetAllProperties()
|
||||||
|
{
|
||||||
|
List<WebDavProperty> list = new List<WebDavProperty>
|
||||||
|
{
|
||||||
|
new WebDavProperty("creationdate"),
|
||||||
|
new WebDavProperty("displayname"),
|
||||||
|
new WebDavProperty("getcontentlength"),
|
||||||
|
new WebDavProperty("getcontenttype"),
|
||||||
|
new WebDavProperty("getetag"),
|
||||||
|
new WebDavProperty("getlastmodified"),
|
||||||
|
new WebDavProperty("resourcetype"),
|
||||||
|
new WebDavProperty("supportedlock"),
|
||||||
|
new WebDavProperty("ishidden")
|
||||||
|
};
|
||||||
|
//list.Add(new WebDAVProperty("getcontentlanguage"));
|
||||||
|
//list.Add(new WebDAVProperty("lockdiscovery"));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region BuildResponseBody
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds the <see cref="XmlDocument" /> containing the response body
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The <see cref="IHttpListenerContext" /></param>
|
||||||
|
/// <param name="propname">The boolean defining the Propfind propname request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="XmlDocument" /> containing the response body
|
||||||
|
/// </returns>
|
||||||
|
private XmlDocument ResponseDocument(IHttpListenerContext context, bool propname)
|
||||||
|
{
|
||||||
|
// Create the basic response XmlDocument
|
||||||
|
XmlDocument responseDoc = new XmlDocument();
|
||||||
|
const string responseXml = "<?xml version=\"1.0\"?><D:multistatus xmlns:D=\"DAV:\"></D:multistatus>";
|
||||||
|
responseDoc.LoadXml(responseXml);
|
||||||
|
|
||||||
|
// Generate the manager
|
||||||
|
XmlNamespaceManager manager = new XmlNamespaceManager(responseDoc.NameTable);
|
||||||
|
manager.AddNamespace("D", "DAV:");
|
||||||
|
manager.AddNamespace("Office", "schemas-microsoft-com:office:office");
|
||||||
|
manager.AddNamespace("Repl", "http://schemas.microsoft.com/repl/");
|
||||||
|
manager.AddNamespace("Z", "urn:schemas-microsoft-com:");
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
foreach (IWebDavStoreItem webDavStoreItem in _webDavStoreItems)
|
||||||
|
{
|
||||||
|
// Create the response element
|
||||||
|
WebDavProperty responseProperty = new WebDavProperty("response", "");
|
||||||
|
XmlElement responseElement = responseProperty.ToXmlElement(responseDoc);
|
||||||
|
|
||||||
|
// The href element
|
||||||
|
Uri result;
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
Uri.TryCreate(_requestUri, "", out result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Uri.TryCreate(_requestUri, webDavStoreItem.Name, out result);
|
||||||
|
}
|
||||||
|
WebDavProperty hrefProperty = new WebDavProperty("href", result.AbsoluteUri);
|
||||||
|
responseElement.AppendChild(hrefProperty.ToXmlElement(responseDoc));
|
||||||
|
count++;
|
||||||
|
|
||||||
|
// The propstat element
|
||||||
|
WebDavProperty propstatProperty = new WebDavProperty("propstat", "");
|
||||||
|
XmlElement propstatElement = propstatProperty.ToXmlElement(responseDoc);
|
||||||
|
|
||||||
|
// The prop element
|
||||||
|
WebDavProperty propProperty = new WebDavProperty("prop", "");
|
||||||
|
XmlElement propElement = propProperty.ToXmlElement(responseDoc);
|
||||||
|
|
||||||
|
foreach (WebDavProperty davProperty in _requestedProperties)
|
||||||
|
{
|
||||||
|
propElement.AppendChild(PropChildElement(davProperty, responseDoc, webDavStoreItem, propname));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the prop element to the propstat element
|
||||||
|
propstatElement.AppendChild(propElement);
|
||||||
|
|
||||||
|
// The status element
|
||||||
|
WebDavProperty statusProperty = new WebDavProperty("status",
|
||||||
|
"HTTP/1.1 " + context.Response.StatusCode + " " +
|
||||||
|
HttpWorkerRequest.GetStatusDescription(context.Response.StatusCode));
|
||||||
|
propstatElement.AppendChild(statusProperty.ToXmlElement(responseDoc));
|
||||||
|
|
||||||
|
// Add the propstat element to the response element
|
||||||
|
responseElement.AppendChild(propstatElement);
|
||||||
|
|
||||||
|
// Add the response element to the multistatus element
|
||||||
|
responseDoc.DocumentElement.AppendChild(responseElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseDoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gives the
|
||||||
|
/// <see cref="XmlElement" /> of a
|
||||||
|
/// <see cref="WebDavProperty" />
|
||||||
|
/// with or without values
|
||||||
|
/// or with or without child elements
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="webDavProperty">The <see cref="WebDavProperty" /></param>
|
||||||
|
/// <param name="xmlDocument">The <see cref="XmlDocument" /> containing the response body</param>
|
||||||
|
/// <param name="iWebDavStoreItem">The <see cref="IWebDavStoreItem" /></param>
|
||||||
|
/// <param name="isPropname">The boolean defining the Propfind propname request</param>
|
||||||
|
/// <returns>
|
||||||
|
/// The <see cref="XmlElement" /> of the <see cref="WebDavProperty" /> containing a value or child elements
|
||||||
|
/// </returns>
|
||||||
|
private XmlElement PropChildElement(WebDavProperty webDavProperty, XmlDocument xmlDocument, IWebDavStoreItem iWebDavStoreItem, bool isPropname)
|
||||||
|
{
|
||||||
|
// If Propfind request contains a propname element
|
||||||
|
if (isPropname)
|
||||||
|
{
|
||||||
|
webDavProperty.Value = String.Empty;
|
||||||
|
return webDavProperty.ToXmlElement(xmlDocument);
|
||||||
|
}
|
||||||
|
// If not, add the values to webDavProperty
|
||||||
|
webDavProperty.Value = GetWebDavPropertyValue(iWebDavStoreItem, webDavProperty);
|
||||||
|
XmlElement xmlElement = webDavProperty.ToXmlElement(xmlDocument);
|
||||||
|
|
||||||
|
// If the webDavProperty is the resourcetype property
|
||||||
|
// and the webDavStoreItem is a collection
|
||||||
|
// add the collection XmlElement as a child to the xmlElement
|
||||||
|
if (webDavProperty.Name != "resourcetype" || !iWebDavStoreItem.IsCollection)
|
||||||
|
return xmlElement;
|
||||||
|
|
||||||
|
WebDavProperty collectionProperty = new WebDavProperty("collection", "");
|
||||||
|
xmlElement.AppendChild(collectionProperty.ToXmlElement(xmlDocument));
|
||||||
|
return xmlElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the correct value for a <see cref="WebDavProperty" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="webDavStoreItem">The <see cref="IWebDavStoreItem" /> defines the values</param>
|
||||||
|
/// <param name="davProperty">The <see cref="WebDavProperty" /> that needs a value</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="string" /> containing the value
|
||||||
|
/// </returns>
|
||||||
|
private string GetWebDavPropertyValue(IWebDavStoreItem webDavStoreItem, WebDavProperty davProperty)
|
||||||
|
{
|
||||||
|
switch (davProperty.Name)
|
||||||
|
{
|
||||||
|
case "creationdate":
|
||||||
|
return webDavStoreItem.CreationDate.ToUniversalTime().ToString("s") + "Z";
|
||||||
|
case "displayname":
|
||||||
|
return webDavStoreItem.Name;
|
||||||
|
case "getcontentlanguage":
|
||||||
|
// still to implement !!!
|
||||||
|
return String.Empty;
|
||||||
|
case "getcontentlength":
|
||||||
|
return (!webDavStoreItem.IsCollection ? "" + ((IWebDavStoreDocument) webDavStoreItem).Size : "");
|
||||||
|
case "getcontenttype":
|
||||||
|
return (!webDavStoreItem.IsCollection ? "" + ((IWebDavStoreDocument) webDavStoreItem).MimeType : "");
|
||||||
|
case "getetag":
|
||||||
|
return (!webDavStoreItem.IsCollection ? "" + ((IWebDavStoreDocument) webDavStoreItem).Etag : "");
|
||||||
|
case "getlastmodified":
|
||||||
|
return webDavStoreItem.ModificationDate.ToUniversalTime().ToString("R");
|
||||||
|
case "lockdiscovery":
|
||||||
|
// still to implement !!!
|
||||||
|
return String.Empty;
|
||||||
|
case "resourcetype":
|
||||||
|
return "";
|
||||||
|
case "supportedlock":
|
||||||
|
// still to implement !!!
|
||||||
|
return "";
|
||||||
|
//webDavProperty.Value = "<D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>";
|
||||||
|
case "ishidden":
|
||||||
|
return "" + webDavStoreItem.Hidden;
|
||||||
|
default:
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SendResponse
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the response
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">The <see cref="IHttpListenerContext" /> containing the response</param>
|
||||||
|
/// <param name="responseDocument">The <see cref="XmlDocument" /> containing the response body</param>
|
||||||
|
private static void SendResponse(IHttpListenerContext context, XmlDocument responseDocument)
|
||||||
|
{
|
||||||
|
// convert the XmlDocument
|
||||||
|
byte[] responseBytes = Encoding.UTF8.GetBytes(responseDocument.InnerXml);
|
||||||
|
|
||||||
|
// HttpStatusCode doesn't contain WebDav status codes, but HttpWorkerRequest can handle these WebDav status codes
|
||||||
|
context.Response.StatusCode = (int)WebDavStatusCode.MultiStatus;
|
||||||
|
context.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription((int)WebDavStatusCode.MultiStatus);
|
||||||
|
|
||||||
|
context.Response.ContentLength64 = responseBytes.Length;
|
||||||
|
context.Response.AdaptedInstance.ContentType = "text/xml";
|
||||||
|
context.Response.OutputStream.Write(responseBytes, 0, responseBytes.Length);
|
||||||
|
|
||||||
|
context.Response.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,196 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Xml;
|
||||||
|
using Common.Logging;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
using WebDAVSharp.Server.Utilities;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>PROPPATCH</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavProppatchMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"PROPPATCH"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
ILog log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Retreive al the information from the request
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// Get the URI to the location
|
||||||
|
Uri requestUri = context.Request.Url;
|
||||||
|
|
||||||
|
// Initiate the XmlNamespaceManager and the XmlNodes
|
||||||
|
XmlNamespaceManager manager = null;
|
||||||
|
XmlNode propNode = null;
|
||||||
|
|
||||||
|
// try to read the body
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StreamReader reader = new StreamReader(context.Request.InputStream, Encoding.UTF8);
|
||||||
|
string requestBody = reader.ReadToEnd();
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(requestBody))
|
||||||
|
{
|
||||||
|
XmlDocument requestDocument = new XmlDocument();
|
||||||
|
requestDocument.LoadXml(requestBody);
|
||||||
|
|
||||||
|
if (requestDocument.DocumentElement != null)
|
||||||
|
{
|
||||||
|
if (requestDocument.DocumentElement.LocalName != "propertyupdate")
|
||||||
|
{
|
||||||
|
log.Debug("PROPPATCH method without propertyupdate element in xml document");
|
||||||
|
}
|
||||||
|
|
||||||
|
manager = new XmlNamespaceManager(requestDocument.NameTable);
|
||||||
|
manager.AddNamespace("D", "DAV:");
|
||||||
|
manager.AddNamespace("Office", "schemas-microsoft-com:office:office");
|
||||||
|
manager.AddNamespace("Repl", "http://schemas.microsoft.com/repl/");
|
||||||
|
manager.AddNamespace("Z", "urn:schemas-microsoft-com:");
|
||||||
|
|
||||||
|
propNode = requestDocument.DocumentElement.SelectSingleNode("D:set/D:prop", manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.Warn(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Take action
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// Get the parent collection of the item
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
// Get the item from the collection
|
||||||
|
IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url);
|
||||||
|
|
||||||
|
FileInfo fileInfo = new FileInfo(item.ItemPath);
|
||||||
|
|
||||||
|
if (propNode != null && fileInfo.Exists)
|
||||||
|
{
|
||||||
|
foreach (XmlNode node in propNode.ChildNodes)
|
||||||
|
{
|
||||||
|
switch (node.LocalName)
|
||||||
|
{
|
||||||
|
case "Win32CreationTime":
|
||||||
|
fileInfo.CreationTime = Convert.ToDateTime(node.InnerText).ToUniversalTime();
|
||||||
|
break;
|
||||||
|
case "Win32LastAccessTime":
|
||||||
|
fileInfo.LastAccessTime = Convert.ToDateTime(node.InnerText).ToUniversalTime();
|
||||||
|
break;
|
||||||
|
case "Win32LastModifiedTime":
|
||||||
|
fileInfo.LastWriteTime = Convert.ToDateTime(node.InnerText).ToUniversalTime();
|
||||||
|
break;
|
||||||
|
case "Win32FileAttributes":
|
||||||
|
//fileInfo.Attributes =
|
||||||
|
//fileInfo.Attributes = Convert.ToDateTime(node.InnerText);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Create the body for the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// Create the basic response XmlDocument
|
||||||
|
XmlDocument responseDoc = new XmlDocument();
|
||||||
|
const string responseXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:multistatus " +
|
||||||
|
"xmlns:Z=\"urn:schemas-microsoft-com:\" xmlns:D=\"DAV:\">" +
|
||||||
|
"<D:response></D:response></D:multistatus>";
|
||||||
|
responseDoc.LoadXml(responseXml);
|
||||||
|
|
||||||
|
// Select the response node
|
||||||
|
XmlNode responseNode = responseDoc.DocumentElement.SelectSingleNode("D:response", manager);
|
||||||
|
|
||||||
|
// Add the elements
|
||||||
|
|
||||||
|
// The href element
|
||||||
|
WebDavProperty hrefProperty = new WebDavProperty("href", requestUri.ToString());
|
||||||
|
responseNode.AppendChild(hrefProperty.ToXmlElement(responseDoc));
|
||||||
|
|
||||||
|
// The propstat element
|
||||||
|
WebDavProperty propstatProperty = new WebDavProperty("propstat", "");
|
||||||
|
XmlElement propstatElement = propstatProperty.ToXmlElement(responseDoc);
|
||||||
|
|
||||||
|
// The propstat/status element
|
||||||
|
WebDavProperty statusProperty = new WebDavProperty("status", "HTTP/1.1 " + context.Response.StatusCode + " " +
|
||||||
|
HttpWorkerRequest.GetStatusDescription(context.Response.StatusCode));
|
||||||
|
propstatElement.AppendChild(statusProperty.ToXmlElement(responseDoc));
|
||||||
|
|
||||||
|
// The other propstat children
|
||||||
|
foreach (WebDavProperty property in from XmlNode child in propNode.ChildNodes
|
||||||
|
where child.Name.ToLower()
|
||||||
|
.Contains("creationtime") || child.Name.ToLower()
|
||||||
|
.Contains("fileattributes") || child.Name.ToLower()
|
||||||
|
.Contains("lastaccesstime") || child.Name.ToLower()
|
||||||
|
.Contains("lastmodifiedtime")
|
||||||
|
let node = propNode.SelectSingleNode(child.Name, manager)
|
||||||
|
select node != null
|
||||||
|
? new WebDavProperty(child.LocalName, "", node.NamespaceURI)
|
||||||
|
: new WebDavProperty(child.LocalName, "", ""))
|
||||||
|
propstatElement.AppendChild(property.ToXmlElement(responseDoc));
|
||||||
|
|
||||||
|
responseNode.AppendChild(propstatElement);
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Send the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
// convert the StringBuilder
|
||||||
|
string resp = responseDoc.InnerXml;
|
||||||
|
byte[] responseBytes = Encoding.UTF8.GetBytes(resp);
|
||||||
|
|
||||||
|
|
||||||
|
// HttpStatusCode doesn't contain WebDav status codes, but HttpWorkerRequest can handle these WebDav status codes
|
||||||
|
context.Response.StatusCode = (int)WebDavStatusCode.MultiStatus;
|
||||||
|
context.Response.StatusDescription = HttpWorkerRequest.GetStatusDescription((int)WebDavStatusCode.MultiStatus);
|
||||||
|
|
||||||
|
// set the headers of the response
|
||||||
|
context.Response.ContentLength64 = responseBytes.Length;
|
||||||
|
context.Response.AdaptedInstance.ContentType = "text/xml";
|
||||||
|
|
||||||
|
// the body
|
||||||
|
context.Response.OutputStream.Write(responseBytes, 0, responseBytes.Length);
|
||||||
|
|
||||||
|
context.Response.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>PUT</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavPutMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"PUT"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavMethodNotAllowedException"></exception>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavLengthRequiredException">If the ContentLength header was not found</exception>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
// Get the parent collection
|
||||||
|
IWebDavStoreCollection parentCollection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
// Gets the item name from the url
|
||||||
|
string itemName = Uri.UnescapeDataString(context.Request.Url.Segments.Last().TrimEnd('/', '\\'));
|
||||||
|
|
||||||
|
IWebDavStoreItem item = parentCollection.GetItemByName(itemName);
|
||||||
|
IWebDavStoreDocument doc;
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
doc = item as IWebDavStoreDocument;
|
||||||
|
if (doc == null)
|
||||||
|
throw new WebDavMethodNotAllowedException();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doc = parentCollection.CreateDocument(itemName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.Request.ContentLength64 < 0)
|
||||||
|
throw new WebDavLengthRequiredException();
|
||||||
|
|
||||||
|
using (Stream stream = doc.OpenWriteStream(false))
|
||||||
|
{
|
||||||
|
long left = context.Request.ContentLength64;
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
while (left > 0)
|
||||||
|
{
|
||||||
|
int toRead = Convert.ToInt32(Math.Min(left, buffer.Length));
|
||||||
|
int inBuffer = context.Request.InputStream.Read(buffer, 0, toRead);
|
||||||
|
stream.Write(buffer, 0, inBuffer);
|
||||||
|
|
||||||
|
left -= inBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.SendSimpleResponse(HttpStatusCode.Created);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using WebDAVSharp.Server.Adapters;
|
||||||
|
using WebDAVSharp.Server.Stores;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.MethodHandlers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements the <c>PUT</c> HTTP method for WebDAV#.
|
||||||
|
/// </summary>
|
||||||
|
internal class WebDavUnlockMethodHandler : WebDavMethodHandlerBase, IWebDavMethodHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of the names of the HTTP methods handled by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The names.
|
||||||
|
/// </value>
|
||||||
|
public IEnumerable<string> Names
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
"UNLOCK"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="server">The <see cref="WebDavServer" /> through which the request came in from the client.</param>
|
||||||
|
/// <param name="context">The
|
||||||
|
/// <see cref="IHttpListenerContext" /> object containing both the request and response
|
||||||
|
/// objects to use.</param>
|
||||||
|
/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
|
||||||
|
public void ProcessRequest(WebDavServer server, IHttpListenerContext context, IWebDavStore store)
|
||||||
|
{
|
||||||
|
// Get the parent collection of the item
|
||||||
|
IWebDavStoreCollection collection = GetParentCollection(server, store, context.Request.Url);
|
||||||
|
|
||||||
|
// Get the item from the collection
|
||||||
|
IWebDavStoreItem item = GetItemFromCollection(collection, context.Request.Url);
|
||||||
|
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Send the response
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
context.SendSimpleResponse(HttpStatusCode.NoContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Resources;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("WebDAVSharp.Server")]
|
||||||
|
[assembly: AssemblyDescription("WebDAV Server implementation for WebDAV#")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("WebDAVSharp")]
|
||||||
|
[assembly: AssemblyCopyright("")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
[assembly: Guid("947fc4a0-9ed5-4d6c-9a97-9daf02524439")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
[assembly: NeutralResourcesLanguage("en")]
|
||||||
|
[assembly: CLSCompliant(true)]
|
||||||
|
[assembly: InternalsVisibleTo("WebDAVSharp.Server.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b3873160e2fe02227fcc8df15c8beb7bb90a43f375f587ed283f770172cb6215fe4ab11c07508c97cda3220b36e2f59a246b9ab659a49dfd360bbbac1b7bf4e84f1d8c356f6504c3659d8c8742d7cb591254674898fdff5121bd8fd79953ad43bed463fe054b62d27a83ae561380562cd624d775353697c0e28194bd0896df97")]
|
|
@ -0,0 +1,28 @@
|
||||||
|
WebDAVSharp.Server
|
||||||
|
==================
|
||||||
|
|
||||||
|
A WebDAV server, coded in C#, which can be used for various WebDAV .NET applications.
|
||||||
|
|
||||||
|
WebDAV# is developed in the .NET Framework 4.5
|
||||||
|
|
||||||
|
## SQLExample ##
|
||||||
|
|
||||||
|
A SQL version of the server has been developed by [Winterleaf][6] and can be found at [this repository][7]
|
||||||
|
|
||||||
|
## Developed by ##
|
||||||
|
|
||||||
|
The WebDAV server implementation was based on another open source project, also called WebDAV#.
|
||||||
|
The maintainer of the project is [Lasse V. Karlsen][1] and the code can be found on [CodePlex][2].
|
||||||
|
|
||||||
|
This version of WebDAV# has been developed by [Lieven Janssen][3] and [Ewout Merckx][4] at [Xplore+][5].
|
||||||
|
|
||||||
|
The last changes have been contributed by [Vincent Gee (Winterleaf)][6].
|
||||||
|
|
||||||
|
|
||||||
|
[1]: http://www.vkarlsen.no/
|
||||||
|
[2]: https://webdavsharp.codeplex.com/
|
||||||
|
[3]: https://www.linkedin.com/in/lievenjanssen/
|
||||||
|
[4]: https://www.linkedin.com/in/ewoutmerckx
|
||||||
|
[5]: http://xploreplus.com/
|
||||||
|
[6]: https://github.com/Winterleaf
|
||||||
|
[7]: https://github.com/Winterleaf/Winterleaf-WebDavSharp.SQLExample
|
|
@ -0,0 +1,41 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Stores.BaseClasses
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class is a base class for <see cref="IWebDavStore" /> implementations.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class WebDavStoreBase : IWebDavStore
|
||||||
|
{
|
||||||
|
private readonly IWebDavStoreCollection _root;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavStoreBase" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="root">The root <see cref="IWebDavStoreCollection" />.</param>
|
||||||
|
/// <exception cref="System.ArgumentNullException">root</exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="root" /> is <c>null</c>.</exception>
|
||||||
|
protected WebDavStoreBase(IWebDavStoreCollection root)
|
||||||
|
{
|
||||||
|
if (root == null)
|
||||||
|
throw new ArgumentNullException("root");
|
||||||
|
|
||||||
|
_root = root;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IWebDAVStore Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the root collection of this <see cref="IWebDavStore" />.
|
||||||
|
/// </summary>
|
||||||
|
public IWebDavStoreCollection Root
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Stores.BaseClasses
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is the base class for <see cref="IWebDavStoreItem" /> implementations.
|
||||||
|
/// </summary>
|
||||||
|
public class WebDavStoreDocumentBase : WebDavStoreItemBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavStoreItemBase" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentCollection">The parent <see cref="IWebDavStoreCollection" /> that contains this <see cref="IWebDavStoreItem" /> implementation.</param>
|
||||||
|
/// <param name="name">The name of this <see cref="IWebDavStoreItem" /></param>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception>
|
||||||
|
protected WebDavStoreDocumentBase(IWebDavStoreCollection parentCollection, string name) : base(parentCollection, name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IWebDAVStoreItem Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the mime type of this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The type of the MIME.
|
||||||
|
/// </value>
|
||||||
|
public string MimeType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return MimeMapping.GetMimeMapping(Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,144 @@
|
||||||
|
using System;
|
||||||
|
using WebDAVSharp.Server.Exceptions;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Stores.BaseClasses
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is the base class for <see cref="IWebDavStoreItem" /> implementations.
|
||||||
|
/// </summary>
|
||||||
|
public class WebDavStoreItemBase : IWebDavStoreItem
|
||||||
|
{
|
||||||
|
private readonly IWebDavStoreCollection _parentCollection;
|
||||||
|
private string _name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavStoreItemBase" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentCollection">The parent <see cref="IWebDavStoreCollection" /> that contains this <see cref="IWebDavStoreItem" /> implementation.</param>
|
||||||
|
/// <param name="name">The name of this <see cref="IWebDavStoreItem" /></param>
|
||||||
|
/// <exception cref="System.ArgumentNullException">name</exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="name" /> is <c>null</c>.</exception>
|
||||||
|
protected WebDavStoreItemBase(IWebDavStoreCollection parentCollection, string name)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrWhiteSpace(name))
|
||||||
|
throw new ArgumentNullException("name");
|
||||||
|
|
||||||
|
_parentCollection = parentCollection;
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IWebDAVStoreItem Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the parent <see cref="IWebDavStoreCollection" /> that owns this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
public IWebDavStoreCollection ParentCollection
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _parentCollection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="WebDAVSharp.Server.Exceptions.WebDavForbiddenException"></exception>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
string fixedName = (value ?? string.Empty).Trim();
|
||||||
|
if (fixedName == _name) return;
|
||||||
|
if (!OnNameChanging(_name, fixedName))
|
||||||
|
throw new WebDavForbiddenException();
|
||||||
|
string oldName = _name;
|
||||||
|
_name = fixedName;
|
||||||
|
OnNameChanged(oldName, _name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the creation date of this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
public virtual DateTime CreationDate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the modification date of this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
public virtual DateTime ModificationDate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the path to this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
public virtual string ItemPath
|
||||||
|
{
|
||||||
|
get { return String.Empty; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if this <see cref="IWebDavStoreItem" /> is a collection.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsCollection
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the hidden state of this <see cref="IWebDavStoreItem" />.
|
||||||
|
/// </summary>
|
||||||
|
public int Hidden
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called before the name of this <see cref="IWebDavStoreItem" /> is changing.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="oldName">The old name of this <see cref="IWebDavStoreItem" />.</param>
|
||||||
|
/// <param name="newName">The new name of this <see cref="IWebDavStoreItem" />.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <c>true</c> if the name change is allowed;
|
||||||
|
/// otherwise,
|
||||||
|
/// <c>false</c>.
|
||||||
|
/// </returns>
|
||||||
|
protected virtual bool OnNameChanging(string oldName, string newName)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called after the name of this <see cref="IWebDavStoreItem" /> has changed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="oldName">The old name of this <see cref="IWebDavStoreItem" />.</param>
|
||||||
|
/// <param name="newName">The new name of this <see cref="IWebDavStoreItem" />.</param>
|
||||||
|
protected virtual void OnNameChanged(string oldName, string newName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace WebDAVSharp.Server.Stores.DiskStore
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements a disk-based <see cref="IWebDavStore" />.
|
||||||
|
/// </summary>
|
||||||
|
[DebuggerDisplay("Disk Store ({RootPath})")]
|
||||||
|
public sealed class WebDavDiskStore : IWebDavStore
|
||||||
|
{
|
||||||
|
private readonly string _rootPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="WebDavDiskStore" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rootPath">The root path of a folder on disk to host in this <see cref="WebDavDiskStore" />.</param>
|
||||||
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
|
/// <exception cref="System.IO.DirectoryNotFoundException"></exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="rootPath" /> is <c>null</c>.</exception>
|
||||||
|
/// <exception cref="DirectoryNotFoundException"><paramref name="rootPath" /> specifies a folder that does not exist.</exception>
|
||||||
|
public WebDavDiskStore(string rootPath)
|
||||||
|
{
|
||||||
|
if (rootPath == null)
|
||||||
|
throw new ArgumentNullException(rootPath);
|
||||||
|
if (!Directory.Exists(rootPath))
|
||||||
|
throw new DirectoryNotFoundException(rootPath);
|
||||||
|
|
||||||
|
_rootPath = rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the root path for the folder that is hosted in this <see cref="WebDavDiskStore" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The root path.
|
||||||
|
/// </value>
|
||||||
|
public string RootPath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _rootPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IWebDAVStore Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the root collection of this <see cref="IWebDavStore" />.
|
||||||
|
/// </summary>
|
||||||
|
public IWebDavStoreCollection Root
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new WebDavDiskStoreCollection(null, _rootPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue