private void SaveAndClose(bool isNewName) { if (isNewName) { Name = FSharpChoice <string, string> .NewChoice1Of2(SaveWithNewName); } else { Name = FSharpChoice <string, string> .NewChoice2Of2(RewriteExistScheduleName); } }
public static FSharpChoice <TR1, TR2> Transform <T1, T2, TR1, TR2>(this FSharpChoice <T1, T2> choice, Func <T1, TR1> func1, Func <T2, TR2> func2) { switch (choice.Tag) { case FSharpChoice <T1, T2> .Tags.Choice1Of2: return(FSharpChoice <TR1, TR2> .NewChoice1Of2(func1((choice.CastTo <FSharpChoice <T1, T2> .Choice1Of2>()).Item))); case FSharpChoice <T1, T2> .Tags.Choice2Of2: return(FSharpChoice <TR1, TR2> .NewChoice2Of2(func2((choice.CastTo <FSharpChoice <T1, T2> .Choice2Of2>()).Item))); } throw new InvalidOperationException(); }
public void New() { var a = FSharpChoice.New1Of2 <int, string>(1); var b = FSharpChoice <int, string> .NewChoice1Of2(1); Assert.AreEqual(a, b); var c = FSharpChoice.New2Of2 <int, string>("a"); var d = FSharpChoice <int, string> .NewChoice2Of2("a"); Assert.AreEqual(c, d); }