/// <summary> /// Constructs a <see cref="LockToken"/> based on the <paramref name="absoluteUri"/>. /// </summary> /// <param name="absoluteUri">The lock token in absolute-URI format as defined in https://tools.ietf.org/html/rfc3986#section-4.3.</param> /// <remarks>Use the strong-typed constructors to create a new <see cref="LockToken"/>.</remarks> /// <exception cref="WebDavException">Thrown when <paramref name="absoluteUri"/> is null.</exception> public LockToken(AbsoluteUri absoluteUri) { AbsoluteUri = absoluteUri ?? throw new WebDavException($"The {nameof(absoluteUri)} cannot be null."); var codedUrl = new CodedUrl(absoluteUri); LockTokenHeaderFormat = codedUrl; IfHeaderNoTagListFormat = new NoTagList(codedUrl); }
/// <summary> /// Tries to parse the given <paramref name="rawNoTagList"/> to a <see cref="NoTagList"/>. /// See <see href="https://tools.ietf.org/html/rfc4918#section-10.4.2"/> for the No-Tag List definition. /// </summary> /// <param name="rawNoTagList">The raw No-Tag List to parse into the <see cref="NoTagList"/>.</param> /// <param name="noTagList">The <see cref="NoTagList"/>.</param> /// <returns>The parsed <see cref="NoTagList"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="rawNoTagList"/> is null.</exception> public static bool TryParse(string rawNoTagList, out NoTagList noTagList) { if (rawNoTagList == null) { throw new ArgumentNullException(nameof(rawNoTagList)); } if (!rawNoTagList.StartsWith(NoTagListPrefix.ToString()) || !rawNoTagList.EndsWith(NoTagListPostfix.ToString())) { noTagList = null; return(false); } var rawCodedUrl = rawNoTagList.Trim(NoTagListPrefix, NoTagListPostfix); if (CodedUrl.TryParse(rawCodedUrl, out var codedUrl)) { noTagList = new NoTagList(codedUrl); return(true); } noTagList = null; return(false); }