private static IList <MenuModel> GetMenuItems(IMenuModel model) { var menuItems = new List <MenuModel>(); for (var i = 0; i < model.Count; i++) { var type = model.GetTypeAt(i); bool?isChecked = null; if (type == MenuItemType.Check) { isChecked = model.IsCheckedAt(i); } var subItems = model.GetSubMenuAt(i); IList <MenuModel> subMenus = subItems == null ? null : GetMenuItems(subItems); var menuItem = new MenuModel { Label = model.GetLabelAt(i), CommandId = model.GetCommandIdAt(i), IsEnabled = model.IsEnabledAt(i), Type = type, IsSeperator = type == MenuItemType.Separator, IsChecked = isChecked, SubMenus = subMenus }; menuItems.Add(menuItem); } return(menuItems); }