MetadataSetProperties Method
Sets known metadata properties satisfying the specified predicate. The operation is recursive so it affects all nested packages as well. This method is a combination of AddProperties(FuncMetadataProperty, Boolean, PropertyValue) and UpdateProperties(FuncMetadataProperty, Boolean, PropertyValue). If an existing property satisfies the predicate its value is updated. If there is a known property missing in a package that satisfies the predicate it is added to the package.

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


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

Return Value

Type: Int32
The number of affected properties.
Please note that GroupDocs.Metadata implicitly checks the type of each filtered property. It's impossible to set a property with a value having inappropriate type.

Learn more

This example demonstrates how to set specific metadata properties using different criteria.
using (Metadata metadata = new Metadata(Constants.InputVsdx))
    // Set the value of each property that satisfies the predicate:
    // property contains the date/time the document was created OR modified
    var affected = metadata.SetProperties(
    p => p.Tags.Contains(Tags.Time.Created) || p.Tags.Contains(Tags.Time.Modified),
    new PropertyValue(DateTime.Now));

    Console.WriteLine("Properties set: {0}", affected);

See Also