MetadataAddProperties Method
Adds known metadata properties satisfying the specified predicate. The operation is recursive so it affects all nested packages as well.

Namespace: GroupDocs.Metadata
Assembly: GroupDocs.Metadata (in GroupDocs.Metadata.dll) Version: 20.10
Syntax
public int AddProperties(
	Func<MetadataProperty, bool> predicate,
	PropertyValue value
)

Parameters

predicate
Type: GroupDocs.Metadata.CommonFuncMetadataProperty, Boolean
A function to test each metadata property for a condition.
value
Type: GroupDocs.Metadata.CommonPropertyValue
A value for the picked properties.

Return Value

Type: Int32
The number of affected properties.
Remarks
Learn more
Examples
This example demonstrates how to add some missing metadata properties to a file regardless of its format.
C#
using (Metadata metadata = new Metadata(Constants.InputDocx))
{
    // Add a property containing the file last printing date if it's missing
    // Note that the property will be added to metadata packages that satisfy the following criteria:
    // 1) Only existing metadata packages will be affected. No new packages are added during this operation
    // 2) There should be a known metadata property in the package structure that fits the search condition but is actually missing in the package.
    // All properties supported by a certain package are usually defined in the specification of a particular metadata standard
    var affected = metadata.AddProperties(p => p.Tags.Contains(Tags.Time.Printed), new PropertyValue(DateTime.Now));

    Console.WriteLine("Affected properties: {0}", affected);

    metadata.Save(Constants.OutputDocx);
}
See Also