internal Magic(int offset, string type, string magic) { _offset = offset; if ((type != null) && (type.Equals("System.Byte"))) { _magic = ReadBytes(magic); } else { _magic = SupportUtil.ToByteArray(magic); } }
/// <summary> Returns an array of matching MimeTypes from the specified name /// (many MimeTypes can have the same registered extensions). /// </summary> private MimeType[] GetMimeTypes(String name) { IList mimeTypes = null; int index = name.LastIndexOf('.'); if ((index != -1) && (index != name.Length - 1)) { // There's an extension, so try to find // the corresponding mime-types String ext = name.Substring(index + 1); mimeTypes = (IList)_extIdx[ext.ToLower()]; } return ((mimeTypes != null) ? (MimeType[])SupportUtil.ToArray(mimeTypes, new MimeType[mimeTypes.Count]) : null); }
private MimeType[] ReadMimeTypes(XmlElement element) { ArrayList types = new ArrayList(); XmlNodeList nodes = element.ChildNodes; for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes.Item(i); if (Convert.ToInt16(node.NodeType) == (short)XmlNodeType.Element) { XmlElement nodeElement = (XmlElement)node; if (nodeElement.Name.Equals("mime-type")) { MimeType type = ReadMimeType(nodeElement); if (type != null) { types.Add(type); } } } } return((MimeType[])SupportUtil.ToArray(types, new MimeType[types.Count])); }