Пример #1
0
        public WindowPoppedUpInitDetector(LocalApp app, XElement xml)
        {
            _app       = app;
            _appState  = _app.AppState;
            _appDef    = _app.RecentAppDef;
            _processId = _app.ProcessId;

            try
            {
                parseArgs(xml);
            }
            catch
            {
                throw new InvalidAppInitDetectorArguments(Name, xml.ToString());
            }

            if (_titleRegExp is null)
            {
                throw new InvalidAppInitDetectorArguments(Name, xml.ToString());
            }

            _appState.Initialized = false; // will be set to true as soon as the exit code condition is met

            log.DebugFormat("WindowPoppedUpInitDetector: Waiting for window with titleRegExp {0}, appid {1}, pid {2}", _titleRegExpString, _appDef.Id, _app.ProcessId);
        }
Пример #2
0
 public MainWindowStyler(LocalApp app)
 {
     _app = app;
     //_appState = _app.AppState;
     _appDef   = _app.RecentAppDef;
     _appState = _app.AppState;
 }
Пример #3
0
        public CrashWatcher(LocalApp app)
        {
            _app      = app;
            _appState = _app.AppState;
            _appDef   = _app.RecentAppDef;

            _state = eState.WaitingForCrash;
        }
Пример #4
0
        public ExitCodeInitDetector(LocalApp app, XElement xml)
        {
            _app      = app;
            _appState = app.AppState;

            try
            {
                string args = xml.Value;

                // " -1, 1, 2,3, 6-8 "
                foreach (var token in args.Split(','))
                {
                    // fill the exitCodes
                    var   trimmed = token.Trim();
                    Match m;
                    m = Regex.Match(trimmed, "(-?\\d+)-(-?\\d+)");   // "1-6" or "-4-8" or "-4--1"
                    if (m.Success)
                    {
                        var lo = int.Parse(m.Groups[1].Value);
                        var hi = int.Parse(m.Groups[2].Value);
                        if (lo <= hi)
                        {
                            for (var i = lo; i <= hi; i++)
                            {
                                _exitCodes.Add(i);
                            }
                        }
                    }
                    else
                    {
                        m = Regex.Match(trimmed, "(-?\\d+)");
                        if (m.Success)
                        {
                            var i = int.Parse(m.Groups[0].Value);
                            _exitCodes.Add(i);
                        }
                    }
                }

                // no exit codes specified??
                if (_exitCodes.Count == 0)
                {
                    throw new InvalidAppInitDetectorArguments(Name, args);
                }

                _appState.Initialized = false; // will be set to true as soon as the exit code condition is met
            }
            catch (Exception ex)
            {
                if (ex is FormatException || ex is OverflowException)
                {
                    throw new InvalidAppInitDetectorArguments(Name, xml.ToString());
                }
                throw;
            }
        }
Пример #5
0
        int MAX_TRIES        = -1;  // how many times to try restarting before giving up; -1 = forever

        /// <param name="vars">what env/macro vars to set for a process; null=no change</param>
        public AppRestarter(LocalApp app, bool waitBeforeRestart, Dictionary <string, string>?vars)
        {
            _app      = app;
            _appDef   = _app.RecentAppDef;
            _appState = _app.AppState;
            _vars     = vars;

            parseXml();

            Reset(waitBeforeRestart);
        }
Пример #6
0
        //public bool TryGet( AppIdTuple appId, out AppState appState )
        //{
        //	appState = default(AppState);
        //	return false;
        //}

        /// <summary>
        /// Adds a new local app record if not yet existing
        /// </summary>
        /// <returns>null if already exisitng, new rec if just added</returns>
        public LocalApp?AddIfMissing(AppDef appDef, string?planName)
        {
            LocalApp?la;

            if (!_apps.TryGetValue(appDef.Id, out la))
            {
                la = new LocalApp(appDef, _sharedContext);
                _apps[appDef.Id] = la;
                return(la);
            }
            return(null);            // not added, already existing
        }
Пример #7
0
        public IAppInitializedDetector create(LocalApp app, XElement xml)
        {
            string name = xml.Name.LocalName;

            CreateDeleg?cd = Find(name);

            if (cd == null)
            {
                throw new UnknownAppInitDetectorType(name);
            }

            return(cd(app, xml));
        }
Пример #8
0
        /// <summary>
        /// Creates new local app record if not exist yet.
        /// Otherwise updates the UpcomingAppDef.
        /// </summary>
        /// <param name="ad"></param>
        /// <param name="planName"></param>
        /// <returns></returns>
        public LocalApp AddOrUpdate(AppDef ad)
        {
            LocalApp?la;

            if (_apps.TryGetValue(ad.Id, out la))
            {
                la.UpdateAppDef(ad);
            }
            else
            {
                la           = new LocalApp(ad, _sharedContext);
                _apps[ad.Id] = la;
            }
            return(la);
        }
Пример #9
0
        //<TimeOut>2.0</TimeOut>
        public TimeOutInitDetector(LocalApp app, XElement xml)
        {
            _app           = app;
            this._appState = app.AppState;
            this._appDef   = app.RecentAppDef;


            try
            {
                var timeString = xml.Value;

                _timeOut = Double.Parse(timeString, CultureInfo.InvariantCulture);
            }
            catch
            {
                throw new InvalidAppInitDetectorArguments(Name, xml.ToString());
            }

            _appState.Initialized = false; // will be set to true as soon as the exit code condition is met

            _initialTicks = DateTime.UtcNow.Ticks;
            log.DebugFormat("TimeOutInitDetector: Waiting {0} sec, appid {1}", _timeOut, _appDef.Id);
        }
Пример #10
0
 static public IAppInitializedDetector create(LocalApp app, XElement xml)
 {
     return(new ExitCodeInitDetector(app, xml));
 }
Пример #11
0
 static public IAppInitializedDetector create(LocalApp app, XElement xml)
 {
     return(new WindowPoppedUpInitDetector(app, xml));
 }