예제 #1
0
        internal UploadProfileElement GetUploadProfileElement(string uploadProfile, bool throwIfNotExists)
        {
            // TODO: figure out why this doesn't work with merged config
            if (string.IsNullOrEmpty(uploadProfile))
            {
                uploadProfile = DefaultProfile;
            }

            if (string.IsNullOrEmpty(uploadProfile))
            {
                if (Count == 1)
                {
                    return(this[0]);
                }
                else if (throwIfNotExists)
                {
                    throw new Exception("Either defaultProfile or a per-request uploadProfile must be specified when more than one uploadProfile exists.");
                }
            }
            else
            {
                UploadProfileElement profile = this[uploadProfile];

                if (profile != null)
                {
                    return(profile);
                }
                else if (throwIfNotExists)
                {
                    throw new Exception("Couldn't find uploadProfile '" + uploadProfile + "'.");
                }
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Adds a <see cref="UploadProfileElement" /> object to the collection.
        /// </summary>
        /// <param name="element">The <see cref="UploadProfileElement" /> to add.</param>
        public void Add(UploadProfileElement element)
        {
            if (element != null)
            {
                //element.UpdatePropertyCollection();

                BaseAdd(element);
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a <see cref="UploadProfileElement" /> object to the collection.
        /// </summary>
        /// <param name="element">The <see cref="UploadProfileElement" /> to add.</param>
        public void Add(UploadProfileElement element)
        {
            if (element != null)
            {
                //element.UpdatePropertyCollection();

                BaseAdd(element);
            }
        }
예제 #4
0
 /// <summary>
 /// Returns the index of the specified <see cref="UploadProfileElement" /> within the collection.
 /// </summary>
 /// <param name="element">The <see cref="UploadProfileElement" /> for which to return the specified index location.</param>
 /// <returns>The index of the specified <see cref="UploadProfileElement" />; otherwise, -1.</returns>
 public int IndexOf(UploadProfileElement element)
 {
     return BaseIndexOf(element);
 }
예제 #5
0
        static void WriteResponse(HttpContext context, string response, UploadProfileElement profileElement)
        {
            if (string.Equals(context.Request.Headers["X-Requested-With"], "XMLHttpRequest", StringComparison.InvariantCultureIgnoreCase))
            {
                context.Response.ContentType = "application/json";

                context.Response.Write(response);
            }
            else
            {
                string documentDomain = null;

                if (profileElement == null)
                    profileElement = SlickUploadContext.Config.UploadProfiles.GetUploadProfileElement(null, false);

                if (profileElement != null && !string.IsNullOrEmpty(profileElement.DocumentDomain))
                    documentDomain = "document.domain=\"" + profileElement.DocumentDomain + "\";\r\n";

                context.Response.ContentType = "text/html";
                // TODO: implement progress thunk
                context.Response.Write("<html><head><script type=\"text/javascript\">" + documentDomain + "if (parent.kw && parent.kw._uploadFrameLoaded) { parent.kw._uploadFrameLoaded(" + response + "); }</script></head><body></body></html>");
            }
        }
예제 #6
0
 /// <summary>
 /// Returns the index of the specified <see cref="UploadProfileElement" /> within the collection.
 /// </summary>
 /// <param name="element">The <see cref="UploadProfileElement" /> for which to return the specified index location.</param>
 /// <returns>The index of the specified <see cref="UploadProfileElement" />; otherwise, -1.</returns>
 public int IndexOf(UploadProfileElement element)
 {
     return(BaseIndexOf(element));
 }