Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Metadata / EdmItemCollection.OcAssemblyCache.cs
1 //---------------------------------------------------------------------
2 // <copyright file="EdmItemCollection.OcAssemblyCache.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System.Collections.Generic;
10 using System.Reflection;
11
12 namespace System.Data.Metadata.Edm
13 {
14     internal class OcAssemblyCache
15     {
16         /// <summary>
17         /// cache for loaded assembly
18         /// </summary>
19         private Dictionary<Assembly, ImmutableAssemblyCacheEntry> _conventionalOcCache;
20
21         internal OcAssemblyCache()
22         {
23             _conventionalOcCache = new Dictionary<Assembly, ImmutableAssemblyCacheEntry>();
24         }
25
26         /// <summary>
27         /// Please do NOT call this method outside of AssemblyCache. Since AssemblyCache maintain the lock, 
28         /// this method doesn't provide any locking mechanism.
29         /// </summary>
30         /// <param name="assemblyToLookup"></param>
31         /// <param name="cacheEntry"></param>
32         /// <returns></returns>
33         internal bool TryGetConventionalOcCacheFromAssemblyCache(Assembly assemblyToLookup, out ImmutableAssemblyCacheEntry cacheEntry)
34         {
35             cacheEntry = null;
36             return _conventionalOcCache.TryGetValue(assemblyToLookup, out cacheEntry);
37         }
38
39         /// <summary>
40         /// Please do NOT call this method outside of AssemblyCache. Since AssemblyCache maintain the lock, 
41         /// this method doesn't provide any locking mechanism.
42         /// </summary>
43         /// <param name="assembly"></param>
44         /// <param name="cacheEntry"></param>
45         internal void AddAssemblyToOcCacheFromAssemblyCache(Assembly assembly, ImmutableAssemblyCacheEntry cacheEntry)
46         {
47             if (_conventionalOcCache.ContainsKey(assembly))
48             {
49                 // we shouldn't update the cache if we already have one
50                 return;
51             }
52             _conventionalOcCache.Add(assembly, cacheEntry);
53         }
54
55     }
56 }