Ejemplo n.º 1
0
        private MetadataShadowCopy GetMetadataShadowCopyNoCheck(string fullPath, MetadataImageKind kind)
        {
            if (!kind.IsValid())
            {
                throw new ArgumentOutOfRangeException("kind");
            }

            FileKey key = new FileKey(fullPath);

            lock (Guard)
            {
                CacheEntry <MetadataShadowCopy> existing;
                if (CopyExistsOrIsSuppressed(key, out existing))
                {
                    return(existing.Public);
                }
            }

            CacheEntry <MetadataShadowCopy> newCopy = CreateMetadataShadowCopy(fullPath, kind);

            // last-write timestamp is copied from the original file at the time the snapshot was made:
            key = new FileKey(fullPath, FileKey.GetTimeStamp(newCopy.Public.PrimaryModule.FullPath));

            lock (Guard)
            {
                CacheEntry <MetadataShadowCopy> existing;
                if (CopyExistsOrIsSuppressed(key, out existing))
                {
                    newCopy.Private.Dispose();
                    return(existing.Public);
                }

                shadowCopies.Add(key, newCopy);
            }

            return(newCopy.Public);
        }