Пример #1
0
 /// <summary>
 /// Gets all the direct/first-level children of the folder at the given path.<br/>
 /// Optionally, only children ones that either are of the given type (in the case of properties) or that contain atleast one property of the given type (in the case of folders).
 /// </summary>
 /// <param name="path">Only children that are within the folder at the given path will be returned.</param>
 /// <param name="type">If not <see cref="GSIPropertyType.None"/>, only children of this type and only folders that contain atleast one property of this type will be returned.</param>
 public IEnumerable <GameStateParameterLookupEntry> Children(string path = "", GSIPropertyType type = GSIPropertyType.None) =>
 from kvp in lookup
     where GetFolderOf(kvp.Key) == path // only include anything in this folder
     where type == GSIPropertyType.None || // if type is none, don't worry about type filtering
 (kvp.Value.IsFolder && AllChildren(kvp.Key).Any(c => c.Type == type)) ||        // return a folder if it contains atleast one child of type
 (!kvp.Value.IsFolder && kvp.Value.Type == type)           // return a property if it is of type
 select kvp.Value;
Пример #2
0
 /// <summary>
 /// Determines if the given path results in a property of the given type.
 /// </summary>
 /// <param name="type">The result will only be true if the parameter type is of this type. If None is passed, any parameter type is allowed.</param>
 public bool IsValidParameter(string path, GSIPropertyType type = GSIPropertyType.None) =>
 lookup.TryGetValue(path, out var entry) && !entry.IsFolder && (type == GSIPropertyType.None || entry.Type == type);