public void RegisterDataType <TData>(Action <TData> dataHandler) where TData : LeafDataProtocol { if (handlers.ContainsKey(typeof(TData))) { throw new DeveloperError("SimpleTreeBuilder", "RegisterDataType", "duplicated data types", "one type can only be registered once"); } LeafProtocolHandler <TData> handler = new LeafProtocolHandler <TData>(); handlers.Add(typeof(TData), handler); Tree.Register(handler); Tree.EntryToLeaf(handler); handler.NewData += data => dataHandler?.Invoke(data); }
public static void EntryToLeaf <TLeafProtocol>( this ProtocolTree tree, LeafProtocolHandler <TLeafProtocol> leaf) where TLeafProtocol : LeafDataProtocol => tree.Entry(leaf.helper);
public static void ConnectToLeaf <TParentProtocol, TLeafProtocol>( this ProtocolTree tree, AbstractProtocolHandler <TParentProtocol> parent, LeafProtocolHandler <TLeafProtocol> leaf) where TParentProtocol : AbstractProtocol where TLeafProtocol : LeafDataProtocol => tree.Connect(parent, leaf.helper);
public static void Register <TLeafProtocol>( this ProtocolTree tree, LeafProtocolHandler <TLeafProtocol> leaf) where TLeafProtocol : LeafDataProtocol => tree.Register(leaf.helper);