Testing for variables #19
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There doesn't seem to be an easy way to check if a variable exists in a given file, and unfortunately the
IMatFile
indexer throws an exception when a variable does not exist. It would be useful to have a more tolerant way to access variables, such as one of the following:IMatFile[string]
returnnull
if variable does not existIMatFile.TryGetVariable(string, out IVariable)
methodIReadOnlyDictionary<string, IVariable>
Thanks for creating the issue!
The current way to check if a variable exists is go through the
IMatFile.Variables
array and test theName
property of the elements, which is quite ugly.I will go with the second proposed solution. Another approach would be to inherit
IMatFile
fromIReadOnlyDictionary<string, IVariable>
orIDictionary<string, IVariable>
, but there are some problems associated with that: I feel like it should be a read-only dictionary, but there is already a setter on the indexer for some reason. I guess we can do it when (if) we think about the next major version with breaking changes to the API.Version 1.4.0-beta1 published on nuget.org contains this change. Feel free to test it.
Great, working for me!
It would be very usefull to have the same interface for IStructureArray - currently you need to iterate over the FieldNames property. Exposing the TryGet method of the underlying Dictionary would help.