minor
This commit is contained in:
parent
b7cda31b58
commit
7b7a17ca49
|
@ -73,6 +73,12 @@ public static class AsyncEnumerableEx
|
|||
}
|
||||
}
|
||||
|
||||
public static async void ForEach<T>(this IAsyncEnumerable<T> ts, Action<T> action)
|
||||
{
|
||||
await foreach (var t in ts)
|
||||
action(t);
|
||||
}
|
||||
|
||||
#pragma warning disable 1998
|
||||
public static async IAsyncEnumerable<T> Repeat<T>(this T t, [EnumeratorCancellation] CancellationToken ct = default)
|
||||
{
|
||||
|
|
|
@ -59,13 +59,14 @@ public static class GraphTraversal
|
|||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
|
||||
private static IEnumerable<T> Traverse<T>(IEnumerable<T> sources,
|
||||
private static IEnumerable<T> Traverse<T>(
|
||||
IEnumerable<T> sources,
|
||||
Func<T , Func<T, IEnumerable<T>>,IEnumerable<T>> traversor,
|
||||
Func<T, IEnumerable<T>> getChildren,
|
||||
IEqualityComparer<T>? comparer = null)
|
||||
{
|
||||
var set = new HashSet<T>(sources, comparer ?? EqualityComparer<T>.Default);
|
||||
IEnumerable<T> GetUniqueChildren(T n) => getChildren(n).Where(set.Add);
|
||||
IEnumerable<T> GetUniqueChildren(T n) => getChildren(n).Where(set!.Add);
|
||||
|
||||
return from s in sources
|
||||
from e in traversor(s, GetUniqueChildren)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using static System.Runtime.CompilerServices.MethodImplOptions;
|
||||
|
@ -171,4 +171,12 @@ public static class Utils
|
|||
}
|
||||
|
||||
public static String ExecutingProcessName => Process.GetCurrentProcess().ProcessName;
|
||||
|
||||
|
||||
public static Func<A, R> Memoize<A, R>(Func<A, R> func) where A : notnull
|
||||
{
|
||||
var cache = new ConcurrentDictionary<A, R>();
|
||||
|
||||
return arg => cache.GetOrAdd(arg, func);
|
||||
}
|
||||
}
|
|
@ -109,8 +109,8 @@ public static class VePropertiesDbus
|
|||
VeDBusApi.GetValue => msg.Ok(p.Value),
|
||||
VeDBusApi.GetText => msg.Ok(p.Text),
|
||||
VeDBusApi.GetItems => msg.Ok(p.GetItem()),
|
||||
VeDBusApi.SetValue => (p.Writeable && msg.ObjectPath != null)
|
||||
? msg.Ok((p.Value==msg.Payload! || props.Set(path: msg.ObjectPath.Value, value: msg.Payload!, writable: true)) ? 0 : -1)
|
||||
VeDBusApi.SetValue => p.Writeable && msg.ObjectPath != null
|
||||
? msg.Ok(p.Value==msg.Payload! || props.Set(path: msg.ObjectPath.Value, value: msg.Payload!, writable: true) ? 0 : -1)
|
||||
: msg.ObjectNotWritable(msg.Member),
|
||||
_ => msg.UnknownMember(msg.Member)
|
||||
};
|
||||
|
@ -150,7 +150,6 @@ public static class VePropertiesDbus
|
|||
return CreateErrorReply(msg, $"Not Writable Property: {objectPath}");
|
||||
}
|
||||
|
||||
|
||||
private static Message CreateErrorReply(Message msg, String error)
|
||||
{
|
||||
Debug.WriteLine("ERROR: " + error);
|
||||
|
|
Loading…
Reference in New Issue