本文整理汇总了C#中SocketClient.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# SocketClient.GetService方法的具体用法?C# SocketClient.GetService怎么用?C# SocketClient.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketClient
的用法示例。
在下文中一共展示了SocketClient.GetService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test1
private static void Test1(SocketClient client)
{
DirectoryService service = client.GetService<DirectoryService> ();
DirectoryItemInfo directory = service.Get ("/") as DirectoryItemInfo;
IEnumerable<FileSystemItemInfo> contents = service.GetContents (directory);
foreach (FileSystemItemInfo content in contents)
Console.WriteLine (content.Path);
service.Close ();
}
示例2: Test2
private static void Test2(SocketClient client)
{
DirectoryService service = client.GetService<DirectoryService> ();
MoveFileOperationService copyService = client.GetService<MoveFileOperationService> ();
DirectoryItemInfo tmpDir = (DirectoryItemInfo)service.Get ("/home/ralph/tmp");
DirectoryItemInfo testDir = (DirectoryItemInfo)service.Get ("/home/ghost.old/Downloads");
int opID = copyService.Start (testDir, tmpDir, false);
bool finished = false;
bool overwriteAll = false;
while (!finished) {
CopyFileOperationInfo info = (CopyFileOperationInfo)copyService.GetInfo (opID);
if (info != null) {
Console.Clear ();
if (info.Actual != null)
Console.WriteLine (info.Actual.Path);
if (info.ActualProgress != null) {
Console.WriteLine ("Progress:\t" + (info.ActualProgress != null ? info.ActualProgress.Current + "\t/" + info.ActualProgress.Max : string.Empty));
Console.WriteLine ("Overall:\t" + info.OverallProgress.Current + "\t/" + info.OverallProgress.Max);
}
if (info.IsRunning) {
if (info.ConflictItem != null) {
char key;
if (info.ConflictOverwriteable) {
if (!overwriteAll) {
Console.WriteLine ("Conflict: " + info.Actual.Path + " vs. " + info.ConflictItem.Path);
Console.Write ("(k)eep/(o)verwrite/(a)all/(c)ancel: ");
key = Console.ReadKey ().KeyChar;
Console.WriteLine ();
} else {
key = 'o';
}
} else {
Console.WriteLine ("Conflict(not overwriteable): " + info.Actual.Path + " vs. " + info.ConflictItem.Path);
Console.Write ("(k)eep/(c)ancel: ");
key = Console.ReadKey ().KeyChar;
Console.WriteLine ();
}
switch (key) {
case 'k':
copyService.ResolveConflict (opID, false);
break;
case 'o':
copyService.ResolveConflict (opID, true);
break;
case 'a':
overwriteAll = true;
copyService.ResolveConflict (opID, true);
break;
case 'c':
copyService.Remove (opID);
finished = true;
break;
}
} else {
Thread.Sleep (50);
}
} else {
if (info.Exception != null) {
Console.WriteLine ("EXCEPTION: " + info.Exception.ExceptionTypeName + ", " + info.Exception.ExceptionTypeName);
Console.WriteLine ("Message:");
Console.WriteLine (info.Exception.ExceptionMessage);
Console.WriteLine ("StackTrace:");
Console.WriteLine (info.Exception.ExceptionStackTrace);
}
finished = true;
}
} else {
finished = true;
}
}
FileSystemItemInfo targetItem = service.GetContents (tmpDir).Where (i => i.Name == "Downloads").FirstOrDefault ();
if (targetItem != null)
Console.WriteLine (targetItem.Path);
else
Console.WriteLine ("something went wrong");
service.Close ();
}