Пример #1
0
        public void Add(ScreenDefinition <TViewModel> from, ScreenDefinition <TViewModel> to)
        {
            if (to is null)
            {
                throw new ArgumentNullException(nameof(to), "Null value for destination is not allowed");
            }

            if (!_nodePerScreenIds.TryGetValue(to.Id, out var node))
            {
                node = new Node <TViewModel>(to, isEntryPoint: from is null);
                _nodePerScreenIds.Add(node.Screen.Id, node);
            }

            if (from is null)
            {
                _entryPoints.Add(node);
                return;
            }

            if (!_nodePerScreenIds.TryGetValue(from.Id, out Node <TViewModel> fromNode))
            {
                throw new InvalidOperationException("Source has not been added to graph before destination, this is not allowed");
            }

            fromNode.NextNodes.Add(node);
        }
Пример #2
0
        public async Task Show(ScreenDefinition <TViewModel> screen, string parameter = null, ViewModelCreator <TViewModel> viewModelCreator = null)
        {
            var screenInstance = new ScreenInstance <TViewModel>(screen, parameter, viewModelCreator);
            var result         = _navigationGraph.FindBestStack(_navigationStack, screenInstance).ToList();

            System.Diagnostics.Debug.WriteLine($"Navigating to {screen.RelativeRoute}");
            System.Diagnostics.Debug.WriteLine($"\tUse stack: {string.Join(", ", result.Select(x => x.ToString()))}");

            await UpdateNavigationStack(result);
        }
Пример #3
0
 public void Register(ScreenDefinition <TViewModel> from, ScreenDefinition <TViewModel> screen)
 {
     _navigationGraph.Add(from, screen);
 }
Пример #4
0
 public void RegisterEntryPoint(ScreenDefinition <TViewModel> screen)
 {
     _navigationGraph.Add(null, screen);
 }
Пример #5
0
 protected bool Equals(ScreenDefinition <TViewModel> other)
 {
     return(Id.Equals(other.Id));
 }
Пример #6
0
 public ScreenInstance(ScreenDefinition <TViewModel> definition, string parameter, ViewModelCreator <TViewModel> viewModelCreator)
 {
     Definition       = definition;
     Parameter        = parameter;
     ViewModelCreator = viewModelCreator ?? definition.DefaultViewModelCreator;
 }