本文整理汇总了C#中Func.IsNotNull方法的典型用法代码示例。如果您正苦于以下问题:C# Func.IsNotNull方法的具体用法?C# Func.IsNotNull怎么用?C# Func.IsNotNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func.IsNotNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCertificate
public static X509Certificate2 GetCertificate(StoreName storeName, StoreLocation storeLocation, Func<X509Certificate2, bool> certFinder) {
DBC.True(certFinder.IsNotNull(), () => "Must supply a certificate finder");
X509Store store = new X509Store(storeName, storeLocation);
store.Open(OpenFlags.ReadOnly);
X509Certificate2 cert = store.Certificates.Cast<X509Certificate2>().FirstOrDefault(certFinder);
store.Close();
DBC.False(cert.IsNull(), () => $"No certificate matching the request found in {storeLocation}/{storeName}");
return cert;
}
示例2: ValidateAndSendCommand
protected ActionResult ValidateAndSendCommand(Command command, Func<ActionResult> successFunc, Func<ActionResult> failFunc, Func<ActionResult> validationFailFunc = null, Func<bool> preCondition = null, Func<ActionResult> preConditionResult = null)
{
if (preCondition.IsNull() || preCondition())
{
if (ModelState.IsValid)
{
_commandBus.Send(command);
return successFunc();
}
else if(validationFailFunc.IsNotNull())
{
return validationFailFunc();
}
}
else if (preConditionResult.IsNotNull())
{
return preConditionResult();
}
return failFunc();
}