public void TestToMenuDatas_1() { _nodes.Nodes.Add(new MenuNode { Label = "a" }); var datas = _nodes.ToMenuDatas(); Assert.Single(datas); Assert.Single(datas[0].Items); Assert.Equal(_nodes.RootId, datas[0].Id); Assert.Equal("a", datas[0].Items[0].Label); }
/// <summary> /// 设置菜单 /// </summary> /// <typeparam name="TComponent">组件类型</typeparam> /// <param name="component">组件实例</param> /// <param name="nodes">菜单节点集合</param> public static TComponent Menu <TComponent>(this TComponent component, MenuNodeCollection nodes) where TComponent : IButton { var option = component as IOptionConfig; option?.Config <ButtonConfig>(config => { config.Data = nodes.ToMenuDatas(); }); return(component.Menu(nodes.RootId)); }