Show the rules a user set on his workspaces in all depots.
- See also
- AcRules constructor
using System.Collections.Generic;
namespace ShowRules
{
class Program
{
private static readonly object _locker = new object();
static int Main()
{
Task<bool> rini = showRulesAsync("barnyrd");
return (rini.Result) ? 0 : 1;
}
public static async Task<bool> showRulesAsync(
string user)
{
List<AcRules> rules = new List<AcRules>();
Func<AcStream, Task<bool>> init = (s) =>
{
AcRules r = new AcRules(explicitOnly: true);
lock (_locker) { rules.Add(r); }
return r.initAsync(s);
};
AcDepots depots = new AcDepots();
if (!(await depots.initAsync())) return false;
var tasks =
from s in depots.SelectMany(d => d.Streams)
!s.Hidden && s.Name.EndsWith(user)
select init(s);
bool[] arr = await Task.WhenAll(tasks);
if (arr == null || arr.Any(n => n == false)) return false;
foreach (AcRule rule in rules.SelectMany(n => n).OrderBy(n => n))
Console.WriteLine(rule);
return true;
}
}
}