/// <summary>
        /// Generates a web request to return a listing of all files and subdirectories in the directory.
        /// </summary>
        /// <param name="uri">The absolute URI to the share.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="listingContext">A set of parameters for the listing operation.</param>
        /// <param name="shareSnapshot">A <see cref="DateTimeOffset"/> specifying the share snapshot timestamp, if the share is a snapshot.</param>
        /// <param name="useVersionHeader">A flag indicating whether to set the x-ms-version HTTP header.</param>
        /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
        /// <returns>A web request to use to perform the operation.</returns>
        internal static HttpWebRequest List(Uri uri, int?timeout, FileListingContext listingContext, DateTimeOffset?shareSnapshot, bool useVersionHeader, OperationContext operationContext)
        {
            UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder();

            DirectoryHttpWebRequestFactory.AddShareSnapshot(directoryBuilder, shareSnapshot);
            directoryBuilder.Add(Constants.QueryConstants.Component, "list");

            if (listingContext != null)
            {
                if (listingContext.Marker != null)
                {
                    directoryBuilder.Add("marker", listingContext.Marker);
                }

                if (listingContext.MaxResults.HasValue)
                {
                    directoryBuilder.Add("maxresults", listingContext.MaxResults.ToString());
                }

                if (listingContext.Prefix != null)
                {
                    directoryBuilder.Add("prefix", listingContext.Prefix);
                }
            }

            HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, directoryBuilder, useVersionHeader, operationContext);

            return(request);
        }
        /// <summary>
        /// Generates a web request to return the user-defined metadata for this directory.
        /// </summary>
        /// <param name="uri">The absolute URI to the directory.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="shareSnapshot">A <see cref="DateTimeOffset"/> specifying the share snapshot timestamp, if the share is a snapshot.</param>
        /// <param name="accessCondition">The access condition to apply to the request.</param>
        /// <param name="useVersionHeader">A flag indicating whether to set the x-ms-version HTTP header.</param>
        /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
        /// <returns>A web request to use to perform the operation.</returns>
        internal static HttpWebRequest GetMetadata(Uri uri, int?timeout, DateTimeOffset?shareSnapshot, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext)
        {
            UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder();

            DirectoryHttpWebRequestFactory.AddShareSnapshot(directoryBuilder, shareSnapshot);

            HttpWebRequest request = HttpWebRequestFactory.GetMetadata(uri, timeout, directoryBuilder, useVersionHeader, operationContext);

            request.ApplyAccessCondition(accessCondition);
            return(request);
        }
예제 #3
0
파일: FileTests.cs 프로젝트: Ankitvaibs/SM
        public static HttpWebRequest ListFilesAndDirectoriesRequest(FileContext context, string shareName, FileListingContext listingContext)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address, shareName);
            OperationContext opContext = new OperationContext();
            HttpWebRequest   request   = DirectoryHttpWebRequestFactory.List(uri, context.Timeout, listingContext, true, opContext);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual("GET", request.Method);
            FileTestUtils.RangeHeader(request, null);
            return(request);
        }
 /// <summary>
 /// Generates a web request to return the properties and user-defined metadata for this directory.
 /// </summary>
 /// <param name="uri">The absolute URI to the directory.</param>
 /// <param name="timeout">The server timeout interval.</param>
 /// <param name="accessCondition">The access condition to apply to the request.</param>
 /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param>
 /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
 /// <returns>A <see cref="System.Net.HttpWebRequest"/> object.</returns>
 public static HttpWebRequest GetProperties(Uri uri, int?timeout, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext)
 {
     return(DirectoryHttpWebRequestFactory.GetProperties(uri, timeout, null /* shareSnapshot */, accessCondition, useVersionHeader, operationContext));
 }
 /// <summary>
 /// Generates a web request to return a listing of all files and subdirectories in the directory.
 /// </summary>
 /// <param name="uri">The absolute URI to the share.</param>
 /// <param name="timeout">The server timeout interval.</param>
 /// <param name="listingContext">A set of parameters for the listing operation.</param>
 /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param>
 /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
 /// <returns>A <see cref="System.Net.HttpWebRequest"/> object.</returns>
 public static HttpWebRequest List(Uri uri, int?timeout, FileListingContext listingContext, bool useVersionHeader, OperationContext operationContext)
 {
     return(DirectoryHttpWebRequestFactory.List(uri, timeout, listingContext, null /* shareSnapshot */, useVersionHeader, operationContext));
 }