GetRootPackage
Leave feedback
On this page
Gets the root package providing access to all metadata properties extracted from the file.
public RootMetadataPackage GetRootPackage()
The root package providing access to all metadata properties extracted from the file.
Learn more
This example demonstrates how to traverse the whole metadata tree for a specific file regardless of the format.
public static void Run()
{
using (Metadata metadata = new Metadata(Constants.JpegWithXmp))
{
DisplayMetadataTree(metadata.GetRootPackage(), 0);
}
}
private static void DisplayMetadataTree(MetadataPackage package, int indent)
{
if (package != null)
{
var stringMetadataType = package.MetadataType.ToString();
Console.WriteLine(stringMetadataType.PadLeft(stringMetadataType.Length + indent));
foreach (MetadataProperty property in package)
{
string stringPropertyRepresentation = string.Format("Name: {0}, Value: {1}", property.Name, property.Value);
Console.WriteLine(stringPropertyRepresentation.PadLeft(stringPropertyRepresentation.Length + indent + 1));
if (property.Value != null)
{
switch (property.Value.Type)
{
case MetadataPropertyType.Metadata:
DisplayMetadataTree(property.Value.ToClass<MetadataPackage>(), indent + 2);
break;
case MetadataPropertyType.MetadataArray:
DisplayMetadataTree(property.Value.ToArray<MetadataPackage>(), indent + 2);
break;
}
}
}
}
}
private static void DisplayMetadataTree(MetadataPackage[] packages, int indent)
{
if (packages != null)
{
foreach (var package in packages)
{
DisplayMetadataTree(package, indent);
}
}
}
- class RootMetadataPackage
- class Metadata
- namespace GroupDocs.Metadata
- assembly GroupDocs.Metadata
Gets the root package providing access to all metadata properties extracted from the file.
public TRoot GetRootPackage<TRoot>()
where TRoot : RootMetadataPackage
| Parameter | Description |
|---|---|
| TRoot | The exact type of the root package. |
The root package providing access to all metadata properties extracted from the file.
Learn more
- class RootMetadataPackage
- class Metadata
- namespace GroupDocs.Metadata
- assembly GroupDocs.Metadata
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.