-
Notifications
You must be signed in to change notification settings - Fork 216
Update Filesystem client to make async invocations (C#) #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,35 +12,36 @@ | |
|
|
||
| // Recursively list the contents of the root directory. | ||
| Console.WriteLine("Contents of root directory:"); | ||
| ListRecursive(rootDir); | ||
| await ListRecursiveAsync(rootDir); | ||
|
|
||
| /// <summary>Recursively print the contents of a directory in tree fashion. For files, show the contents of each file. | ||
| /// </summary> | ||
| /// <param name="dir">The directory to list./<param> | ||
| /// <param name="depth">The current nesting level (for indentation).</param> | ||
| void ListRecursive(DirectoryPrx dir, int depth = 0) | ||
| async Task ListRecursiveAsync(DirectoryPrx dir, int depth = 0) | ||
| { | ||
| var indent = new string('\t', ++depth); | ||
|
|
||
| NodePrx?[] contents = dir.List(); | ||
| NodePrx?[] contents = await dir.ListAsync(); | ||
|
|
||
| foreach (NodePrx? node in contents) | ||
| { | ||
| Debug.Assert(node is not null); // The node proxies returned by list() are never null. | ||
|
|
||
| // TODO: should be an async call | ||
| DirectoryPrx? subdir = DirectoryPrxHelper.checkedCast(node); | ||
| string kind = subdir is not null ? "directory" : "file"; | ||
|
|
||
| Console.WriteLine($"{indent}{node.Name()} {kind}:"); | ||
| Console.WriteLine($"{indent}{await node.NameAsync()} {kind}:"); | ||
|
||
|
|
||
| if (subdir is not null) | ||
| { | ||
| ListRecursive(subdir, depth); | ||
| await ListRecursiveAsync(subdir, depth); | ||
| } | ||
| else | ||
| { | ||
| FilePrx file = FilePrxHelper.uncheckedCast(node); | ||
| string[] lines = file.Read(); | ||
| string[] lines = await file.ReadAsync(); | ||
| foreach (string line in lines) | ||
| { | ||
| Console.WriteLine($"{indent}\t{line}"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should generate a checkedCastAsync ... anything else would be inconsistent.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding checkedCastAsync sounds good. On a side note the Slice model for this example isn't great.
I wondering if we should add a NodeInfo struct and NodeKind enum:
This avoids the need for separate name, checkedCast requests.