コード例 #1
0
        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);
        }
コード例 #2
0
 public static void EntryToLeaf <TLeafProtocol>(
     this ProtocolTree tree,
     LeafProtocolHandler <TLeafProtocol> leaf)
     where TLeafProtocol : LeafDataProtocol => tree.Entry(leaf.helper);
コード例 #3
0
 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);
コード例 #4
0
 public static void Register <TLeafProtocol>(
     this ProtocolTree tree, LeafProtocolHandler <TLeafProtocol> leaf)
     where TLeafProtocol : LeafDataProtocol => tree.Register(leaf.helper);