1.1 --- a/Hardware/PInvokeDelegateFactory.cs Sun Oct 21 14:45:24 2012 +0000
1.2 +++ b/Hardware/PInvokeDelegateFactory.cs Sat Oct 27 11:40:28 2012 +0000
1.3 @@ -4,7 +4,7 @@
1.4 License, v. 2.0. If a copy of the MPL was not distributed with this
1.5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
1.6
1.7 - Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
1.8 + Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
1.9
1.10 */
1.11
1.12 @@ -13,6 +13,7 @@
1.13 using System.Reflection;
1.14 using System.Reflection.Emit;
1.15 using System.Runtime.InteropServices;
1.16 +using OpenHardwareMonitor.Collections;
1.17
1.18 namespace OpenHardwareMonitor.Hardware {
1.19
1.20 @@ -24,18 +25,20 @@
1.21 AssemblyBuilderAccess.Run).DefineDynamicModule(
1.22 "PInvokeDelegateFactoryInternalModule");
1.23
1.24 - private static readonly IDictionary<DllImportAttribute, Type> wrapperTypes =
1.25 - new Dictionary<DllImportAttribute, Type>();
1.26 + private static readonly IDictionary<Pair<DllImportAttribute, Type>, Type> wrapperTypes =
1.27 + new Dictionary<Pair<DllImportAttribute, Type>, Type>();
1.28
1.29 public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
1.30 out T newDelegate) where T : class
1.31 {
1.32 Type wrapperType;
1.33 - wrapperTypes.TryGetValue(dllImportAttribute, out wrapperType);
1.34 + Pair<DllImportAttribute, Type> key =
1.35 + new Pair<DllImportAttribute, Type>(dllImportAttribute, typeof(T));
1.36 + wrapperTypes.TryGetValue(key, out wrapperType);
1.37
1.38 if (wrapperType == null) {
1.39 wrapperType = CreateWrapperType(typeof(T), dllImportAttribute);
1.40 - wrapperTypes.Add(dllImportAttribute, wrapperType);
1.41 + wrapperTypes.Add(key, wrapperType);
1.42 }
1.43
1.44 newDelegate = Delegate.CreateDelegate(typeof(T), wrapperType,