ToArray() 공개 정적인 메소드

Obtains an array containing all the elements of the collection.
public static ToArray ( ICollection c, Object objects ) : Object[]
c ICollection
objects Object The array into which the elements of the collection will be stored.
리턴 Object[]
        /// <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);
        }
예제 #2
0
        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]));
        }