/// <summary>
        /// Initializes a new instance of the <see cref="BulkDeletionFailedObject"/> class
        /// with the specified object name and status.
        /// </summary>
        /// <param name="obj">The name of the object which could not be deleted.</param>
        /// <param name="status">A <see cref="Status"/> object describing the reason the object could not be deleted.</param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="obj"/> is <c>null</c>.
        /// <para>-or-</para>
        /// <para>If <paramref name="status"/> is <c>null</c>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">If <paramref name="obj"/> is empty.</exception>
        public BulkDeletionFailedObject(string obj, Status status)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");
            if (status == null)
                throw new ArgumentNullException("status");
            if (string.IsNullOrEmpty(obj))
                throw new ArgumentException("obj cannot be empty");

            Object = obj;
            Status = status;
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public virtual bool TryParse(string value, out Status result)
        {
            if (value == null)
            {
                result = null;
                return false;
            }

            var match = _expression.Match(value);
            if (!match.Success)
            {
                result = null;
                return false;
            }

            HttpStatusCode statusCode = (HttpStatusCode)int.Parse(match.Groups["StatusCode"].Value);
            string description = match.Groups["Status"].Value;
            if (string.IsNullOrEmpty(description))
                description = statusCode.ToString();

            result = new Status((int)statusCode, description);
            return true;
        }