Exemple #1
0
        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();
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <inheritdoc/>
        public virtual ISynchronizedTypeResolveContext Synchronize()
        {
            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] + ".Synchronize() returned null");
                    }
                }
                var knownTypeDefinitions = new ITypeDefinition[ReflectionHelper.ByTypeCodeArraySize];
                var r = new CompositeSynchronizedTypeResolveContext(sync, knownTypeDefinitions, new CacheManager(), true);
                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();
                        }
                    }
                }
            }
        }
		/// <inheritdoc/>
		public virtual ISynchronizedTypeResolveContext Synchronize()
		{
			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] + ".Synchronize() returned null");
				}
				ISynchronizedTypeResolveContext r = new CompositeSynchronizedTypeResolveContext(sync, new CacheManager(), true);
				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(ISynchronizedTypeResolveContext[] children, CacheManager cacheManager, bool isTopLevel)
				: base(children)
			{
				Debug.Assert(cacheManager != null);
				this.cacheManager = cacheManager;
				this.isTopLevel = isTopLevel;
			}