Example #1
0
        private static _mime Normalize(string mime)
        {
            var result = new _mime();
            var spl    = mime.Split(';').Select(a => a.Trim()).ToArray();

            result.Type = spl[0];
            foreach (var line in spl.Skip(1))
            {
                var linesplit = line.Split(new char[] { '=' }, 2);
                if (linesplit.Length == 1)
                {
                    result.Values[linesplit[0]] = "";
                }
                else
                {
                    var val = linesplit[1];
                    if (val.StartsWith("\"") && val.EndsWith("\""))
                    {
                        val = val.Substring(1, val.Length - 2);
                    }

                    result.Values[linesplit[0]] = val;
                }
            }

            return(result);
        }
Example #2
0
        private static bool _equal(string mimetype, _mime mold)
        {
            var  made    = Normalize(mimetype.Trim());
            bool isEqual = made.Type == mold.Type;

            foreach (var val in mold.Values)
            {
                isEqual = isEqual && made.Values.ContainsKey(val.Key) && made.Values[val.Key] == val.Value;
            }

            return(isEqual);
        }