示例#1
0
 public MenuGroupViewModel Create(Infrastructure.MenuGroup menuGroup_)
 {
     return(new MenuGroupViewModel()
     {
         Name = menuGroup_.Name,
         Position = menuGroup_.Position,
         FontAwesomeClass = menuGroup_.FontAwesomeClass,
         MenuItems = new List <MenuItemViewModel>()
     });
 }
示例#2
0
        /// <summary>
        /// Finds the MenuGroupViewModel in menuGroupViewModels_ or creates and returns it.
        /// </summary>
        /// <param name="requestHandler_"></param>
        /// <param name="menuGroupViewModels_"></param>
        /// <param name="menuGroup_"></param>
        /// <returns></returns>
        private static MenuGroupViewModel FindOrCreateMenuGroup(IRequestHandler requestHandler_, Dictionary <string, MenuGroupViewModel> menuGroupViewModels_,
                                                                Infrastructure.MenuGroup menuGroup_, ILogger logger_)
        {
            MenuGroupViewModel menuGroupViewModel;

            menuGroupViewModels_.TryGetValue(menuGroup_.Name, out menuGroupViewModel);

            if (menuGroupViewModel == null)
            {
#if DEBUG
                logger_.LogInformation(
                    $"Menu group {menuGroup_.Name} found for first time, position {menuGroup_.Position}");
#endif
                menuGroupViewModel = new MenuGroupViewModelFactory(requestHandler_).Create(menuGroup_);
                menuGroupViewModels_.Add(menuGroupViewModel.Name, menuGroupViewModel);
            }
            else
            {
#if DEBUG
                logger_.LogInformation(
                    $"Menu group {menuGroup_.Name} already exists with position {menuGroup_.Position}");
#endif
                // If menu group already exist, the position and Font Awesome will be the one of the lowest position menu group
                if (menuGroup_.Position < menuGroupViewModel.Position)
                {
#if DEBUG
                    logger_.LogInformation(
                        $"Menu group {menuGroup_.Name} found with lower position {menuGroup_.Name}");
#endif
                    menuGroupViewModel.FontAwesomeClass = menuGroup_.FontAwesomeClass;
                    menuGroupViewModel.Position         = menuGroup_.Position;
                }
            }

            return(menuGroupViewModel);
        }