1 //---------------------------------------------------------------------
2 // <copyright file="EdmItemCollection.OcAssemblyCache.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System.Collections.Generic;
10 using System.Reflection;
12 namespace System.Data.Metadata.Edm
14 internal class OcAssemblyCache
17 /// cache for loaded assembly
19 private Dictionary<Assembly, ImmutableAssemblyCacheEntry> _conventionalOcCache;
21 internal OcAssemblyCache()
23 _conventionalOcCache = new Dictionary<Assembly, ImmutableAssemblyCacheEntry>();
27 /// Please do NOT call this method outside of AssemblyCache. Since AssemblyCache maintain the lock,
28 /// this method doesn't provide any locking mechanism.
30 /// <param name="assemblyToLookup"></param>
31 /// <param name="cacheEntry"></param>
32 /// <returns></returns>
33 internal bool TryGetConventionalOcCacheFromAssemblyCache(Assembly assemblyToLookup, out ImmutableAssemblyCacheEntry cacheEntry)
36 return _conventionalOcCache.TryGetValue(assemblyToLookup, out cacheEntry);
40 /// Please do NOT call this method outside of AssemblyCache. Since AssemblyCache maintain the lock,
41 /// this method doesn't provide any locking mechanism.
43 /// <param name="assembly"></param>
44 /// <param name="cacheEntry"></param>
45 internal void AddAssemblyToOcCacheFromAssemblyCache(Assembly assembly, ImmutableAssemblyCacheEntry cacheEntry)
47 if (_conventionalOcCache.ContainsKey(assembly))
49 // we shouldn't update the cache if we already have one
52 _conventionalOcCache.Add(assembly, cacheEntry);