using System.Collections.Generic; using System.Linq; using EcsRx.Extensions; using EcsRx.Infrastructure; using EcsRx.Infrastructure.Extensions; using EcsRx.Plugins.ReactiveSystems.Systems; using EcsRx.Plugins.Views.Systems; using EcsRx.Systems; namespace EcsRx.Plugins.Views.Extensions { public static class IEcsRxApplicationExtensions { /// /// Resolve all systems which have been bound in the order they need to be triggered /// /// The application to act on /// This ordering will be Setup, ViewResolvers, Anything Else public static IEnumerable GetAllBoundViewSystems(this IEcsRxApplication application) { var allSystems = application.Container.ResolveAll(); return allSystems .OrderByDescending(x => x is ISetupSystem && !(x is IViewResolverSystem)) .ThenByDescending(x => x is IViewResolverSystem) .ThenByPriority(); } /// /// Resolve all systems which have been bound and register them in order with the systems executor /// /// The application to act on /// /// This ordering will be Setup, ViewResolvers, Anything Else public static void StartAllBoundViewSystems(this IEcsRxApplication application) { var orderedSystems = GetAllBoundViewSystems(application); orderedSystems.ForEachRun(application.SystemExecutor.AddSystem); } } }