public void op_AsOfT() { var shard = new DataShard(); shard.Entries.Add(new KeyStringDictionary { { "name", "value" } }); foreach (var entry in shard.As <TestDataEntry>()) { Assert.Equal("value", entry.Name); } }
public void op_GetEnumerator() { var shard = new DataShard(); shard.Entries.Add(new KeyStringDictionary { { "name", "value" } }); foreach (var entry in shard) { Assert.Equal("value", entry["name"]); } }
public virtual IEnumerable <DataShard> Shard(IIdentifyShard identifier) { if (null == identifier) { throw new ArgumentNullException("identifier"); } DataShard shard = null; string current = null; foreach (var entry in this) { var id = identifier.IdentifyShard(entry); if (null == shard) { shard = new DataShard(id); } if (id != current) { current = id; if (0 != shard.Entries.Count) { yield return(shard); } shard = new DataShard(id); } shard.Entries.Add(entry); } if (null == shard) { yield break; } if (0 != shard.Entries.Count) { yield return(shard); } }