private void ParseAttributeDefinition(string strLine) { if (strLine.StartsWith("BA_DEF_DEF_")) { return; } Regex re = new Regex(@"BA_DEF_\s+(?<objType>\S+)?\s*""(?<name>\S+)""\s+(?<attriValType>\S+)\s*(?<attrDef>.+)?\s*;"); string strObjType = re.Match(strLine).Groups["objType"].Value; string name = re.Match(strLine).Groups["name"].Value; string strAttriValType = re.Match(strLine).Groups["attriValType"].Value; string attrDef = re.Match(strLine).Groups["attrDef"].Value; DBCObjType objType = DBCObjType.DBCObjBase; if (strObjType.Contains("BU_")) { objType = DBCObjType.Node; } else if (strObjType.Contains("BO_")) { objType = DBCObjType.Message; } else if (strObjType.Contains("SG_")) { objType = DBCObjType.Signal; } AttriValType valType = AttriValType.STRING; if (strAttriValType.Contains("INT")) { valType = AttriValType.INT; } else if (strAttriValType.Contains("HEX")) { valType = AttriValType.HEX; } else if (strAttriValType.Contains("FLOAT")) { valType = AttriValType.FLOAT; } else if (strAttriValType.Contains("ENUM")) { valType = AttriValType.ENUM; } else if (strAttriValType.Contains("STRING")) { valType = AttriValType.STRING; } Regex re1; string strMin, strMax; switch (valType) { case AttriValType.INT: re1 = new Regex(@"\s*(?<min>\S+)\s*(?<max>\S+)"); strMin = re1.Match(attrDef).Groups["min"].Value; strMax = re1.Match(attrDef).Groups["max"].Value; IntDBCAttributeDefinition attributeInt = new IntDBCAttributeDefinition(name, objType, int.Parse(strMin), int.Parse(strMax)); _netWork.AddAttributeDef(attributeInt); break; case AttriValType.HEX: re1 = new Regex(@"\s*(?<min>\S+)\s*(?<max>\S+)"); strMin = re1.Match(attrDef).Groups["min"].Value; strMax = re1.Match(attrDef).Groups["max"].Value; HexDBCAttributeDefinition attributeHex = new HexDBCAttributeDefinition(name, objType, uint.Parse(strMin), uint.Parse(strMax)); _netWork.AddAttributeDef(attributeHex); break; case AttriValType.FLOAT: re1 = new Regex(@"\s*(?<min>\S+)\s*(?<max>\S+)"); strMin = re1.Match(attrDef).Groups["min"].Value; strMax = re1.Match(attrDef).Groups["max"].Value; FloatDBCAttributeDefinition attributeFloat = new FloatDBCAttributeDefinition(name, objType, double.Parse(strMin), double.Parse(strMax)); _netWork.AddAttributeDef(attributeFloat); break; case AttriValType.ENUM: string[] parts = attrDef.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <string> partl = new List <string>(); foreach (string item in parts) { partl.Add(item.Replace("\"", "").Trim()); } EnumDBCAttributeDefinition attributeEnum = new EnumDBCAttributeDefinition(name, objType, partl); _netWork.AddAttributeDef(attributeEnum); break; case AttriValType.STRING: StringDBCAttributeDefinition attributeString = new StringDBCAttributeDefinition(name, objType); _netWork.AddAttributeDef(attributeString); break; } }