/
diev
/
PKISolutions-SSLVerifier.WPF
Обзор
Документация
Войти
/
diev
/
PKISolutions-SSLVerifier.WPF
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
SSLVerifier.Core/Models/TreeNode.cs
35 строк
1 KB
Vadims Podans
redesigned CertProcessor. Work in progress.
05 июл 2020, 23:58
05 июл 2020, 23:58
d70f112
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace SSLVerifier.Core.Models { public class TreeNode<T> { public TreeNode(T value) { Value = value; } public TreeNode<T> this[Int32 i] => Children[i]; public TreeNode<T> Parent { get; private set; } public T Value { get; } public ObservableCollection<TreeNode<T>> Children { get; } = new ObservableCollection<TreeNode<T>>(); public TreeNode<T> AddChild(T value) { var node = new TreeNode<T>(value) { Parent = this }; Children.Add(node); return node; } public TreeNode<T>[] AddChildren(params T[] values) { return values.Select(AddChild).ToArray(); } public Boolean RemoveChild(TreeNode<T> node) { return Children.Remove(node); } public void Traverse(Action<T> action) { action(Value); foreach (var child in Children) child.Traverse(action); } public IEnumerable<T> Flatten() { return new[] { Value }.Union(Children.SelectMany(x => x.Flatten())); } } }