Allows caching values for a specific compilation. A CacheManager consists of a for shared instances (shared among all threads working with that resolve context).
This class is thread-safe
		ISynchronizedTypeResolveContext Synchronize(CacheManager cacheManager, bool isTopLevel)
		{
			ISynchronizedTypeResolveContext[] sync = new ISynchronizedTypeResolveContext[children.Length];
			bool success = false;
			try {
				for (int i = 0; i < sync.Length; i++) {
					sync[i] = children[i].Synchronize();
					if (sync[i] == null)
						throw new InvalidOperationException(children[i] + ".ToString() returned null");
				}
				ISynchronizedTypeResolveContext r = new CompositeSynchronizedTypeResolveContext(sync, cacheManager, isTopLevel);
				success = true;
				return r;
			} finally {
				if (!success) {
					// something went wrong, so immediately dispose the contexts we acquired
					for (int i = 0; i < sync.Length; i++) {
						if (sync[i] != null)
							sync[i].Dispose();
					}
				}
			}
		}
			public CompositeSynchronizedTypeResolveContext(ITypeResolveContext[] children, CacheManager cacheManager, bool isTopLevel)
				: base(children)
			{
				Debug.Assert(cacheManager != null);
				this.cacheManager = cacheManager;
				this.isTopLevel = isTopLevel;
			}
Пример #3
0
        internal VB6Compilation(IVbpProjectSymbolCache parent)
        {
            _parent = parent;

            CacheManager = new CacheManager();
        }