-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a helper function to add user defined properties to the user defined properties container. #190
Conversation
/// <returns>The new property, of null if this container can't contain user defined properties.</returns> | ||
public OLEProperty AddUserDefinedProperty(VTPropertyType vtPropertyType, string name) | ||
{ | ||
if (this.ContainerType != ContainerType.UserDefinedProperties) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it could be done so that calls against a DocumentSummaryInfo container forward on to the contained UserDefinedProperties container. (Now that there is a CreateUserDefinedProperties() function, it could even create the UserDefinedProperties container if there isn't one already)
I think that an exception is more linear and makes things easier to spot if this behaviour appears as a wrong action (>90% cases I suppose) |
d0c819d
to
0135b53
Compare
|
||
// As per https://learn.microsoft.com/en-us/openspecs/windows_protocols/MS-OLEPS/4177a4bc-5547-49fe-a4d9-4767350fd9cf | ||
// the property names have to be unique, and are case insensitive. | ||
if (this.PropertyNames.Any(property => property.Value.Equals(name, StringComparison.InvariantCultureIgnoreCase))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually sure if the uniqueness of the user defined property names needs to consider locales / cultures here?
a0c22f9
to
0cdb887
Compare
Refs comments in #104 - I think it'd be useful to have a built in function that handles the management of property identifiers and names so that users don't have to do it manually.
Question: The names of user defined properties are required to be unique within a file so it needs some validation.
Should an attempt to add a user defined property with a name that already exists be an error (e.g. throw an exception), or should it replace any existing property with a new one (it might have to handle the new property having a different type than the existing one, which would need to remove the existing property and create a new one)