コード例 #1
0
 public override void Unload()
 {
     base.Unload();
     //BEGIN UNMANAGED FUNCTIONS
     _getTeamInfo    = null;
     _onEvent        = null;
     _getInstruction = null;
     _getPlacement   = null;
     //END UNMANAGED FUNCTIONS
 }
コード例 #2
0
        public override bool Load(string dllPath, bool reverse, out Exception exception)
        {
            if (IsLoaded)
            {
                exception = new Exception("DLL has loaded.");
                return(false);
            }

            ReverseCoordinate = reverse;
            _lastDllPath      = dllPath;
            var hModule   = LoadLibrary(dllPath);
            var errorCode = Marshal.GetLastWin32Error();

            if (hModule == IntPtr.Zero)
            {
                exception = new Exception($"Error load {dllPath}, code {errorCode}");
                return(false);
            }
            CurrentModule = hModule;
            try
            {
                //BEGIN UNMANAGED FUNCTIONS
                _getTeamInfo    = LoadFunction <GetTeamInfoDelegate>("GetTeamInfo");
                _onEvent        = LoadFunction <OnEventDelegate>("OnEvent");
                _getInstruction = LoadFunction <GetInstructionDelegate>("GetInstruction");
                _getPlacement   = LoadFunction <GetPlacementDelegate>("GetPlacement");
                _getControlInfo = LoadFunction <GetControlInfoDelegate>("GetControlInfo");
                //END UNMANAGED FUNCTIONS
            }
            catch (ArgumentNullException e)
            {
                Unload();
                exception = new Exception("Missing function", e);
                return(false);
            }
            exception = null;
            return(true);
        }