Esempio n. 1
0
        private static void CreateWebViews(TaskDispatcherPagesOptions options)
        {
            var enumerable =
                options.TaskHandlers.Select(
                    x =>
                    x.GetType()
                    .GetInterfaces()
                    .FirstOrDefault(y => y.IsConstructedGenericType)
                    .GetGenericArguments()
                    .FirstOrDefault()).ToList()
            ;

            foreach (var taskTypeGroup in enumerable.GroupBy(x => x.Name).ToDictionary(x => x.Key, x => x.ToList()))
            {
                var taskType = taskTypeGroup.Value.FirstOrDefault();
                var task     = Activator.CreateInstance(taskType) as ITaskParameters;
                TasksMenu.Tasks.Add(task);
                TasksMenu.AuthTasks.Add(task);
                if (taskTypeGroup.Value.Count() == 1)
                {
                    TaskDetailsRoutes.AddCommands(task, taskType.Name);

                    DashboardRoutes.Routes.AddRazorPage($"{TasksPage.UrlRoute}/{taskType.Name.Replace("`1", "")}",
                                                        x => new TaskDetailsPage(task, options));
                }
                else
                {
                    var types = taskTypeGroup.Value.Select(x => x.GenericTypeArguments.FirstOrDefault());
                    var unConstructedGenericType = taskType.Assembly.GetTypes().FirstOrDefault(x => x.Name == taskType.Name);
                    TaskDetailsRoutes.AddCommands(unConstructedGenericType, types.ToList(), taskType.Name.Replace("`1", ""));
                    DashboardRoutes.Routes.AddRazorPage($"{TasksPage.UrlRoute}/{taskType.Name.Replace("`1", "")}",
                                                        x => new TaskDetailsPage(task, options, types.ToList()));
                }
            }
        }
Esempio n. 2
0
        public static IGlobalConfiguration UseTaskDispatcherPages(this IGlobalConfiguration config, TaskDispatcherPagesOptions options)
        {
            options = options ?? new TaskDispatcherPagesOptions();
            CreateTopNavMenuItem();
            CreateScriptRoute();
            CreateWebViews(options);

            return(config);
        }