本文整理汇总了C#中ClientContext.OpenWorkspace方法的典型用法代码示例。如果您正苦于以下问题:C# ClientContext.OpenWorkspace方法的具体用法?C# ClientContext.OpenWorkspace怎么用?C# ClientContext.OpenWorkspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClientContext
的用法示例。
在下文中一共展示了ClientContext.OpenWorkspace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("Starting client");
BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = 0;
props["name"] = "clientChannelName";
var channel = new HttpChannel(props, clientProv, serverProv);
ChannelServices.RegisterChannel(channel, false);
try
{
var ctxServer = (IServerContext)RemotingServices.Connect(typeof(IServerContext), "http://localhost:5656" + "/ctxServer");
var ctxClient = new ClientContext(ctxServer, new Execom.IOG.Storage.MemoryStorageUnsafe<Guid, object>());
ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
do
{
Console.Clear();
Console.WriteLine("Press ESC to exit");
if (Console.KeyAvailable)
{
pressedKey = Console.ReadKey();
}
if (pressedKey.Key != ConsoleKey.Escape)
{
using (var ws = ctxClient.OpenWorkspace<Execom.IOG.Distributed.Model.IDataModel>(IsolationLevel.Snapshot))
{
for (int i = 0; i < 1000; i++)
{
var user = ws.New<IUser>();
user.Username = "New guy";
ws.Data.Users.Add(user);
}
ws.Commit();
}
}
}
while (pressedKey.Key != ConsoleKey.Escape);
}
finally
{
ChannelServices.UnregisterChannel(channel);
}
}