private static void Validate02(MyNamedPropertyClass root) { foreach (var item in root.Flatten(v => v.Children)) { if (item.FontSize != root.FontSize) { throw new Exception(); } } }
private static void BuildGraph02(MyNamedPropertyClass element, int level = 0) { if (level < 2) { for (int i = 0; i < 30; i++) { var e = new MyNamedPropertyClass(); element.Children.Add(e); BuildGraph02(e, level + 1); } } }
private static void InheritedNamedProperty() { var root = new MyNamedPropertyClass(); BuildGraph02(root); var sw = Stopwatch.StartNew(); for (int i = 0; i < 1000; i++) { root.FontSize = i; } sw.Stop(); Validate02(root); Console.WriteLine($"Elapsed {sw.Elapsed} ({MyClass.Counter} elements)"); }