/// <summary> /// Reads the Properties dictionary and relates each one to its owning class. /// </summary> /// <param name="ms"></param> /// <param name="owner"></param> protected void ReadProperties(Stream ms, NdfBinary owner) { NdfFooterEntry propEntry = owner.Footer.Entries.Single(x => x.Name == "PROP"); ms.Seek(propEntry.Offset, SeekOrigin.Begin); int i = 0; var buffer = new byte[4]; while (ms.Position < propEntry.Offset + propEntry.Size) { var property = new NdfProperty(i); ms.Read(buffer, 0, buffer.Length); int strLen = BitConverter.ToInt32(buffer, 0); var strBuffer = new byte[strLen]; ms.Read(strBuffer, 0, strBuffer.Length); property.Name = Encoding.GetEncoding("ISO-8859-1").GetString(strBuffer); ms.Read(buffer, 0, buffer.Length); NdfClass cls = owner.Classes.Single(x => x.Id == BitConverter.ToUInt32(buffer, 0)); property.Class = cls; cls.Properties.Add(property); i++; } }
protected void ReadProperties() { var propEntry = Footer.Entries.Single(x => x.Name == "PROP"); //TODO: int cast is a bit too hacky here, solution needed using (var ms = new MemoryStream(ContentData, (int)propEntry.Offset - 40, (int)propEntry.Size)) { int i = 0; var buffer = new byte[4]; while (ms.Position < ms.Length) { var property = new NdfProperty { Offset = ms.Position, Id = i }; ms.Read(buffer, 0, buffer.Length); var strLen = BitConverter.ToInt32(buffer, 0); var strBuffer = new byte[strLen]; ms.Read(strBuffer, 0, strBuffer.Length); property.Name = Encoding.GetEncoding("ISO-8859-1").GetString(strBuffer); ms.Read(buffer, 0, buffer.Length); var cls = Classes.Single(x => x.Id == BitConverter.ToInt32(buffer, 0)); property.Class = cls; cls.Properties.Add(property); i++; } } }