bool TryGetMeta( string keyname, T& outvalue )

book_4_sparkGenerated
code_blocksInput

Description

The TryGetMeta method attempts to retrieve a metadata value associated with a specified key from the project configuration. If the key exists, the method outputs the corresponding value and returns true. If the key does not exist, the method returns false and the output value is not modified.

Usage

Use this method when you need to safely attempt to retrieve a metadata value from a ProjectConfig instance without throwing an exception if the key is not found. This is particularly useful for optional metadata entries where the presence of a key is not guaranteed.

Example

// Example usage of TryGetMeta
var projectConfig = new ProjectConfig();

// Assume some metadata has been set previously
projectConfig.SetMeta("author", "John Doe");

// Attempt to retrieve the metadata
if (projectConfig.TryGetMeta("author", out string author))
{
    // Successfully retrieved the author
    // Use the author value
    Console.WriteLine($"Author: {author}");
}
else
{
    // Key not found
    Console.WriteLine("Author metadata not found.");
}