Add project files.

This commit is contained in:
2025-04-19 20:47:58 +03:00
parent 9e14d137ae
commit bfdcdb1f3b
66 changed files with 2394 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
using aeqw89.DataKeys;
namespace Beam.Temporary.Cli {
internal static class DataKeyExtensions {
public static DataKey WithNamespace(this DataKey dk, string @namespace) {
string[] names = @namespace.Split(':');
var agg = (string x, string y) => $"{x}:{y}";
for (int i = 0; i < names.Length; i++) {
string test = names.SkipLast(i).Aggregate(agg);
if (dk.Identifier.StartsWith(test)) {
return new DataKey(dk.Identifier.Replace(test, @namespace));
}
}
return new DataKey(@namespace + ":" + dk.Identifier);
}
public static DataKey<T> WithNamespace<T>(this DataKey<T> dk, string @namespace) {
return ((DataKey)dk).WithNamespace(@namespace).As<T>();
}
public static DataKey<T> WithSuffix<T>(this DataKey<T> dk, string suffix) {
return new DataKey<T>(dk.Identifier + suffix);
}
public static DataKey ToAggregator(this DataKey dk)
=> dk.WithNamespace("aeqw89:document:aggregators");
public static DataKey ToAuxiliary(this DataKey dk)
=> dk.WithNamespace("aeqw89:document:auxillaries");
public static DataKey<T> As<T>(this DataKey dk) => new DataKey<T>(dk.Identifier);
}
}