-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support complex root structures #23
Comments
Will be nice to have a Deserialization with a nested structures like in the "libraryfolders.vdf" where you can have multiple places where to look for games installed. "libraryfolders" In this case having a class for the whole content will be something like that:
So when we deserialize that content the objects will be automatically populated. |
This is a tricky issue to solve as there isn't a way to check if the keys 1,2,... are elements of an array or proper keys by themselves. We could have an attribute on a list property that tells the library to put all array elements into it but that's quite a bit of work (since we currently rely on an intermediate JSON conversion step for model deserialization) I think it may be best to do this logic using LINQ when you're sure it'll be an array: VProperty root = VdfConvert.Deserialize(input);
JObject rootObj = (JObject) root.Value.ToJson();
LibraryFolders libraryFolders = new LibraryFolders
{
ContentStatsId = rootObj["contentstatsid"]!.Value<string>()!,
libraryFoldersSpecifications = Enumerable
.Range(1, rootObj.Children<JProperty>().Select(x => x.Name).Where(x => Int32.TryParse(x, out _)).Select(x => Int32.Parse(x)).Max())
.Select(x => rootObj[x.ToString()]!.ToObject<LibraryFolderSpecification>()!)
.ToList()
}; |
Sound scripts have multiple elements at the root scope, rather than one root element encompassing the rest. |
@ZzZombo Could you share an example file? |
The KeyValues wiki states that statements like
"#base" "panelBase.res"
may be present in VDF files. Automatically executing import statements is out of scope for this library, but we should support these if possible. There may also be other root tokens like comments. One way to return these is as aIReadOnlyList<VToken>
.TODO:
The text was updated successfully, but these errors were encountered: