コード例 #1
0
        private bool ValidateMimeType(string mimeType)
        {
            if (string.IsNullOrWhiteSpace(mimeType))
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(this.Accept))
            {
                return(true);
            }

            foreach (string item in this.Accept.Split(','))
            {
                if (string.Compare(item, mimeType, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(true);
                }
                else if (mimeType.IndexOf(item.Replace("*", string.Empty), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(true);
                }
                else
                {
                    string fileExtension = MimeType.GetExtension(mimeType);

                    if (string.Compare(item, fileExtension, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }