/// <summary>
        /// Registers <paramref name="config"/> for specified <paramref name="type"/> which must inherit <see cref="INavigationTarget"/>
        /// </summary>
        /// <param name="type"></param>
        /// <param name="config"></param>
        /// <exception cref="ArgumentNullException">When <paramref name="config"/> is null.</exception>
        /// <exception cref="ArgumentNullException">When <paramref name="type"/> is null.</exception>
        /// <exception cref="ArgumentException">When <see cref="INavigationTarget"/> is not assignable from <paramref name="type"/>.</exception>
        public static void RegisterTarget(Type type, INavigationConfig <INavigationTarget> config)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (!typeof(INavigationTarget).IsAssignableFrom(type))
            {
                throw new ArgumentException(nameof(type));
            }
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            InvokeOnDispatcher(() =>
            {
                if (!_navitaionTargetToConfigs.ContainsKey(type))
                {
                    _navitaionTargetToConfigs[type] = new List <INavigationConfig <INavigationTarget> >();
                }

                _navitaionTargetToConfigs[type].Add(config);
            });
        }
        /// <summary>
        /// Registers all available configs in speicifid <paramref name="assembly"/>
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="configResolver"></param>
        /// <exception cref="ArgumentNullException">When <paramref name="assembly"/> is null.</exception>
        public static void RegisterAvailableConfigs(Assembly assembly, Func <Type, INavigationConfig <INavigationTarget> > configResolver)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException(nameof(assembly));
            }
            if (configResolver == null)
            {
                throw new ArgumentNullException(nameof(configResolver));
            }

            var generic  = typeof(INavigationConfig <>);
            var allTypes = assembly.GetTypes().ToList();
            var matches  = allTypes.Where(x => x.IsClass && IsSubclassOfRawGeneric(generic, x)).ToList();

            InvokeOnDispatcher(() =>
            {
                foreach (var type in matches)
                {
                    INavigationConfig <INavigationTarget> config = configResolver(type);

                    if (config != null) // Check if config successfully resolved.
                    {
                        var parameterizedGeneric = GetParameterizedGeneric(generic, type);
                        RegisterTarget(parameterizedGeneric.GenericTypeArguments.First(), config);
                    }
                }
            });
        }
        /// <summary>
        /// Registers <paramref name="config"/> for specified <typeparam name="T"><see cref="INavigationTarget"/></typeparam> type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        /// <exception cref="ArgumentNullException">When <paramref name="config"/> is null.</exception>
        public static void RegisterTarget <T>(INavigationConfig <T> config) where T : INavigationTarget
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            InvokeOnDispatcher(() =>
            {
                RegisterTarget(typeof(T), (INavigationConfig <INavigationTarget>)config);
            });
        }
Пример #4
0
        public virtual IList <INavigationItem> GetItems(INavigationItem root, INavigationItem current, INavigationConfig config)
        {
            this.rootItem      = root;
            this.currentItem   = current;
            this.configuration = config ?? new DefaultConfiguration();

            var items = new List <INavigationItem>();

            if (root != null)
            {
                items.Add(root);
                items = GetItems(items, 0);
            }

            return(items);
        }
Пример #5
0
        /// <summary>
        /// Loads data to <see cref="Shell"/> and keeps data used for navigation in <see cref="Shell"/>.
        /// </summary>
        /// <param name="navMode">Navigation mode</param>
        /// <param name="config">Navigation config</param>
        /// <param name="target">Navigation target</param>
        /// <param name="data">Data for <see cref="Shell"/></param>
        internal void Load(NavigationMode navMode, INavigationConfig <INavigationTarget> config, INavigationTarget target, object data)
        {
            Mode   = navMode;
            Config = config;
            Target = target;
            Data   = data;
            var navigatable = Data as INavigatable;

            if (navigatable != null)
            {
                navigatable.RequestClose += NavigatableOnRequestClose;
            }

            UnloadView();
            View     = Shell.SetContent(data, target?.GetType());
            IsLoaded = true;
        }
Пример #6
0
 public Antenna(INavigationConfig navConfig, IRoverEngine roverEngine)
 {
     _navConfig   = navConfig ?? throw new ArgumentNullException(nameof(navConfig));
     _roverEngine = roverEngine ?? throw new ArgumentNullException(nameof(roverEngine));
 }
        public virtual IList <INavigationItem> GetItems(PageData startPage, PageData currentPage, INavigationConfig config)
        {
            var startPageNavigationItem   = this.navigationItemFactory.MakeNavigationItem(startPage);
            var currentPageNavigationItem = this.navigationItemFactory.MakeNavigationItem(currentPage);

            return(GetItems(startPageNavigationItem, currentPageNavigationItem, config));
        }