/wasDAVClient/Helpers/ResponseParser.cs |
@@ -1,11 +1,4 @@ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
// Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
// rights of fair usage, the disclaimer and warranty conditions. // |
/////////////////////////////////////////////////////////////////////////// |
// Originally based on: WebDAV .NET client by Sergey Kazantsev |
|
using System; |
using System; |
using System.Collections.Generic; |
using System.IO; |
using System.Linq; |
@@ -16,19 +9,12 @@ |
namespace wasDAVClient.Helpers |
{ |
/// <summary> |
/// Represents the parser for response's results. |
/// Represents the parser for response's results. |
/// </summary> |
internal static class ResponseParser |
{ |
internal static XmlReaderSettings XmlReaderSettings = new XmlReaderSettings |
{ |
IgnoreComments = true, |
IgnoreProcessingInstructions = true, |
IgnoreWhitespace = true |
}; |
|
/// <summary> |
/// Parses the disk item. |
/// Parses the disk item. |
/// </summary> |
/// <param name="stream">The response text.</param> |
/// <returns>The parsed item.</returns> |
@@ -37,8 +23,15 @@ |
return ParseItems(stream).FirstOrDefault(); |
} |
|
internal static XmlReaderSettings XmlReaderSettings = new XmlReaderSettings |
{ |
IgnoreComments = true, |
IgnoreProcessingInstructions = true, |
IgnoreWhitespace = true |
}; |
|
/// <summary> |
/// Parses the disk items. |
/// Parses the disk items. |
/// </summary> |
/// <param name="stream">The response text.</param> |
/// <returns>The list of parsed items.</returns> |
@@ -47,6 +40,7 @@ |
var items = new List<Item>(); |
using (var reader = XmlReader.Create(stream, XmlReaderSettings)) |
{ |
|
Item itemInfo = null; |
while (reader.Read()) |
{ |
@@ -131,8 +125,7 @@ |
{ |
reader.Read(); |
var resourceType = reader.LocalName.ToLower(); |
if (string.Equals(resourceType, "collection", |
StringComparison.InvariantCultureIgnoreCase)) |
if (string.Equals(resourceType, "collection", StringComparison.InvariantCultureIgnoreCase)) |
itemInfo.IsCollection = true; |
} |
break; |
@@ -144,6 +137,11 @@ |
case "version-controlled-configuration": |
reader.Skip(); |
break; |
default: |
{ |
int a = 0; |
break; |
} |
} |
} |
else if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName.ToLower() == "response") |
@@ -166,5 +164,7 @@ |
|
return items; |
} |
|
|
} |
} |
} |
/wasDAVClient/Helpers/wasDAVConflictException.cs |
@@ -1,54 +1,40 @@ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
// Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
// rights of fair usage, the disclaimer and warranty conditions. // |
/////////////////////////////////////////////////////////////////////////// |
// Originally based on: WebDAV .NET client by Sergey Kazantsev |
|
using System; |
using System.Runtime.Serialization; |
|
namespace wasDAVClient.Helpers |
{ |
public class wasDAVConflictException : wasDAVException |
{ |
public wasDAVConflictException() |
{ |
} |
|
public wasDAVConflictException(string message) |
: base(message) |
{ |
} |
|
public wasDAVConflictException(string message, int hr) |
: base(message, hr) |
{ |
} |
|
public wasDAVConflictException(string message, Exception innerException) |
: base(message, innerException) |
{ |
} |
|
public wasDAVConflictException(int httpCode, string message, Exception innerException) |
: base(httpCode, message, innerException) |
{ |
} |
|
public wasDAVConflictException(int httpCode, string message) |
: base(httpCode, message) |
{ |
} |
|
public wasDAVConflictException(int httpCode, string message, int hr) |
: base(httpCode, message, hr) |
{ |
} |
|
protected wasDAVConflictException(SerializationInfo info, StreamingContext context) |
: base(info, context) |
{ |
} |
} |
using System; |
using System.Runtime.Serialization; |
|
namespace wasDAVClient.Helpers |
{ |
public class wasDAVConflictException : wasDAVException |
{ |
public wasDAVConflictException() |
{ |
} |
|
public wasDAVConflictException(string message) |
: base(message) |
{} |
|
public wasDAVConflictException(string message, int hr) |
: base(message, hr) |
{} |
|
public wasDAVConflictException(string message, Exception innerException) |
: base(message, innerException) |
{} |
|
public wasDAVConflictException(int httpCode, string message, Exception innerException) |
: base(httpCode, message, innerException) |
{} |
|
public wasDAVConflictException(int httpCode, string message) |
: base(httpCode, message) |
{} |
|
public wasDAVConflictException(int httpCode, string message, int hr) |
: base(httpCode, message, hr) |
{} |
|
protected wasDAVConflictException(SerializationInfo info, StreamingContext context) |
: base(info, context) |
{} |
} |
} |
/wasDAVClient/Helpers/wasDAVException.cs |
@@ -1,70 +1,51 @@ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
// Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
// rights of fair usage, the disclaimer and warranty conditions. // |
/////////////////////////////////////////////////////////////////////////// |
// Originally based on: WebDAV .NET client by Sergey Kazantsev |
|
using System; |
using System.Runtime.Serialization; |
using System.Text; |
using System.Web; |
|
namespace wasDAVClient.Helpers |
{ |
public class wasDAVException : HttpException |
{ |
public wasDAVException() |
{ |
} |
|
public wasDAVException(string message) |
: base(message) |
{ |
} |
|
public wasDAVException(string message, int hr) |
: base(message, hr) |
{ |
} |
|
public wasDAVException(string message, Exception innerException) |
: base(message, innerException) |
{ |
} |
|
public wasDAVException(int httpCode, string message, Exception innerException) |
: base(httpCode, message, innerException) |
{ |
} |
|
public wasDAVException(int httpCode, string message) |
: base(httpCode, message) |
{ |
} |
|
public wasDAVException(int httpCode, string message, int hr) |
: base(httpCode, message, hr) |
{ |
} |
|
protected wasDAVException(SerializationInfo info, StreamingContext context) |
: base(info, context) |
{ |
} |
|
public override string ToString() |
{ |
var sb = new StringBuilder(); |
sb.Append($"HttpStatusCode: {GetHttpCode()}"); |
sb.Append(Environment.NewLine); |
sb.Append($"ErrorCode: {ErrorCode}"); |
sb.Append(Environment.NewLine); |
sb.Append($"Message: {Message}"); |
sb.Append(Environment.NewLine); |
sb.Append(base.ToString()); |
|
return sb.ToString(); |
} |
} |
using System; |
using System.Runtime.Serialization; |
using System.Web; |
|
namespace wasDAVClient.Helpers |
{ |
public class wasDAVException : HttpException |
{ |
public wasDAVException() |
{ |
} |
|
public wasDAVException(string message) |
: base(message) |
{} |
|
public wasDAVException(string message, int hr) |
: base(message, hr) |
{} |
|
public wasDAVException(string message, Exception innerException) |
: base(message, innerException) |
{} |
|
public wasDAVException(int httpCode, string message, Exception innerException) |
: base(httpCode, message, innerException) |
{} |
|
public wasDAVException(int httpCode, string message) |
: base(httpCode, message) |
{} |
|
public wasDAVException(int httpCode, string message, int hr) |
: base(httpCode, message, hr) |
{} |
|
protected wasDAVException(SerializationInfo info, StreamingContext context) |
: base(info, context) |
{} |
|
public override string ToString() |
{ |
var s = string.Format("HttpStatusCode: {0}", base.GetHttpCode()); |
s += Environment.NewLine + string.Format("ErrorCode: {0}", ErrorCode); |
s += Environment.NewLine + string.Format("Message: {0}", Message); |
s += Environment.NewLine + base.ToString(); |
|
return s; |
} |
} |
} |