Ejemplo n.º 1
0
        void ICache.Merge(IPsiSourceFile sourceFile, object builtPart)
        {
            var values = builtPart as List <IUnitTestElement>;

            if (values != null)
            {
                lock (_lock)
                {
                    _elementsInFiles.RemoveKey(sourceFile);
                    _elementsInFiles.AddValueRange(sourceFile, values);
                }

                var xml = "<Serialized></Serialized>";
                if (_elementsInFiles[sourceFile].Any())
                {
                    var document = new XmlDocument();
                    document.LoadXml(xml);
                    var info = new PersistentUnitTestSessionInfo(sourceFile.GetSolution(), null)
                    {
                        Elements = _elementsInFiles[sourceFile]
                    };
                    info.WriteToXml(document.DocumentElement);
                    xml = document.OuterXml;
                }

                if (_persistentCache != null)
                {
                    _persistentCache.AddDataToSave(sourceFile, xml);
                }
            }
        }
Ejemplo n.º 2
0
 object ICache.Load(IProgressIndicator progress, bool enablePersistence)
 {
     if (enablePersistence)
     {
         _persistentCache = new SimplePersistentCache <string>(_shellLocks, 1, "KarmaTest", _psiConfiguration);
         if (_persistentCache.Load(progress, _persistentIndexManager,
                                   (file, reader) => reader.ReadString(),
                                   (file, serialized) =>
         {
             lock (_lock)
             {
                 var info = new PersistentUnitTestSessionInfo(_solution, serialized);
                 foreach (var element in info.Elements)
                 {
                     _elementsInFiles.AddValue(file, element);
                 }
                 _processedFiles.Add(file);
                 _persistentCache.AddDataToSave(file, serialized);
             }
         }) != LoadResult.OK)
         {
             lock (_lock)
             {
                 _elementsInFiles.Clear();
                 _processedFiles.Clear();
             }
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        public void Merge(IPsiSourceFile sourceFile, object builtPart)
        {
            var data = (TCacheData)builtPart;

            lock (_lockObject)
            {
                AddFileToCache(sourceFile, data);
                if (_persistentCache != null)
                {
                    _persistentCache.AddDataToSave(sourceFile, data);
                }
                _dirtyFiles.Remove(sourceFile);
            }
        }
Ejemplo n.º 4
0
		object ICache.Load(IProgressIndicator progress, bool enablePersistence)
		{
			if (enablePersistence)
			{
				_persistentCache = new SimplePersistentCache<string>(_shellLocks, 1, "KarmaTest", _psiConfiguration);
				if (_persistentCache.Load(progress, _persistentIndexManager,
					(file, reader) => reader.ReadString(),
					(file, serialized) =>
					{
						lock (_lock)
						{
							var info = new PersistentUnitTestSessionInfo(_solution, serialized);
							foreach (var element in info.Elements)
							{
								_elementsInFiles.AddValue(file, element);
							}
							_processedFiles.Add(file);
							_persistentCache.AddDataToSave(file, serialized);
						}
					}) != LoadResult.OK)
				{
					lock (_lock)
					{
						_elementsInFiles.Clear();
						_processedFiles.Clear();
					}
				}
			}
			return null;
		}