コード例 #1
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
 public HexViewDataType(BuiltInDataType builtInDataType)
 {
     Name      = builtInDataType.ToString();
     ByteCount = HexViewDataType.getBuiltInTypeByteCount(builtInDataType);
 }
コード例 #2
0
ファイル: HexView.cs プロジェクト: principal6/HexDiff
        private bool constructDataTypeInternal(ref HexViewDataType currDataType, XmlNode xmlNode)
        {
            XmlNode attrName = xmlNode.Attributes.GetNamedItem("Name");

            if (attrName != null)
            {
                currDataType.Alias = attrName.Value;
            }

            XmlNode attrType = xmlNode.Attributes.GetNamedItem("Type");

            if (attrType != null)
            {
                BuiltInDataType builtInType = HexViewDataType.stringToBuiltInDataType(attrType.Value);
                if (builtInType == BuiltInDataType.Wrapper)
                {
                    HexViewDataType found = findDataType(attrType.Value);
                    if (found == null)
                    {
                        MessageBox.Show("해당 데이터 타입이 선언되지 않았습니다. 선언 순서를 지켰습니까?", "사용자 정의 자료형 파싱 실패");
                        return(false);
                    }
                    else
                    {
                        currDataType.Name      = found.Name;
                        currDataType.Children  = found.Children;
                        currDataType.ByteCount = found.ByteCount;
                    }
                }
                else
                {
                    currDataType.Name      = builtInType.ToString();
                    currDataType.ByteCount = HexViewDataType.getBuiltInTypeByteCount(builtInType);
                }
            }

            // 자식이 있는 경우 자식의 ByteCount 를 누적한 게 내 ByteCount 가 된다!
            if (currDataType.Children != null)
            {
                foreach (HexViewDataType childNode in currDataType.Children)
                {
                    currDataType.ByteCount += childNode.ByteCount;
                }
            }

            XmlNode attrContent = xmlNode.Attributes.GetNamedItem("Content");

            if (attrContent != null)
            {
                currDataType.Content = attrContent.Value;
            }

            XmlNode attrFormat = xmlNode.Attributes.GetNamedItem("Format");

            if (attrFormat != null)
            {
                currDataType.Format = attrFormat.Value;
            }

            return(true);
        }