本文整理汇总了C#中Maybe.Single方法的典型用法代码示例。如果您正苦于以下问题:C# Maybe.Single方法的具体用法?C# Maybe.Single怎么用?C# Maybe.Single使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maybe
的用法示例。
在下文中一共展示了Maybe.Single方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public void Save(Maybe<Deal> deal)
{
if (deal.Any())
{
var value = deal.Single();
var path = GetFileName(value.Id).FullName;
var serializedDeal = _serializer.SerializeDeal(value);
File.WriteAllText(path, serializedDeal);
}
}
示例2: Save
public void Save(Maybe<Deal> deal)
{
_writer.Save(deal);
ImmutableInterlocked.AddOrUpdate(ref _cache, deal.Single().Id, deal, (i, d) => deal);
}
示例3: WhenConstructedWithOneElement_ReturnsSameItem
public void WhenConstructedWithOneElement_ReturnsSameItem()
{
// ARRANGE
const string expctedValue = "Bill";
var maybe = new Maybe<string>(expctedValue);
// ACT
var actual = maybe.Single();
// ASSERT
Assert.AreSame(expctedValue, actual);
}
示例4: WhenConstructedWithOneElement_ReturnsCountOf1
public void WhenConstructedWithOneElement_ReturnsCountOf1()
{
// ARRANGE
const int expctedCount = 1;
var maybe = new Maybe<string>("Bill");
// ACT
var actualCount = maybe.Count();
// ASSERT
Assert.AreEqual(expctedCount, actualCount);
Assert.AreEqual("Bill", maybe.Single());
}