From f9e85445f8f57119bb017629265efe24f738024d Mon Sep 17 00:00:00 2001 From: Paul Sladen Date: Wed, 29 Jul 2009 18:28:39 +0100 Subject: [PATCH] PluginManager: break out repeated .dll name and callingconvention in DllImport --- openBVE/OpenBve/PluginManager.cs | 40 ++++++++++++++++++++----------------- 1 files changed, 22 insertions(+), 18 deletions(-) diff --git a/openBVE/OpenBve/PluginManager.cs b/openBVE/OpenBve/PluginManager.cs index c9d79b7..622e178 100644 --- a/openBVE/OpenBve/PluginManager.cs +++ b/openBVE/OpenBve/PluginManager.cs @@ -87,42 +87,44 @@ namespace OpenBve { private const int ATS_CONSTANTSPEED_DISABLE = 2; // proxy functions + private const CallingConvention convention = CallingConvention.StdCall; + private const string proxyname = "AtsPluginProxy.dll"; + - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static int LoadDLL([MarshalAs(UnmanagedType.LPWStr)]string UnicodeFileName, [MarshalAs(UnmanagedType.LPStr)]string AnsiFileName); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static int UnloadDLL(); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void Load(); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void Dispose(); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static int GetPluginVersion(); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void SetVehicleSpec(ref int spec); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void Initialize(int brake); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void Elapse(ref int handles, ref double state, ref int panel, ref int sound); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void SetPower(int notch); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void SetBrake(int notch); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void SetReverser(int pos); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void KeyDown(int atsKeyCode); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void KeyUp(int atsKeyCode); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void HornBlow(int hornType); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void DoorOpen(); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void DoorClose(); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void SetSignal(int signal); - [DllImport("AtsPluginProxy.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] + [DllImport(proxyname, ExactSpelling = true, CallingConvention = convention)] private extern static void SetBeaconData(ref int beacon); // cached data -- 1.6.0.4