MetadataUpdateProperties Method |
Updates known metadata properties satisfying the specified predicate.
The operation is recursive so it affects all nested packages as well.
Namespace: GroupDocs.MetadataAssembly: GroupDocs.Metadata (in GroupDocs.Metadata.dll) Version: 21.2
Syntaxpublic int UpdateProperties(
Func<MetadataProperty, bool> predicate,
PropertyValue value
)
Public Function UpdateProperties (
predicate As Func(Of MetadataProperty, Boolean),
value As PropertyValue
) As Integer
public:
int UpdateProperties(
Func<MetadataProperty^, bool>^ predicate,
PropertyValue^ value
)
member UpdateProperties :
predicate : Func<MetadataProperty, bool> *
value : PropertyValue -> int
Parameters
- predicate
- Type: GroupDocs.Metadata.CommonFuncMetadataProperty, Boolean
A function to test each metadata property for a condition. - value
- Type: GroupDocs.Metadata.CommonPropertyValue
A new value for the filtered properties.
Return Value
Type:
Int32The number of affected properties.
Remarks
Please note that GroupDocs.Metadata implicitly checks the type of each filtered property.
It's impossible to update a property with a value having an inappropriate type.
Learn more
Examplesusing (Metadata metadata = new Metadata(Constants.InputXlsx))
{
if (metadata.FileFormat != FileFormat.Unknown && !metadata.GetDocumentInfo().IsEncrypted)
{
var affected = metadata.UpdateProperties(p => p.Tags.Contains(Tags.Time.Created) &&
p.Value.Type == MetadataPropertyType.DateTime &&
p.Value.ToStruct<DateTime>() < threeDaysAgo, new PropertyValue(today));
Console.WriteLine("Affected properties: {0}", affected);
metadata.Save(Constants.OutputXlsx);
}
}
See Also