Пример #1
0
        /// <summary>
        /// Gets the file collection as a dictionary of file containers
        /// </summary>
        /// <param name="postedData">The HTTP posted data</param>
        /// <returns>The file container dictionary</returns>
        public static Dictionary <string, FileContainer> AsFileContainerDictionary
        (
            this HttpPostedData postedData
        )
        {
            Validate.IsNotNull(postedData);

            var dictionary = new Dictionary <string, FileContainer>();

            foreach (var item in postedData.Files)
            {
                var file = item.Value;

                if (file.FileContents.Length > 0)
                {
                    var container = new FileContainer
                                    (
                        file.FileContents,
                        file.ContentType,
                        file.Filename
                                    );

                    dictionary.Add
                    (
                        item.Key,
                        container
                    );
                }
            }

            return(dictionary);
        }
        /// <summary>
        /// Gets the field collection as a name value collection
        /// </summary>
        /// <param name="postedData">The HTTP posted data</param>
        /// <returns>The name value collection</returns>
        public static NameValueCollection AsNameValueCollection(this HttpPostedData postedData)
        {
            Validate.IsNotNull(postedData);

            var collection = new NameValueCollection();

            foreach (var item in postedData.Fields)
            {
                var field = item.Value;

                collection.Add(field.Name, field.Value);
            }

            return(collection);
        }