private async Task Process(object obj) { switch (obj) { case string str: await Process(str); break; case IObjectSummary objectSummary: await Process(objectSummary); break; case PSObject psObject: await Process(psObject.BaseObject); break; case AccessRulebasePagingResults ruleBase: await export.AddAsync(ruleBase, Depth); break; case IEnumerable objs: foreach (object o in objs) { await Process(o); } break; default: throw new CmdletInvocationException($"Invalid input object type: {obj.GetType()}"); } }
private async Task Process(object obj) { switch (obj) { case string str: var whereUsed = await Session.FindWhereUsed(identifier : str, indirect : IndirectWhereUsed.IsPresent, cancellationToken : CancelProcessToken); await export.AddAsync(str, whereUsed, Depth); break; case IObjectSummary objectSummary: await Process(objectSummary); break; case PSObject psObject: await Process(psObject.BaseObject); break; case AccessRulebasePagingResults ruleBase: await export.AddAsync(ruleBase, Depth); break; case IEnumerable objs: foreach (object o in objs) { await Process(o); } break; default: throw new CmdletInvocationException($"Invalid input object type: {obj.GetType()}"); } }