private static Task <Either <PowershellFailure, string> > ComparePath(string firstPath, string secondPath, Option <string> storageIdentifier) { return(storageIdentifier.ToEither(new PowershellFailure { Message = "unknown VM storage identifier" }) .BindAsync(id => { var fullPath = Path.Combine(firstPath, id); if (!secondPath.Equals(fullPath, StringComparison.InvariantCultureIgnoreCase)) { return Prelude .LeftAsync <PowershellFailure, string>(new PowershellFailure { Message = "Path calculation failure" }) .ToEither(); } return Prelude .RightAsync <PowershellFailure, string>(firstPath) .ToEither(); })); }
public static Task <Either <Error, TIn> > ToEitherLeft <TIn>(this Error error) { return(Prelude.LeftAsync <Error, TIn>(error).ToEither()); }