public static PathHelperResult SelectsOnly(this Path path, IViewModel singleViewModel) { Check.NotNull(path, nameof(path)); Check.NotNull(singleViewModel, nameof(singleViewModel)); bool success = path.Length == 1 && path[0].ViewModel == singleViewModel; return(success ? PathHelperResult.Succeeded(vm: singleViewModel) : PathHelperResult.Failed()); }
public static PathHelperResult SelectsOnlyCollectionOf(this Path path, IViewModel owner) { Check.NotNull(path, nameof(path)); Check.NotNull(owner, nameof(owner)); bool success = path.Length == 2 && path[0].ViewModel == owner && path[1].Type == PathStepType.Collection; return(success ? PathHelperResult.Succeeded(vm: owner, collection: path[1].Collection) : PathHelperResult.Failed()); }