本文整理汇总了C#中System.Result.AddException方法的典型用法代码示例。如果您正苦于以下问题:C# Result.AddException方法的具体用法?C# Result.AddException怎么用?C# Result.AddException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Result
的用法示例。
在下文中一共展示了Result.AddException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SafeExecute
public static Result<string> SafeExecute(ICustomAction action)
{
var result = new Result<string>();
try
{
result.Value = action.Do(action.State);
}
catch (Exception e)
{
result.AddException(e);
}
return result;
}
示例2: RemoveChecker
public Result<IEnumerable<Scenario>> RemoveChecker(Type checkerType)
{
var result = new Result<IEnumerable<Scenario>>();
var scenariosWasEdited = new List<Scenario>();
try
{
lock (Pyrite.ScenariosPool.Scenarios)
{
var assemblyName = checkerType.Assembly.FullName;
_customCheckers.RemoveAll(x => x.Assembly.FullName == assemblyName);
foreach (var action in Pyrite.ScenariosPool.Scenarios)
if (action.Action is IHasCheckerAction)
if (((IHasCheckerAction)action.Action).RemoveChecker(checkerType))
scenariosWasEdited.Add(action);
}
}
catch (Exception e)
{
result.AddException(e);
}
result.Value = scenariosWasEdited;
return result;
}
示例3: RemoveAction
public Result<IEnumerable<Scenario>> RemoveAction(Type actionType)
{
var result = new Result<IEnumerable<Scenario>>();
var scenariosWasEdited = new List<Scenario>();
try
{
lock (Pyrite.ScenariosPool.Scenarios)
{
var assemblyName = actionType.Assembly.FullName;
_customActions.RemoveAll(x => x.Assembly.FullName == assemblyName);
foreach (var action in Pyrite.ScenariosPool.Scenarios.ToArray())
{
if (action.Action is IHasCheckerAction)
{
if (((IHasCheckerAction)action.Action).RemoveAction(actionType))
scenariosWasEdited.Add(action);
}
else if (action.Action.GetType().Equals(actionType))
{
Pyrite.ScenariosPool.RemoveScenario(action);
}
}
}
}
catch (Exception e)
{
result.AddException(e);
}
result.Value = scenariosWasEdited;
return result;
}
示例4: GetViewName
public Result<string> GetViewName(Type type)
{
var result = new Result<string>();
try
{
result.Value = type.GetProperty("Name").GetValue(type.GetConstructor(new Type[0]).Invoke(new object[0])).ToString();
}
catch (Exception e)
{
result.AddException(e);
}
return result;
}