本文整理汇总了C#中Union类的典型用法代码示例。如果您正苦于以下问题:C# Union类的具体用法?C# Union怎么用?C# Union使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Union类属于命名空间,在下文中一共展示了Union类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UnionWithT4_UsesElseExpressionIfNoCase3Match
public void UnionWithT4_UsesElseExpressionIfNoCase3Match()
{
var union = new Union<int, string, Colors, Animals>(Animals.Cow);
var result = union.Match<bool>()
.Case1().Do(x => false).Case2().Do(x => false).Case3().Do(false).Else(true).Result();
IsTrue(result);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchElseTests.cs
示例2: UnionWithT3_UsesElseIfNoCase3Match
public void UnionWithT3_UsesElseIfNoCase3Match()
{
var union = new Union<int, string, Colors, Animals>(Colors.Green);
var result = union.Match<bool>()
.Case1().Do(x => false).Case2().Do(x => false).Case4().Do(false).Else(x => true).Result();
IsTrue(result);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchElseTests.cs
示例3: YesNo123OrOtherIntMatcherExample
public static string YesNo123OrOtherIntMatcherExample(Union<int, bool> value) =>
value.Match<string>()
.Case1().Of(1).Or(2).Or(3).Do(i => $"{i} in range 1-3")
.Case1().Do(i => $"int={i}")
.Case2().Of(true).Do("Yes")
.Case2().Of(false).Do("No")
.Result();
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionMatcherExamples.cs
示例4: DifferentT3Values_ArentEqual
public void DifferentT3Values_ArentEqual()
{
var a = new Union<int, string, Colors, Animals>(Colors.Blue);
var b = new Union<int, string, Colors, Animals>(Colors.Red);
IsFalse(a.Equals(b));
IsFalse(a == b);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4EqualityTests.cs
示例5: UnionWithT1_MatchesBasicCase1CorrectlyWithExec
public void UnionWithT1_MatchesBasicCase1CorrectlyWithExec()
{
var union = new Union<int, string>(2);
var result = 0;
union.Match().Case1().Do(x => result = x).Case2().Do(x => result = 3).Exec();
AreEqual(2, result);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2Tests.cs
示例6: UnionWithT1_UsesCase1MatchOverElse
public void UnionWithT1_UsesCase1MatchOverElse()
{
var union = new Union<int, string, Colors, Animals>(2);
var result = 0;
union.Match().Case1().Do(x => result = x).Else(_ => result = 1).Exec();
AreEqual(2, result);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchElseExecTests.cs
示例7: DifferentT3Values_ArentEqual
public void DifferentT3Values_ArentEqual()
{
var a = new Union<int, string, Colors>(Colors.Blue);
var b = new Union<int, string, Colors>(Colors.Green);
IsFalse(a.Equals(b));
IsTrue(a != b);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3EqualityTests.cs
示例8: FontSize
public static ReactStyle FontSize(Union<string, int> fontSize)
{
return new ReactStyle
{
FontSize = fontSize
};
}
开发者ID:ProductiveRage,项目名称:Bridge.React,代码行数:7,代码来源:StyleFactory.cs
示例9: Main
static void Main(string[] args)
{
string s = "123";
int i;
if (int.TryParse(s, out i))
{
Console.WriteLine("Parsed {0}", i);
}
else
{
Console.WriteLine("Unable to parse '{0}'", s);
}
s = "1234zr";
s.ParseInt()
.Match()
.None()
.Do(() => Console.WriteLine($"Unable to parse '{s}'"))
.Some()
.Do(value => Console.WriteLine($"Parsed {value}"))
.Exec();
var demoUnion = new Union<int, bool>(false);
string matcherResult = demoUnion.Match<string>()
.Case1().Of(1).Or(2).Or(3).Do(ui => $"{ui} in range 1-3")
.Case1().Do(ui => $"int={ui}")
.Case2().Of(true).Do("Yes")
.Case2().Of(false).Do("No")
.Result();
Console.WriteLine(matcherResult);
}
开发者ID:vermluh,项目名称:cs,代码行数:31,代码来源:Program.cs
示例10: UnionWithT2_UsesCase2MatchOverElse
public void UnionWithT2_UsesCase2MatchOverElse()
{
var union = new Union<int, string, Colors, Animals>("x");
var result = 0;
union.Match().Case2().Do(_ => result = 1).Else(_ => result = 2).Exec();
AreEqual(1, result);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchElseExecTests.cs
示例11: DifferentT2Values_ArentEqual
public void DifferentT2Values_ArentEqual()
{
var a = new Union<int, string, Colors>("abc");
var b = new Union<int, string, Colors>("def");
IsFalse(a.Equals(b));
IsTrue(a != b);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3EqualityTests.cs
示例12: UnionWithT2_UsesElseIfNoCase2MatchWithExec
public void UnionWithT2_UsesElseIfNoCase2MatchWithExec()
{
var union = new Union<int, string, Colors>("fred");
var result = 0;
union.Match().Case1().Do(x => result = 1).Case3().Do(x => result = 3).Else(x => result = 2).Exec();
AreEqual(2, result);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3BasicMatchExecTests.cs
示例13: UnionWithT2_CaseOfExpressionSupported
public void UnionWithT2_CaseOfExpressionSupported()
{
var union = new Union<int, string, Colors, Animals>("1");
var result = union.Match<int>()
.Case1().Do(0).Case2().Of("1").Do(2).Case2().Do(1).Case3().Do(3).Case4().Do(4).Result();
AreEqual(2, result);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchTests.cs
示例14: UnionWithT1_UsesElseIfNoCase1MatchWithExec
public void UnionWithT1_UsesElseIfNoCase1MatchWithExec()
{
var union = new Union<int, string, Colors>(11);
var result = 0;
union.Match().Case2().Do(x => result = 1).Case3().Do(x => result = 3).Else(x => result = x.Case1).Exec();
AreEqual(11, result);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3BasicMatchExecTests.cs
示例15: UnionWithT3_UsesCase3MatchOverElse
public void UnionWithT3_UsesCase3MatchOverElse()
{
var union = new Union<int, string, Colors, Animals>(Colors.Blue);
var result = 0;
union.Match().Case3().Do(_ => result = 1).Else(_ => result = 3).Exec();
AreEqual(1, result);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchElseExecTests.cs
示例16: DifferentT4Values_ArentEqual
public void DifferentT4Values_ArentEqual()
{
var a = new Union<int, string, Colors, Animals>(Animals.Cat);
var b = new Union<int, string, Colors, Animals>(Animals.Cow);
IsFalse(a.Equals(b));
IsFalse(a == b);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4EqualityTests.cs
示例17: ComparingT2ValueWithNull_ResultsInNotEqual
public void ComparingT2ValueWithNull_ResultsInNotEqual()
{
var a = new Union<int, string>(null);
IsFalse(a.Equals(null));
IsTrue(a != null);
IsTrue(null != a);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2EqualityTests.cs
示例18: DifferentT2Values_ArentEqual
public void DifferentT2Values_ArentEqual()
{
var a = new Union<int, string>("a");
var b = new Union<int, string>("b");
IsFalse(a.Equals(b));
IsTrue(a != b);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2EqualityTests.cs
示例19: UnionWithT4_UsesCase4MatchOverElse
public void UnionWithT4_UsesCase4MatchOverElse()
{
var union = new Union<int, string, Colors, Animals>(Animals.Sheep);
var result = 0;
union.Match().Case4().Do(_ => result = 1).Else(_ => result = 3).Exec();
AreEqual(1, result);
}
开发者ID:chamook,项目名称:SuccincT,代码行数:7,代码来源:UnionT1T2T3T4BasicMatchElseExecTests.cs
示例20: UnionWithT3_SimpleCaseExpressionSupported
public void UnionWithT3_SimpleCaseExpressionSupported()
{
var union = new Union<int, string, Colors, Animals>(Colors.Blue);
var result = 0;
union.Match().Case1().Do(_ => result = 1).Case2().Do(_ => result = 2)
.Case3().Do(_ => result = 3).Case4().Do(_ => result = 4).Exec();
AreEqual(3, result);
}
开发者ID:martijnhoekstra,项目名称:SuccincT,代码行数:8,代码来源:UnionT1T2T3T4BasicMatchExecTests.cs
注:本文中的Union类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论