能否在一段代码中写一个common class 多次访问client context?

Can we write a common class to access the client context multiple times in a code?

我有一个 SharePoint 提供商托管应用程序。我将不得不多次点击客户端上下文来呈现数据。

我无法在 C# 客户端对象模型中编写通用 class 来使用 class 访问客户端上下文。有没有可能减少对上下文的命中以提高性能。

非常感谢您的帮助。

提前致谢!!

是的,您当然可以重复使用同一个 ClientContext 对象。您应该使用标准的面向对象技术传递它。

例如

public class YourClass {

private ClientContext _clientContext;

public YourClass(ClientContext clientContext){ 
_clientContext = clientContext;
}
}