Пример #1
0
        /// <summary>
        /// Returns a filtered Putty sessions list based on the given Query.
        /// If no Query.ActionParameter is provided only the default Putty item is returned.
        /// </summary>
        /// <param name="query">A Query that contains an ActionParameter to filter the Putty session list</param>
        /// <returns>The filtered Putty session list</returns>
        public List <Result> Query(Query query)
        {
            var results = new List <Result> {
            };

            if (_settings.AddPuttyExeToResults)
            {
                results.Add(CreateResult());
            }
            var querySearch = query.ActionParameters.FirstOrDefault();

            if (string.IsNullOrEmpty(querySearch))
            {
                if (_settings.AddPuttyExeToResults)
                {
                    return(results);
                }
                else
                {
                    querySearch = string.Empty;
                }
            }

            var puttySessions = PuttySessionService.GetAll().Where(session => session.Identifier.ToLowerInvariant().Contains(querySearch.ToLowerInvariant()));

            foreach (var puttySession in puttySessions)
            {
                results.Add(CreateResult(puttySession.Identifier, puttySession.ToString()));
            }

            return(results);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public PuttyPlugin()
 {
     SettingsService     = new SettingsService();
     _settings           = SettingsService.LoadSettings();
     PuttySessionService = new PuttySessionService();
 }