/// <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);
        }
Exemple #2
0
        /// <summary>
        /// Tries to parse the given <paramref name="rawAbsoluteUri"/> into an <see cref="AbsoluteUri"/>.
        /// </summary>
        /// <param name="rawAbsoluteUri">The absolute-URI to parse.</param>
        /// <param name="absoluteUri">The <see cref="AbsoluteUri"/>.</param>
        /// <returns>True if the parsing succeeded, false if it did not.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="rawAbsoluteUri"/> is null.</exception>
        public static bool TryParse(string rawAbsoluteUri, out AbsoluteUri absoluteUri)
        {
            if (rawAbsoluteUri == null)
            {
                throw new ArgumentNullException(nameof(rawAbsoluteUri));
            }

            if (Uri.TryCreate(rawAbsoluteUri, UriKind.Absolute, out var parsedUri))
            {
                absoluteUri = new AbsoluteUri(parsedUri);
                return(true);
            }

            absoluteUri = null;
            return(false);
        }
Exemple #3
0
 /// <summary>
 /// Constructs a Coded-URL based on the <paramref name="absoluteUri"/>.
 /// See <see href="https://tools.ietf.org/html/rfc4918#section-10.1"/> for the Coded-URL definition.
 /// </summary>
 /// <param name="absoluteUri">The lock token in absolute-URI format.</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="absoluteUri"/> is null.</exception>
 internal CodedUrl(AbsoluteUri absoluteUri)
 {
     AbsoluteUri = absoluteUri ?? throw new ArgumentNullException(nameof(absoluteUri));
 }