Skip to content

Commit

Permalink
When writing user defined properties, add a DictionaryProperty before…
Browse files Browse the repository at this point in the history
… writing the actual properties
  • Loading branch information
Numpsy committed Feb 23, 2024
1 parent 0bc739c commit 3a2aff0
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ public void Save(CFStream cfStream)

ps.PropertySet1 = new PropertySet
{
NumProperties = (uint)this.UserDefinedProperties.Properties.Count(),
// Number of user defined properties, plus 1 for the name dictionary
NumProperties = (uint)this.UserDefinedProperties.Properties.Count() + 1,
PropertyIdentifierAndOffsets = new List<PropertyIdentifierAndOffset>(),
Properties = new List<Interfaces.IProperty>(),
PropertyContext = UserDefinedProperties.Context
Expand All @@ -251,13 +252,21 @@ public void Save(CFStream cfStream)
ps.FMTID1 = new Guid(WellKnownFMTID.FMTID_UserDefinedProperties);
ps.Offset1 = 0;

// Add the dictionary containing the property names
IDictionaryProperty dictionaryProperty = new DictionaryProperty(ps.PropertySet1.PropertyContext.CodePage)
{
Value = this.UserDefinedProperties.PropertyNames
};
ps.PropertySet1.Properties.Add(dictionaryProperty);
ps.PropertySet1.PropertyIdentifierAndOffsets.Add(new PropertyIdentifierAndOffset() { PropertyIdentifier = 0, Offset = 0 });

// Add the properties themselves
foreach (var op in this.UserDefinedProperties.Properties)
{
ITypedPropertyValue p = PropertyFactory.Instance.NewProperty(op.VTType, ps.PropertySet1.PropertyContext.CodePage);
p.Value = op.Value;
ps.PropertySet1.Properties.Add(p);
ps.PropertySet1.PropertyIdentifierAndOffsets.Add(new PropertyIdentifierAndOffset() { PropertyIdentifier = op.PropertyIdentifier, Offset = 0 });

}
}

Expand Down

0 comments on commit 3a2aff0

Please sign in to comment.