本文整理汇总了C#中AtomicComposition.AddRevertActionAllowNull方法的典型用法代码示例。如果您正苦于以下问题:C# AtomicComposition.AddRevertActionAllowNull方法的具体用法?C# AtomicComposition.AddRevertActionAllowNull怎么用?C# AtomicComposition.AddRevertActionAllowNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AtomicComposition
的用法示例。
在下文中一共展示了AtomicComposition.AddRevertActionAllowNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryPreviewImportsStateMachine
private CompositionResult TryPreviewImportsStateMachine(PartManager partManager,
ComposablePart part, AtomicComposition atomicComposition)
{
var result = CompositionResult.SucceededResult;
if (partManager.State == ImportState.ImportsPreviewing)
{
// We shouldn't nomally ever hit this case but if we do
// then we should just error with a cycle error.
return new CompositionResult(ErrorBuilder.CreatePartCycle(part));
}
// Transition from NoImportsStatisified to ImportsPreviewed
if (partManager.State == ImportState.NoImportsSatisfied)
{
partManager.State = ImportState.ImportsPreviewing;
var requiredImports = part.ImportDefinitions.Where(IsRequiredImportForPreview);
// If this atomicComposition gets rolledback for any reason we need to reset our state
atomicComposition.AddRevertActionAllowNull(() => partManager.State = ImportState.NoImportsSatisfied);
result = result.MergeResult(
this.TrySatisfyImportSubset(partManager, requiredImports, atomicComposition));
if (!result.Succeeded)
{
partManager.State = ImportState.NoImportsSatisfied;
return result;
}
partManager.State = ImportState.ImportsPreviewed;
}
return result;
}