Skip to content

Unable to test for a config key existence #162

Closed
@haacked

Description

@haacked

I'd like to be able to tell the difference between a case where a config setting is missing vs it's value is null. For example, right now to test if some setting is missing, I have to do this:

var missingToken = Guid.NewGuid().ToString();
if (repository.Config.Get("SETTINGNAME", missingToken) == missingToken)
{
    Console.Write("The key 'SETTINGNAME' is missing");
}

It'd be nice if I could simply do this:

repository.Config.ContainsKey("SETTINGNAME");

Or even better, make the operation atomic.:

repository.Config.TryGet("SETTINGNAME"); 

This would return value with 2 properties, bool Exists and string Value.

What do you think?

Also, while I'm on the subject, how do I determine where the setting came from?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions