Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KVObject[string] returns KVValue which is impossible to enumerate #21

Closed
xPaw opened this issue Apr 16, 2020 · 2 comments
Closed

KVObject[string] returns KVValue which is impossible to enumerate #21

xPaw opened this issue Apr 16, 2020 · 2 comments

Comments

@xPaw
Copy link
Member

xPaw commented Apr 16, 2020

KVObject["string"] returns a KVValue, but if it has children i can't access that
debuggers shows 'children', but i can only call ToXXX() on it
it gives me the this[string] accessor, but i can't enumerate the children if I dont know the keys
calling tostring on it would indicate its KVCollectionValue due to [Collection], but if I try to foreach() it says KVValue has no GetEnumerator

Example code for Steam's config.vdf:

            using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            var data = KVSerializer.Create(KVSerializationFormat.KeyValues1Text).Deserialize(fs);

            var depots = data["Software"]["Valve"]["Steam"]["depots"];

            foreach (var depot in depots) // KVValue has no GetEnumerator()
            {

            }
@yaakov-h
Copy link
Member

The whole API probably needs to be revisited, but in the meantime you can cast it, i.e.:

var depots = data["Software"]["Valve"]["Steam"]["depots"];

foreach (var depot in (IEnumerable<KVObject>)depots)
{
    Console.WriteLine(depot.Name);
}

@yaakov-h
Copy link
Member

yaakov-h commented Jun 8, 2023

Closing to leave this to #30.

@yaakov-h yaakov-h closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants