Пример #1
0
        /// <summary>
        /// Parse a node for data types (primitive, complex, useType)
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected static AbstractNode ParseNode(XmlTextReader reader)
        {
            AbstractNode it        = null;
            string       byteOrder = reader.GetAttribute("byteOrder");

            if (reader.LocalName.Equals("struct"))
            {
                it = LoadStruct(reader);
            }
            else if (reader.LocalName.Equals("union"))
            {
                it = LoadUnion(reader);
            }
            else if (reader.LocalName.StartsWith("array"))
            {
                it = LoadArray(reader);
            }
            else if (reader.LocalName.Equals("useType"))
            {
                string typeName  = reader.GetAttribute("typeName");
                string blockSize = reader.GetAttribute("blockSize");
                it = new UseTypeNode(typeName);
                if (blockSize != null)
                {
                    ((UseTypeNode)it).setBlockSize(Convert.ToInt16(blockSize));
                }
                string varName = reader.GetAttribute("varName");
                it.setVarName(varName);
            }
            else                //primitive
            {
                string varName = reader.GetAttribute("varName");
                it = new PrimitiveNode(reader.LocalName);
                if (varName != null)
                {
                    it.setVarName(varName);
                }
            }
            if (byteOrder != null)
            {
                it.setBigEndian((byteOrder.Equals("bigEndian"))?true:false);
            }
            return(it);
        }
Пример #2
0
 /// <summary>
 /// Parse a node for data types (primitive, complex, useType)
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 protected static AbstractNode ParseNode(XmlTextReader reader)
 {
     AbstractNode it = null;
     string byteOrder = reader.GetAttribute("byteOrder");
     if (reader.LocalName.Equals("struct"))
     {
         it = LoadStruct(reader);
     }
     else if (reader.LocalName.Equals("union"))
     {
         it = LoadUnion(reader);
     }
     else if (reader.LocalName.StartsWith("array"))
     {
         it = LoadArray(reader);
     }
     else if (reader.LocalName.Equals("useType"))
     {
         string typeName = reader.GetAttribute("typeName");
         string blockSize = reader.GetAttribute("blockSize");
         it = new UseTypeNode(typeName);
         if (blockSize != null)
         {
             ((UseTypeNode)it).setBlockSize( Convert.ToInt16(blockSize) );
         }
         string varName = reader.GetAttribute("varName");
         it.setVarName( varName );
     }
     else	//primitive
     {
         string varName = reader.GetAttribute("varName");
         it = new PrimitiveNode(reader.LocalName);
         if (varName!=null)
         {
             it.setVarName( varName );
         }
     }
     if (byteOrder != null)
     {
         it.setBigEndian( (byteOrder.Equals("bigEndian"))?true:false );
     }
     return it;
 }