统一容器 - Idataprotector的注册

时间:2016-03-26 17:53:28

标签: c# asp.net unity-container

以下注册码用于结构图。

For<IDataProtector>().Use(() => new DpapiDataProtectionProvider().Create("ASP.NET Identity"));

统一中的等效注册是什么?

当我尝试如下时,它会出错。

container.RegisterType<IDataProtector>(() => new DpapiDataProtectionProvider().Create("ASP.NET Identity"));

1 个答案:

答案 0 :(得分:2)

// Waits for *all* futures to complete and returns a list of results.
// If *any* future completes exceptionally then the resulting future will also complete exceptionally.

public static <T> CompletableFuture<List<T>> all(List<CompletableFuture<T>> futures) {
    CompletableFuture[] cfs = futures.toArray(new CompletableFuture[futures.size()]);

    return CompletableFuture.allOf(cfs)
            .thenApply(ignored -> futures.stream()
                                    .map(CompletableFuture::join)
                                    .collect(Collectors.toList())
            );
}