using System.Collections.Generic;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        public class ListMimeByExtension : MyList
        {
            public ListMimeByExtension(State MyState)
                : base(MyState, "Mime Types")
            {
                if (Mime.mimemap.Count == 0) Mime.BuildMimeMap();
                foreach (string key in Mime.mimemap)
                {
                    Add(key, Mime.mimemap[key]);
                }
            }
        }
        public class ListMimeByType : MyList
        {
            public ListMimeByType(State MyState)
                : base(MyState, "Mime Types")
            {
                if (Mime.mimemap.Count == 0) Mime.BuildMimeMap();
                List<string> Types = new List<string>();
                for (int i = 0; i < Mime.mimemap.Count; i++)
                {
                    if (!Types.Contains(Mime.mimemap[i]))
                        Types.Add(Mime.mimemap[i]);
                }
                Types.Sort();
                foreach (string Type in Types)
                {
                    string s = "";
                    for (int i = 0; i < Mime.mimemap.Count; i++)
                    {
                        if (Mime.mimemap[i] == Type)
                            s += (s == "" ? "" : ", ") + Mime.mimemap.Keys[i];
                    }
                    Add(Type, s);
                }
            }
        }
    }
}