Пример #1
0
        /// <summary>
        /// Builds the reason phrase for a status code and an additional message
        /// </summary>
        /// <param name="statusCode">The status code to build the reason phrase for</param>
        /// <param name="additionalMessage">The additional message for the reason phrase</param>
        /// <returns>The built reason phrase</returns>
        public static string GetReasonPhrase(this WebDavStatusCode statusCode, string additionalMessage = null)
        {
            var reasonPhrase = _reasonPhrases.GetOrAdd(
                statusCode,
                key =>
            {
                var name    = new StringBuilder();
                var isFirst = true;
                foreach (var part in GetParts(key.ToString("G")))
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        name.Append(' ');
                    }

                    name.Append(part);
                }

                return(name.ToString());
            });

            if (string.IsNullOrEmpty(additionalMessage))
            {
                return(reasonPhrase);
            }

            return($"{reasonPhrase} ({additionalMessage})");
        }
        private IActionResult BuildResultForStatusCode(ExceptionContext context, WebDavStatusCode statusCode, string optionalMessge)
        {
            switch (statusCode)
            {
            case WebDavStatusCode.NotModified:
                // 304 must not return a body
                return(new StatusCodeResult((int)statusCode));
            }

            var result = new WebDavResult <multistatus>(
                statusCode,
                new multistatus()
            {
                response = new[]
                {
                    new response()
                    {
                        href             = context.HttpContext.Request.GetEncodedUrl(),
                        ItemsElementName = new[] { ItemsChoiceType2.status, },
                        Items            = new object[] { new Status(context.HttpContext.Request.Protocol, statusCode, optionalMessge).ToString() },
                    },
                },
            });
            var dispatcher = context.HttpContext.RequestServices.GetService <IWebDavDispatcher>();

            return(new WebDavIndirectResult(dispatcher, result, _responseLogger));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionActionResult"/> class.
 /// </summary>
 /// <param name="target">The target to create the result information for</param>
 /// <param name="createdChildEntries">The created child entries</param>
 /// <param name="failedEntry">The failed child entry</param>
 /// <param name="errorStatusCode">The status code for the failed child entry</param>
 public CollectionActionResult(
     ICollection target,
     IReadOnlyCollection <IEntry> createdChildEntries,
     IEntry failedEntry,
     WebDavStatusCode errorStatusCode)
 {
     Target = target;
     CreatedChildEntries = createdChildEntries;
     FailedEntry         = failedEntry;
     ErrorStatusCode     = errorStatusCode;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionActionResult"/> class.
 /// </summary>
 /// <param name="target">The target to create the result information for</param>
 /// <param name="createdChildEntries">The created child entries</param>
 /// <param name="failedEntry">The failed child entry</param>
 /// <param name="errorStatusCode">The status code for the failed child entry</param>
 public CollectionActionResult(
     [NotNull] ICollection target,
     [NotNull][ItemNotNull] IReadOnlyCollection <IEntry> createdChildEntries,
     [CanBeNull] IEntry failedEntry,
     WebDavStatusCode errorStatusCode)
 {
     Target = target;
     CreatedChildEntries = createdChildEntries;
     FailedEntry         = failedEntry;
     ErrorStatusCode     = errorStatusCode;
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Status"/> struct.
        /// </summary>
        /// <param name="protocol">The HTTP protocol (usually <c>HTTP/1.1</c>)</param>
        /// <param name="statusCode">The WebDAV status code</param>
        /// <param name="additionalReasonPhrase">The additional text to the reason phrase</param>
        public Status([NotNull] string protocol, WebDavStatusCode statusCode, [CanBeNull] string additionalReasonPhrase = null)
        {
            if (string.IsNullOrEmpty(protocol))
            {
                throw new ArgumentNullException(nameof(protocol));
            }

            Protocol     = protocol;
            StatusCode   = (int)statusCode;
            ReasonPhrase = statusCode.GetReasonPhrase(additionalReasonPhrase);
        }
Пример #6
0
        public static void ParseStatusLine( string statusLine,
            out string protocol, out WebDavStatusCode code, out string reason )
        {
            int space1Index = statusLine.IndexOf( " " );
            int space2Index = statusLine.IndexOf( " ", space1Index + 1 );

            if( space1Index < 0 )
            {
                throw new ArgumentException( "Invalid status line" );
            }

            protocol = statusLine.Substring( 0, space1Index );
            code = (WebDavStatusCode) int.Parse( statusLine.Substring(
                space1Index + 1, space2Index - space1Index - 1 ) );
            reason = statusLine.Substring( space2Index + 1 );
        }
Пример #7
0
        private response CreateErrorResponse(WebDavStatusCode statusCode, IEnumerable <IActiveLock> activeLocks)
        {
            var hrefs   = GetHrefs(activeLocks);
            var choices = hrefs.Skip(1)
                          .Select(x => Tuple.Create(ItemsChoiceType2.href, x))
                          .ToList();

            choices.Add(Tuple.Create(
                            ItemsChoiceType2.status,
                            new Status(_context.RequestProtocol, statusCode).ToString()));
            var response = new response()
            {
                href             = hrefs.FirstOrDefault(),
                ItemsElementName = choices.Select(x => x.Item1).ToArray(),
                Items            = choices.Select(x => x.Item2).Cast <object>().ToArray(),
            };

            return(response);
        }
        /// <summary>
        ///     Put a resource to the server.
        /// </summary>
        /// <param name="resourcePath">
        ///     The path the resource will be placed at. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="contentType">
        ///     The type of the content being placed on the
        ///     server.
        /// </param>
        /// <param name="uploadBytes">
        ///     The data being uploaded.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="resultContentType">
        ///     The content of the resource or null if there was an
        ///     error.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication error
        /// prevented the request from succeeding. If true, the caller should
        /// examine the result code and reason to determine whether or not the
        /// result content is valid.</returns>
        public bool PutResource( string resourcePath, string contentType, byte[] uploadBytes,
            out WebDavStatusCode resultCode, out string resultReason, out string resultContentType)
        {
            bool success = PutResource( resourcePath, contentType, uploadBytes,
                out resultCode, out resultReason, out resultContentType, null, null );

            return success;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MissingProperty"/> class.
 /// </summary>
 /// <param name="statusCode">The status code why this property wasn't selected</param>
 /// <param name="propertyName">The name of the property that wasn't selected</param>
 public MissingProperty(WebDavStatusCode statusCode, XName propertyName)
 {
     StatusCode = statusCode;
     Key        = propertyName;
 }
        /// <summary>
        /// Retrieve the names available properties on a resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="propertyNames">
        ///     An array of property names. Just because a property is listed here does
        ///     not mean the caller has permission to retrieve the value.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="resultContent">
        ///     A hashtable with the properties of the resource or
        ///     null if there was an error.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool Propnames( string path, out WebDavStatusCode resultCode,
            out string resultReason, out string[] propertyNames)
        {
            bool success = Propnames(
                path, out resultCode, out resultReason, out propertyNames, null, null );

            return( success );
        }
        /// <summary>
        /// Delete the resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool DeleteResource( string path, out WebDavStatusCode resultCode,
            out string resultReason)
        {
            bool success = DeleteResource( path, out resultCode, out resultReason, null, null );

            return( success );
        }
 /// <summary>
 ///     Get a resource from the server.
 /// </summary>
 /// <param name="path">
 ///     The path of the resource. It must be non-null and
 ///     contain at least one character.
 /// </param>
 /// <param name="resultCode">
 ///     The result code from the server or BadRequest if an
 ///     exception was thrown.
 /// </param>
 /// <param name="resultReason">
 ///     The result message from the server or the exception
 ///     message if an exception was thrown.
 /// </param>
 /// <param name="contentType">
 ///     The reported type of the content returned from the
 ///     server.
 /// </param>
 /// <param name="resultContent">
 ///     The content of the resource or null if there was an
 ///     error.
 /// </param>
 /// <returns>
 ///     true if the call succeeded, false if a communication
 ///     error prevented the request from succeeding. If true,
 ///     the caller should examine the result code and reason
 ///     to determine whether or not the result content is
 ///     valid.
 /// </returns>
 public bool GetResource( string path,
     out WebDavStatusCode resultCode,
     out string resultReason,
     out string contentType,
     out byte[] resultContent)
 {
     return( GetResource( path, out resultCode, out resultReason, out contentType, out resultContent, null, null ) );
 }
        /// <summary>
        ///     Returns the list of resources in the collection.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///    exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="resources">
        ///     The resources contained in the collection, or null if
        ///     there were no resources, or the path did not resolve
        ///     to a collection itself.
        /// </param>
        /// <param name="sizes">
        ///     The sizes of the resources in the collection.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool CollectionContents( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out string[] resources,
            out long[] sizes,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = true;
            sizes = null;
            // Make sure the input parameters are valid.
            if( ( path == null ) || ( path.Length == 0 ) )
            {
                throw new ArgumentException( "Invalid resource path.", "path" );
            }

            // Try to get the properties.
            try
            {
                string[] propertyKeys = new string[] { DavPropertyUtil.DavResourceTypeProp,
                                                     DavPropertyUtil.DavContentLengthProp};

                byte[] content = DavPropertyUtil.GetPropfindRequestContent( propertyKeys );

                string[] propfindHeaders = new string[ 1 ];
                propfindHeaders[ 0 ] = "Depth: 1";

                DavResponse response = SendRequest( path, PropfindRequest,
                    propfindHeaders, XMLTextContent, content );

                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;

                string contentType = (string) response.Headers[ ContentTypeHeader ];
                string resultContent =
                    Encoding.UTF8.GetString( response.Content, 0, response.ContentLength );

                resources = null;

                if( resultCode == WebDavStatusCode.MultiStatus )
                {
                    Hashtable resourceInfo =
                        DavPropertyUtil.ParseMultiStatus( response.Content );

                    if( resourceInfo.Count > 1 )
                    {
                        // Do not return the resource path for the parent.
                        resources = new string[ resourceInfo.Count - 1 ];
                        sizes = new long[ resourceInfo.Count - 1 ];

                        int i = 0;
                        foreach( string resKey in resourceInfo.Keys)
                        {
                            if( !resKey.Equals( path ) )
                            {
                                resources[ i ] = resKey;
                                Hashtable tab = ((Hashtable)((Hashtable)
                                    resourceInfo[resKey])[WebDavStatusCode.OK]);
                                if(tab.ContainsKey( DavPropertyUtil.DavContentLengthProp ))
                                    sizes[i] = long.Parse(tab[DavPropertyUtil.DavContentLengthProp].ToString());
                                else
                                    sizes[i] = -1;

                                i++;
                            }
                        }
                    }
                }
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                resources = null;

                success = false;
            }
            catch( XmlException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                resources = null;

                success = false;
            }

            return( success );
        }
 /// <summary>
 ///     Copies a file on the server to another place on the
 ///     server
 /// </summary>
 /// <param name="source">
 ///     The source path. It must be non-null and contain at
 ///     least one character.
 /// </param>
 /// <param name="destination">
 ///     The destination path. It must be non-null and contain
 ///     at least one character.
 /// </param>
 /// <param name="allowOverwrite">
 ///     Flag to allow overwrite
 /// </param>
 /// <param name="resultCode">
 ///     The result code from the server or BadRequest if an
 ///     exception was thrown.
 /// </param>
 /// <param name="resultReason">
 ///     The result message from the server or the exception
 ///     message if an exception was thrown.
 /// </param>
 /// <param name="contentType">
 ///     The reported type of the content returned from the
 ///     server.
 /// </param>
 /// <param name="resultContent">
 ///     The content of the resource or null if there was an
 ///     error.
 /// </param>
 /// <param name="sendProgress">
 ///     Used to monitor the progress of sending the request.
 /// </param>
 /// <param name="receiveProgress">
 ///     Used to monitor the progress of receiving the response.
 /// </param>
 /// <returns>
 ///     true if the call succeeded, false if a communication
 ///     error prevented the request from succeeding. If true,
 ///     the caller should examine the result code and reason
 ///     to determine whether or not the result content is
 ///     valid.
 /// </returns>
 public bool CopyResource( string source,
     string destination,
     bool allowOverwrite,
     out WebDavStatusCode resultCode,
     out string resultReason,
     out string contentType,
     out byte[] resultContent,
     ProgressContainer sendProgress,
     ProgressContainer receiveProgress)
 {
     return ChangeResourceCmd(CopyRequest,
         source,
         destination,
         allowOverwrite,
         out resultCode,
         out resultReason,
         out contentType,
         out resultContent,
         sendProgress,
         receiveProgress );
 }
        /// <summary>
        /// Make a new collection at the specified path.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool Mkcol( string resourcePath, 
            out WebDavStatusCode resultCode, out string resultReason,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = true;

            // Try to get the resource.
            try
            {
                DavResponse response = SendRequest(resourcePath, MkcolRequest,
                    null, null, null, sendProgress, receiveProgress );

                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;

                success = false;
            }
            return success;
        }
        /// <summary>
        /// Make a new collection at the specified path.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool Mkcol( string resourcePath, 
            out WebDavStatusCode resultCode, out string resultReason)
        {
            bool success = Mkcol( resourcePath, out resultCode, out resultReason, null, null );

            return success;
        }
 /// <summary>
 ///     Determine if the resource at the given path is a
 ///     collection or not.
 /// </summary>
 /// <param name="path">
 ///     The path of the resource. It must be non-null and
 ///     contain at least one character.
 /// </param>
 /// <param name="resultCode">
 ///     The result code from the server or BadRequest if an
 ///     exception was thrown.
 /// </param>
 /// <param name="resultReason">
 ///     The result message from the server or the exception
 ///     message if an exception was thrown.
 /// </param>
 /// <returns>
 ///     true if the call succeeded, false if a communication
 ///     error prevented the request from succeeding. If true,
 ///     the caller should examine the result code and reason
 ///     to determine whether or not the properties are valid.
 /// </returns>
 public bool IsCollection( string path,
     out WebDavStatusCode resultCode,
     out string resultReason,
     out bool isCollection)
 {
     return( IsCollection( path, out resultCode, out resultReason, out isCollection, null, null ) );
 }
        /// <summary>
        ///     Locks a resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest
        ///     if an exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the
        ///     exception message if an exception was thrown.
        /// </param>
        /// <param name="contentType">
        ///     The reported type of the content returned
        ///     from the server.
        /// </param>
        /// <param name="resultContent">
        ///     The content of the resource or null if
        ///     there was an error.
        /// </param>
        /// <param name="lockToken">
        ///     The lock token if the resource is locked or null
        ///     if the resource could not be locked.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication error
        ///     prevented the request from succeeding. If true, the caller should
        ///     examine the result code and reason to determine whether or not the
        ///     result content is valid.
        /// </returns>
        public bool LockResource(string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out string contentType,
            out byte[] resultContent,
            out string lockToken,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            // Local variables
            bool success = true;
            string CR = "\n";
            string xmlFluff = XMLContentPreamble + CR
                + "<D:lockinfo xmlns:D=\"DAV:\">" + CR
                + " <D:lockscope><D:exclusive/></D:lockscope>" + CR
                + " <D:locktype><D:write/></D:locktype>" + CR
                + " <D:owner>" + CR
                + "  <D:href>http://whisper.cse.ucsc.edu:16080/csharp</D:href>" + CR
                + " </D:owner>" + CR
                + "</D:lockinfo>" + CR;
            string[] headers = new string[] {
                                                "Depth: infinity"
                                            };
            lockToken = null;

            // Make sure the input parameters are valid.
            if( ( path == null ) || ( path.Length == 0 ) )
            {
                throw new ArgumentException( "Invalid resource path.", "path" );
            }

            // Try to lock the resource.
            try
            {
                DavResponse response = SendRequest(path, LockRequest, null, XMLTextContent,
                    System.Text.Encoding.UTF8.GetBytes(xmlFluff), sendProgress, receiveProgress );

                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;
                contentType = (string) response.Headers[ ContentTypeHeader ];
                resultContent = response.Content;

                // Extract lock token from XML body
                if (response.StatusCode == WebDavStatusCode.OK)
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                    doc.Load(new System.IO.StringReader(
                        System.Text.Encoding.UTF8.GetString(
                            response.Content, 0, response.ContentLength ) ) );
                    System.Xml.XmlNodeReader xmlReader = new System.Xml.XmlNodeReader(doc);
                    do { xmlReader.Read(); } while (xmlReader.Name != "D:locktoken");
                    do { xmlReader.Read(); } while (xmlReader.Name != "D:href");
                    xmlReader.Read();
                    lockToken = xmlReader.Value.Trim();
                }
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                contentType = null;
                resultContent = null;
                lockToken = null;
                success = false;
            }

            return( success );
        }
        /// <summary>
        ///     Determine if the resource at the given path is a
        ///     collection or not.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool IsCollection( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out bool isCollection,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = false;

            object typeInfo;
            isCollection = false;

            if( GetResourceType( path,
                out resultCode,
                out resultReason,
                out typeInfo,
                sendProgress,
                receiveProgress ) &&
                ( typeInfo != null ) )
            {
                success = true;
                Hashtable typeInfoTable = (Hashtable) typeInfo;
                isCollection =
                    typeInfoTable.ContainsKey( DavPropertyUtil.DavCollectionProp );
            }

            return( success );
        }
        /// <summary>
        ///     Returns the type info associated with a resource. By
        ///     default, resources have an empty resourcetype.
        ///     Collections have an empty sub-element DAV:collection
        ///     to flag the resource as a collection.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="typeInfo">
        ///     The resource type information as stored on the server.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool GetResourceType( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out object typeInfo)
        {
            bool success = Propfind( path, DavPropertyUtil.DavResourceTypeProp,
                out resultCode, out resultReason, out typeInfo );

            return( success );
        }
        /// <summary>
        ///     Returns the type info associated with a resource. By
        ///     default, resources have an empty resourcetype.
        ///     Collections have an empty sub-element DAV:collection
        ///     to flag the resource as a collection.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="typeInfo">
        ///     The resource type information as stored on the server.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool GetResourceType( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out object typeInfo,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = Propfind( path, DavPropertyUtil.DavResourceTypeProp,
                out resultCode, out resultReason, out typeInfo, sendProgress, receiveProgress );

            return( success );
        }
        /// <summary>
        ///     Unlocks a resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="token">
        ///     The resource's lock token as returned by a LOCK request.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest
        ///     if an exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the
        ///     exception message if an exception was thrown.
        /// </param>
        /// <param name="contentType">
        ///     The reported type of the content returned
        ///     from the server.
        /// </param>
        /// <param name="resultContent">
        ///     The content of the resource or null if
        ///     there was an error.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication error
        ///     prevented the request from succeeding. If true, the caller should
        ///     examine the result code and reason to determine whether or not the
        ///     result content is valid.
        /// </returns>
        public bool UnlockResource(string path,
            string token,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out string contentType,
            out byte[] resultContent)
        {
            // Local variables
            bool success = UnlockResource( path, token,
                out resultCode, out resultReason, out contentType, out resultContent, null, null );

            return( success );
        }
        /// <summary>
        ///     Get the specified properties associated with a
        ///     resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="propertyKey">
        ///     The key of the property to be retrieved.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="property">
        ///     A hashtable with the properties of the resource or
        ///     null if there was an error.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool Propfind( string path,
            string propertyKey,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out object property,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            string[] propertyList = new string[] { propertyKey };
            Hashtable properties;

            bool success = Propfind(path,
                propertyList,
                out resultCode,
                out resultReason,
                out properties,
                sendProgress,
                receiveProgress );

            property = null;

            if( success && ( properties != null ) )
            {
                foreach( WebDavStatusCode statusCode in properties.Keys )
                {
                    Hashtable propInfo = (Hashtable) properties[ statusCode ];

                    if( propInfo.ContainsKey( propertyKey ) )
                    {
                        resultCode = (WebDavStatusCode)
                            propInfo[ DavPropertyUtil.DAVSharpReasonCodeKey ];
                        resultReason  = (string)
                            propInfo[ DavPropertyUtil.DAVSharpReasonStringKey ];
                        property = propInfo[ propertyKey ];
                    }
                }
            }

            return( success );
        }
        /// <summary>
        ///     A template for a MOVE or COPY command
        /// </summary>
        /// <param name="command">
        ///     HTTP command to send
        /// </param>
        /// <param name="source">
        ///     The source path. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="destination">
        ///     The destination path. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="allowOverwrite">
        ///     Flag to allow overwrite
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the
        ///     exception message if an exception was thrown.
        /// </param>
        /// <param name="contentType">
        ///     The reported type of the content returned from the
        ///     server.
        /// </param>
        /// <param name="resultContent">
        ///     The content of the resource or null if there was an
        ///     error.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the result content is
        ///     valid.
        /// </returns>
        protected bool ChangeResourceCmd(
            string command,
            string source,
            string destination,
            bool allowOverwrite,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out string contentType,
            out byte[] resultContent,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = true;

            // Make sure the input parameters are valid.
            if( ( source == null ) || ( source.Length == 0 )
                || ( destination == null ) || ( destination.Length == 0 ))
            {
                throw new ArgumentException( "Invalid resource path.", "path" );
            }

            // Try to copy the resource.
            try
            {
                string[] headers = new string[3];
                destination = destination.TrimStart('/');

                headers[0] = "Host: " + this.serverUri.Host;
                headers[1] = "Destination: " + this.serverUri + destination;
                if(allowOverwrite)
                    headers[2] = "Overwrite: T";
                else
                    headers[2] = "Overwrite: F";

                DavResponse response = SendRequest( source, command,
                    headers, null, null, sendProgress, receiveProgress );

                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;
                contentType = (string) response.Headers[ ContentTypeHeader ];
                resultContent = response.Content;
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                contentType = null;
                resultContent = null;

                success = false;
            }

            return( success );
        }
Пример #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDavResult{T}"/> class.
 /// </summary>
 /// <param name="statusCode">The WebDAV status code</param>
 /// <param name="data">The data to be returned in the response body</param>
 public WebDavResult(WebDavStatusCode statusCode, T data)
     : base(statusCode)
 {
     Data = data;
 }
 /// <summary>
 ///     Returns the list of resources in the collection.
 /// </summary>
 /// <param name="path">
 ///     The path of the resource. It must be non-null and
 ///     contain at least one character.
 /// </param>
 /// <param name="resultCode">
 ///     The result code from the server or BadRequest if an
 ///    exception was thrown.
 /// </param>
 /// <param name="resultReason">
 ///     The result message from the server or the exception
 ///     message if an exception was thrown.
 /// </param>
 /// <param name="resources">
 ///     The resources contained in the collection, or null if
 ///     there were no resources, or the path did not resolve
 ///     to a collection itself.
 /// </param>
 /// <returns>
 ///     true if the call succeeded, false if a communication
 ///     error prevented the request from succeeding. If true,
 ///     the caller should examine the result code and reason
 ///     to determine whether or not the properties are valid.
 /// </returns>
 public bool CollectionContents( string path,
     out WebDavStatusCode resultCode,
     out string resultReason,
     out string[] resources)
 {
     return( CollectionContents( path, out resultCode, out resultReason, out resources, null, null ) );
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDavException"/> class.
 /// </summary>
 /// <param name="statusCode">The WebDAV status code</param>
 /// <param name="responseMessage">The reason phrase for the status code</param>
 public WebDavException(WebDavStatusCode statusCode, string responseMessage)
     : base(statusCode.GetReasonPhrase(responseMessage))
 {
     StatusCode = statusCode;
 }
 /// <summary>
 ///     Copies a file on the server to another place on the
 ///     server
 /// </summary>
 /// <param name="source">
 ///     The source path. It must be non-null and contain at
 ///     least one character.
 /// </param>
 /// <param name="destination">
 ///     The destination path. It must be non-null and contain
 ///     at least one character.
 /// </param>
 /// <param name="allowOverwrite">
 ///     Flag to allow overwrite
 /// </param>
 /// <param name="resultCode">
 ///     The result code from the server or BadRequest if an
 ///     exception was thrown.
 /// </param>
 /// <param name="resultReason">
 ///     The result message from the server or the exception
 ///     message if an exception was thrown.
 /// </param>
 /// <param name="contentType">
 ///     The reported type of the content returned from the
 ///     server.
 /// </param>
 /// <param name="resultContent">
 ///     The content of the resource or null if there was an
 ///     error.
 /// </param>
 /// <returns>
 ///     true if the call succeeded, false if a communication
 ///     error prevented the request from succeeding. If true,
 ///     the caller should examine the result code and reason
 ///     to determine whether or not the result content is
 ///     valid.
 /// </returns>
 public bool CopyResource( string source,
     string destination,
     bool allowOverwrite,
     out WebDavStatusCode resultCode,
     out string resultReason,
     out string contentType,
     out byte[] resultContent)
 {
     return CopyResource(
         source,
         destination,
         allowOverwrite,
         out resultCode,
         out resultReason,
         out contentType,
         out resultContent,
         null, null);
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDavException"/> class.
 /// </summary>
 /// <param name="statusCode">The WebDAV status code</param>
 /// <param name="innerException">The inner exception</param>
 public WebDavException(WebDavStatusCode statusCode, [NotNull] Exception innerException)
     : base(statusCode.GetReasonPhrase(innerException.Message), innerException)
 {
     StatusCode = statusCode;
 }
        /// <summary>
        ///     Get a resource from the server.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="contentType">
        ///     The reported type of the content returned from the
        ///     server.
        /// </param>
        /// <param name="resultContent">
        ///     The content of the resource or null if there was an
        ///     error.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the result content is
        ///     valid.
        /// </returns>
        public bool GetResource( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out string contentType,
            out byte[] resultContent,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = true;

            // Make sure the input parameters are valid.
            if( ( path == null ) || ( path.Length == 0 ) )
            {
                throw new ArgumentException( "Invalid resource path.", "path" );
            }

            // Try to get the resource.
            try
            {
                DavResponse response = SendRequest( path, GetRequest, null, null, null, sendProgress, receiveProgress );
                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;
                contentType = (string) response.Headers[ ContentTypeHeader ];
                resultContent = response.Content;
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                contentType = null;
                resultContent = null;

                success = false;
            }

            return( success );
        }
        /// <summary>
        /// Retrieve the names available properties on a resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="propertyNames">
        ///     An array of property names. Just because a property is listed here does
        ///     not mean the caller has permission to retrieve the value.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="resultContent">
        ///     A hashtable with the properties of the resource or
        ///     null if there was an error.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool Propnames( string path, out WebDavStatusCode resultCode,
            out string resultReason, out string[] propertyNames,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = true;

            // Make sure the input parameters are valid.
            if( ( path == null ) || ( path.Length == 0 ) )
            {
                throw new ArgumentException( "Invalid resource path.", "path" );
            }

            // Try to get the properties.
            try
            {
                byte[] content = DavPropertyUtil.GetPropfindNamesRequestContent();

                string[] propfindHeaders = new string[ 1 ];
                propfindHeaders[ 0 ] = "Depth: 0";

                DavResponse response = SendRequest( path, PropfindRequest,
                    propfindHeaders, XMLTextContent, content, sendProgress, receiveProgress );

                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;

                string contentType = (string) response.Headers[ ContentTypeHeader ];
                string resultContent =
                    Encoding.UTF8.GetString( response.Content, 0, response.ContentLength );

                propertyNames = null;

                if( resultCode == WebDavStatusCode.MultiStatus )
                {
                    Hashtable statusTable = (Hashtable)
                        DavPropertyUtil.ParseMultiStatus( response.Content )[ path ];

                    if( statusTable.ContainsKey( WebDavStatusCode.OK ) )
                    {
                        Hashtable availableProps =
                            (Hashtable) statusTable[ WebDavStatusCode.OK ];

                        // Subtract 2 keys (the result code and result string are not props)
                        propertyNames = new string[ availableProps.Count - 2 ];
                        int i = 0;

                        foreach( string prop in availableProps.Keys )
                        {
                            if( !prop.Equals( DavPropertyUtil.DAVSharpReasonCodeKey ) &&
                                !prop.Equals( DavPropertyUtil.DAVSharpReasonStringKey ) )
                            {
                                propertyNames[ i ] = prop;
                                i++;
                            }
                        }
                    }
                }
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                propertyNames = null;

                success = false;
            }
            catch( XmlException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                propertyNames = null;

                success = false;
            }

            return( success );
        }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeleteResult"/> class.
 /// </summary>
 /// <param name="statusCode">The status code for the operation</param>
 /// <param name="failedEntry">The entry of the failed operation</param>
 public DeleteResult(WebDavStatusCode statusCode, IEntry failedEntry)
 {
     FailedEntry = failedEntry;
     StatusCode  = statusCode;
 }
Пример #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDavXmlResult"/> class.
 /// </summary>
 /// <param name="statusCode">The WebDAV status code</param>
 /// <param name="element">The element to be serialized as the response body</param>
 public WebDavXmlResult(WebDavStatusCode statusCode, XElement element)
     : base(statusCode)
 {
     _element = element;
 }
        /// <summary>
        ///     Get the specified properties associated with a
        ///     resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="propertyKey">
        ///     The key of the property to be retrieved.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="property">
        ///     A hashtable with the properties of the resource or
        ///     null if there was an error.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool Propfind( string path,
            string propertyKey,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out object property)
        {
            bool success = Propfind(path,
                propertyKey,
                out resultCode,
                out resultReason,
                out property,
                null,
                null);

            return( success );
        }
Пример #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDavException"/> class.
 /// </summary>
 /// <param name="statusCode">The WebDAV status code</param>
 public WebDavException(WebDavStatusCode statusCode)
     : base(statusCode.GetReasonPhrase())
 {
     StatusCode = statusCode;
 }
 /// <summary>
 /// Initializes a new instance of WebDavResponseMessage.
 /// </summary>
 /// <param name="statusCode">The request's <see cref="WebDavStatusCode"/>.</param>
 public WebDavResponseMessage(WebDavStatusCode statusCode)
     : base((HttpStatusCode)statusCode)
 {
 }
        /// <summary>
        ///     Get all properties associated with a resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="resultContent">
        ///     A hashtable with the properties of the resource or
        ///     null if there was an error.
        /// </param>
        /// <param name="sendProgress">
        ///     Used to monitor the progress of sending the request.
        /// </param>
        /// <param name="receiveProgress">
        ///     Used to monitor the progress of receiving the response.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool PropfindAll( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out Hashtable properties,
            ProgressContainer sendProgress,
            ProgressContainer receiveProgress)
        {
            bool success = true;
            Hashtable prop = new Hashtable();

            // Make sure the input parameters are valid.
            if( ( path == null ) || ( path.Length == 0 ) )
            {
                throw new ArgumentException( "Invalid resource path.", "path" );
            }

            // Try to get the properties.
            try
            {
                byte[] content = DavPropertyUtil.GetPropfindAllRequestContent();

                string[] propfindHeaders = new string[ 1 ];
                propfindHeaders[ 0 ] = "Depth: 1";

                DavResponse response = SendRequest( path, PropfindRequest,
                    propfindHeaders, XMLTextContent, content, sendProgress, receiveProgress );

                // Extract the response data for the caller.
                resultCode = response.StatusCode;
                resultReason = response.StatusReason;

                string contentType = (string) response.Headers[ ContentTypeHeader ];
                string resultContent =
                    Encoding.UTF8.GetString( response.Content, 0, response.ContentLength );

                if( resultCode == WebDavStatusCode.MultiStatus )
                {
                    DavPropertyUtil.ParseMultiStatus( response.Content, prop );
                    properties = prop;
                }
                else
                {
                    properties = null;
                }
            }
            catch( SocketException e )
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                properties = null;

                success = false;
            }
            catch (XmlException e)
            {
                // Flag an exception as a bad request and send the exception message
                // back to the caller.
                resultCode = WebDavStatusCode.BadRequest;
                resultReason = e.Message;
                properties = null;
                success = false;
            }
            return( success );
        }
Пример #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDavResult"/> class.
 /// </summary>
 /// <param name="statusCode">The WebDAV status code</param>
 public WebDavResult(WebDavStatusCode statusCode)
 {
     StatusCode = statusCode;
 }
        /// <summary>
        ///     Get all properties associated with a resource.
        /// </summary>
        /// <param name="path">
        ///     The path of the resource. It must be non-null and
        ///     contain at least one character.
        /// </param>
        /// <param name="resultCode">
        ///     The result code from the server or BadRequest if an
        ///     exception was thrown.
        /// </param>
        /// <param name="resultReason">
        ///     The result message from the server or the exception
        ///     message if an exception was thrown.
        /// </param>
        /// <param name="resultContent">
        ///     A hashtable with the properties of the resource or
        ///     null if there was an error.
        /// </param>
        /// <returns>
        ///     true if the call succeeded, false if a communication
        ///     error prevented the request from succeeding. If true,
        ///     the caller should examine the result code and reason
        ///     to determine whether or not the properties are valid.
        /// </returns>
        public bool PropfindAll( string path,
            out WebDavStatusCode resultCode,
            out string resultReason,
            out Hashtable properties)
        {
            bool success = PropfindAll( path, out resultCode, out resultReason, out properties, null, null );

            return( success );
        }