public override bool OnData(object data) { if (!(data is DataType)) { throw new BlockTypeMismatchException(typeof(DataType), data.GetType(), this); } var d = (DataType)data; // :HACK: lol if (isAggregator) { List <DataType> temp; AggregateDictionary.TryGetValue(KeyFunction(d), out temp); if (temp == null) { AggregateDictionary[KeyFunction(d)] = new List <DataType>(); } AggregateDictionary[KeyFunction(d)].Add(d); SendToChildren(AggregateDictionary); } else { Dictionary[KeyFunction(d)] = d; SendToChildren(Dictionary); } return(false); }
public void TryGetValue_should_find_value_with_one_locator_registered() { var values = new NameValueCollection { { "foo", "value" } }; var dict = new AggregateDictionary(); dict.AddLocator(s => values[s]); object value; dict.TryGetValue("foo", out value).ShouldBeTrue(); value.ShouldEqual("value"); }
public void TryGetValue_should_find_value_with_multiple_locators_registered() { var values1 = new NameValueCollection { { "foo", "value" } }; var values2 = new NameValueCollection { { "bar", "baz" } }; var dict = new AggregateDictionary(); dict.AddLocator(s => values1[s]); dict.AddLocator(s => values2[s]); object value; dict.TryGetValue("bar", out value).ShouldBeTrue(); value.ShouldEqual("baz"); }
public void TryGetValue_should_not_error_if_no_locator_finds_the_value() { var values1 = new NameValueCollection { { "foo", "value" } }; var values2 = new NameValueCollection { { "bar", "baz" } }; var dict = new AggregateDictionary(); dict.AddLocator(s => values1[s]); dict.AddLocator(s => values2[s]); object value; dict.TryGetValue("zzzz", out value).ShouldBeFalse(); value.ShouldBeNull(); }
public void TryGetValue_should_work_without_any_locators_registered() { var dict = new AggregateDictionary(); object value; dict.TryGetValue("foo", out value).ShouldBeFalse(); value.ShouldBeNull(); }