/// <summary> /// Get engines from token. Token can be solution file or watch folder /// </summary> /// <param name="token">The engine watch token to look for. The token is either the solution file or the watch folder</param> /// <param name="caseInsensitive">Wether to match the token ignoring case</param> /// <returns>Engine</returns> public IEngine GetEngine(string token, bool caseInsensitive) { VMHandle activeHandle = null; var connect = new VMConnectHandle(); var handles = connect.GetFromToken(token, caseInsensitive); var toDelete = new List<string>(); foreach (var handle in handles) { if (canConnect(handle)) { activeHandle = handle; break; } toDelete.Add(handle.File); } toDelete.ForEach(x => { try { File.Delete(x); } catch { } }); if (activeHandle == null) return null; return new Engine(activeHandle); }