private void ParseProperty(SymbolDef current, PropertyDef prop, XmlNode node) { TypeDef type = prop.Type; switch (type.Name) { case "TEXT": case "MLTEXT": { int stringLen = reader.ReadInt32(); string s; if (stringLen <= 0) { s = ""; } else { s = TextDecode.Decode(reader.ReadBytes(stringLen)); } AddProp(current, prop, s, node); } break; case "ULONG": { uint uv = reader.ReadUInt32(); AddProp(current, prop, Convert.ToString(uv), node); } break; case "LONG": { int v = reader.ReadInt32(); AddProp(current, prop, Convert.ToString(v), node); } break; case "LONG2": { int v1 = reader.ReadInt32(); int v2 = reader.ReadInt32(); AddProp(current, prop, v1 + "," + v2, node); } break; case "LONG4": { int v1 = reader.ReadInt32(); int v2 = reader.ReadInt32(); int v3 = reader.ReadInt32(); int v4 = reader.ReadInt32(); AddProp(current, prop, v1 + "," + v2 + "," + v3 + "," + v4, node); } break; case "BOOL": { int v = reader.ReadInt32(); AddProp(current, prop, (v == 1) ? "true" : "false", node); } break; case "FLOAT": { float f = reader.ReadSingle(); AddProp(current, prop, f.ToString(DEC_FORMAT), node); } break; case "FLOAT2": { float f1 = reader.ReadSingle(); float f2 = reader.ReadSingle(); AddProp(current, prop, f1.ToString(DEC_FORMAT) + "," + f2.ToString(DEC_FORMAT), node); } break; case "FLOAT4": { float f1 = reader.ReadSingle(); float f2 = reader.ReadSingle(); float f3 = reader.ReadSingle(); float f4 = reader.ReadSingle(); AddProp(current, prop, f1.ToString(DEC_FORMAT) + "," + f2.ToString(DEC_FORMAT) + "," + f3.ToString(DEC_FORMAT) + "," + f4.ToString(DEC_FORMAT), node); } break; case "DOUBLE": { double v = reader.ReadDouble(); AddProp(current, prop, v.ToString(DEC_FORMAT), node); } break; case "BYTE4": { byte b1 = reader.ReadByte(); byte b2 = reader.ReadByte(); byte b3 = reader.ReadByte(); byte b4 = reader.ReadByte(); AddProp(current, prop, b1 + "," + b2 + "," + b3 + "," + b4, node); } break; case "GUID": { byte[] gd = reader.ReadBytes(16); Guid g = new Guid(gd); if (models != null) { string modelName = models.Lookup(g); if (modelName != null) { XmlComment com = doc.CreateComment("Model: " + modelName); node.AppendChild(com); } } AddProp(current, prop, "{" + new Guid(gd).ToString().ToUpper() + "}", node); } break; case "PBH": case "PBH32": { double p = reader.ReadUInt32() / ((double)65536 * 65536) * 360.0; double b = reader.ReadUInt32() / ((double)65536 * 65536) * 360.0; double h = reader.ReadUInt32() / ((double)65536 * 65536) * 360.0; // pad reader.ReadInt32(); AddProp(current, prop, p.ToString(DEC_FORMAT) + "," + b.ToString(DEC_FORMAT) + "," + h.ToString(DEC_FORMAT), node); } break; case "ENUM": { EnumDef enumDef = prop.Enum; if (enumDef == null) { throw new SPBException("Enum type without values"); } int idx = reader.ReadInt32(); string val = enumDef[idx]; AddProp(current, prop, val, node); } break; case "LLA": { long lat = reader.ReadInt64(); long lon = reader.ReadInt64(); uint alt1 = reader.ReadUInt32(); int alt2 = reader.ReadInt32(); LLA l = new LLA(lat, lon, alt1, alt2); AddProp(current, prop, l.ToString("D2"), node); } break; case "FILETIME": { // TODO: filetime } break; default: throw new SPBException("Don't know how to format type " + type.Type + " at " + reader.BaseStream.Position); } }
public void AddProperty(PropertyDef prop) { AddAndCheck(prop); }