Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
Merge branch 'pr/19-expose-the-internal-locktoken-value-for-serializa…
Browse files Browse the repository at this point in the history
…tion'
  • Loading branch information
DecaTec committed Feb 16, 2017
2 parents e8c4aeb + 0978f38 commit cc51c8f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Shared/DecaTec.WebDav.Shared/LockToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace DecaTec.WebDav
/// </summary>
public class LockToken
{
private string lockToken;

/// <summary>
/// Initializes a new instance of LockToken.
/// </summary>
Expand All @@ -18,9 +16,16 @@ public LockToken(string lockToken)
if (string.IsNullOrEmpty(lockToken))
throw new WebDavException("A lock token cannot be null or empty.");

this.lockToken = lockToken;
this.RawLockToken = lockToken;
}

/// <summary>
/// Gets the raw representation of the lock token for serialization purposes.
///
/// Use <see cref="ToString"/> to get the formatted representation for use in headers.
/// </summary>
public string RawLockToken { get; }

/// <summary>
/// Gets the string representation of a lock token as used in an IF header.
/// </summary>
Expand All @@ -30,16 +35,16 @@ public string ToString(LockTokenFormat format)
{
var sb = new StringBuilder();

if (format == LockTokenFormat.IfHeader && !this.lockToken.StartsWith("("))
if (format == LockTokenFormat.IfHeader && !this.RawLockToken.StartsWith("("))
sb.Append("(");
else if(!this.lockToken.StartsWith("<") && !this.lockToken.StartsWith("("))
else if(!this.RawLockToken.StartsWith("<") && !this.RawLockToken.StartsWith("("))
sb.Append("<");

sb.Append(this.lockToken);
sb.Append(this.RawLockToken);

if (format == LockTokenFormat.IfHeader && !this.lockToken.EndsWith(")"))
if (format == LockTokenFormat.IfHeader && !this.RawLockToken.EndsWith(")"))
sb.Append(")");
else if(!this.lockToken.EndsWith(">") && !this.lockToken.EndsWith(")"))
else if(!this.RawLockToken.EndsWith(">") && !this.RawLockToken.EndsWith(")"))
sb.Append(">");

return sb.ToString();
Expand Down

0 comments on commit cc51c8f

Please sign in to comment.