Example #1
0
 /// <summary>Read Element named magic. </summary>
 private void  ReadMagic(System.Xml.XmlElement element, MimeType mimeType)
 {
     // element.getValue();
     System.String offset             = null;
     System.String content            = null;
     System.String type               = null;
     System.Xml.XmlNamedNodeMap attrs = (System.Xml.XmlAttributeCollection)element.Attributes;
     for (int i = 0; i < attrs.Count; i++)
     {
         System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute)attrs.Item(i);
         if (attr.Name.Equals("offset"))
         {
             offset = attr.Value;
         }
         else if (attr.Name.Equals("type"))
         {
             type = attr.Value;
             if (String.Compare(type, "byte", true) == 0)
             {
                 type = "System.Byte";
             }
         }
         else if (attr.Name.Equals("value"))
         {
             content = attr.Value;
         }
     }
     if ((offset != null) && (content != null))
     {
         mimeType.AddMagic(System.Int32.Parse(offset), type, content);
     }
 }
Example #2
0
        /// <summary>Read Element named magic. </summary>
        private static void ReadMagic(XmlElement element, MimeType mimeType)
        {
            string offset  = null;
            string content = null;
            string type    = null;
            var    attrs   = element.Attributes;

            for (var i = 0; i < attrs.Count; i++)
            {
                var attr = (XmlAttribute)attrs.Item(i);

                if (attr.Name.Equals("offset"))
                {
                    offset = attr.Value;
                }
                else if (attr.Name.Equals("type"))
                {
                    type = attr.Value;
                    if (string.Compare(type, "byte", true) == 0)
                    {
                        type = "System.Byte";
                    }
                }
                else if (attr.Name.Equals("value"))
                {
                    content = attr.Value;
                }
            }

            if ((offset != null) && (content != null))
            {
                mimeType.AddMagic(Int32.Parse(offset), type, content);
            }
        }