feat: Resurrect DataStream primitives

They were originally commented out because the expression parsing utils
weren't ready (now they are).
This commit is contained in:
John Colvin committed 2023-09-29 13:10:50 -04:00
1 parent 1dfc028554
commit 9311c27f47
29 files changed
+2737 -2647

No files matched your search

@@ -1,6 +1,8 @@
using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace BCG
{
@@ -36,6 +38,11 @@ namespace BCG
myValues[colNo] = newValue;
}
#nullable enable
public IDictionary<string, object?> AsDictionary() =>
new DictionaryWrapper(this);
#nullable disable
private static object[] myCloneArray (IBlueTableSchema schema,object[] vals)
{
object[] retVal = new object[schema.columnNames.Length];
@@ -52,5 +59,69 @@ namespace BCG
return rv;
}
}
class DictionaryWrapper : IDictionary<string, object?> {
readonly MutableBlueRow source;
public DictionaryWrapper(MutableBlueRow source) =>
this.source = source;
public ICollection<string> Keys => source.schema.columnNames;
public ICollection<object> Values => source.myValues;
public int Count => source.Count;
public bool IsReadOnly => false;
public object this[string key] {
get => source[key];
set => source.setValue(key, value);
}
public void Add(string key, object value) =>
source.setValue(key, value);
public void Add(KeyValuePair<string, object> item) =>
source.setValue(item.Key, item.Value);
public void Clear() =>
source.Clear();
public bool Contains(KeyValuePair<string, object> item) =>
source.Contains(item.Key) && Equals(source[item.Key], item.Value);
public bool ContainsKey(string key) =>
source.Contains(key);
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex) {
for (int i = 0; i < source.Count; i++) {
array[arrayIndex++] = new(source.schema.columnNames[i], source.myValues[i]);
}
}
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() {
throw new NotImplementedException();
}
public bool Remove(string key) {
throw new NotImplementedException();
}
public bool Remove(KeyValuePair<string, object> item) {
throw new NotImplementedException();
}
public bool TryGetValue(string key, [MaybeNullWhen(false)] out object value) {
if (source.Contains(key)) {
value = source[key];
return true;
}
value = default;
return false;
}
IEnumerator IEnumerable.GetEnumerator() =>
GetEnumerator();
}
}
}