// Merges the appdefs from the plan with the current ones (add new, replace existing).
        private void AdoptPlan(ILaunchPlan plan)
        {
            // add record for not yet existing apps
            foreach (var a in plan.getAppDefs())
            {
                if (!appsState.ContainsKey(a.AppIdTuple))
                {
                    appsState[a.AppIdTuple] = new AppState()
                    {
                        Initialized = false,
                        Running     = false,
                        Started     = false,
                        Disabled    = a.Disabled
                    };
                }

                if (a.AppIdTuple.MachineId == machineId)
                {
                    if (!localApps.ContainsKey(a.AppIdTuple))
                    {
                        localApps[a.AppIdTuple] = new LocalApp()
                        {
                            AppDef   = a,
                            launcher = null,
                            watchers = new List <IAppWatcher>()
                        };
                    }
                    else                     // app already exists, just update its appdef to be used on next launch
                    {
                        localApps[a.AppIdTuple].AppDef = a;
                    }
                }
            }
        }
Beispiel #2
0
        public bool Equals(ILaunchPlan other)
        {
            if (other == null)
                return false;

            if (this.Name == other.Name
                  &&
                this.appDefs.SequenceEqual( other.getAppDefs() )
                )
                return true;
            else
                return false;
        }
Beispiel #3
0
        public bool Equals(ILaunchPlan other)
        {
            if (other == null)
            {
                return(false);
            }

            if (this.Name == other.Name
                &&
                this.appDefs.SequenceEqual(other.getAppDefs())
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Prepares for starting a new plan. Merges the appdefs from the plan with the current ones (add new, replace existing).
        /// </summary>
        /// <param name="plan"></param>
        public void SelectPlan(ILaunchPlan plan)
        {
            //if (plan == null)
            //{
            //    throw new ArgumentNullException("plan");
            //}

            // stop the current plan
            StopPlan();

            // change the current plan to this one
            currentPlan = plan;

            if (plan == null)
            {
                return;
            }

            // add record for not yet existing apps
            foreach (var a in plan.getAppDefs())
            {
                if (!appsState.ContainsKey(a.AppIdTuple))
                {
                    appsState[a.AppIdTuple] = new AppState()
                    {
                        Initialized = false,
                        Running = false,
                        Started = false
                    };
                }

                if (a.AppIdTuple.MachineId == machineId)
                {
                    if (!localApps.ContainsKey(a.AppIdTuple))
                    {
                        localApps[a.AppIdTuple] = new LocalApp()
                        {
                            AppDef = a,
                            launcher = null,
                            watchers = new List<IAppWatcher>()
                        };
                    }
                    else // app already exists, just update its appdef to be used on next launch
                    {
                        localApps[a.AppIdTuple].AppDef = a;
                    }
                }
            }
        }