private void GenerateCallBackException(HookTypes type, SetCallBackResults result)
        {
            if (result == SetCallBackResults.Success)
            {
                return;
            }

            string msg;

            switch (result)
            {
            case SetCallBackResults.AlreadySet:
                msg  = "A hook of type " + type + " is already registered. You can only register ";
                msg += "a single instance of each type of hook class. This can also occur when you forget ";
                msg += "to unregister or dispose a previous instance of the class.";

                throw new ManagedHooksException(msg);

            case SetCallBackResults.ArgumentError:
                msg = "Failed to set hook callback due to an error in the arguments.";

                throw new ArgumentException(msg);

            case SetCallBackResults.NotImplemented:
                msg  = "The hook type of type " + type + " is not implemented in the C++ layer. ";
                msg += "You must implement this hook type before you can use it. See the C++ function ";
                msg += "SetUserHookCallback.";

                throw new HookTypeNotImplementedException(msg);
            }

            msg = "Unrecognized exception during hook callback setup. Error code " + result + ".";
            throw new ManagedHooksException(msg);
        }
        /// <include file='Internal.xml' path='Docs/SystemHook/ctor/*'/>
        public SystemHook(HookTypes type)
        {
            this.type = type;

            processHandler = new HookProcessedHandler(InternalHookCallback);
            SetCallBackResults result = SetUserHookCallback(processHandler, type);

            if (result != SetCallBackResults.Success)
            {
                this.Dispose();
                GenerateCallBackException(type, result);
            }
        }
Exemple #3
0
		private void GenerateCallBackException(HookTypes type, SetCallBackResults result)
		{
			if (result == SetCallBackResults.Success)
			{
				return;
			}

			string msg;

			switch (result)
			{
				case SetCallBackResults.AlreadySet:
					msg = "A hook of type " + type + " is already registered. You can only register ";
					msg += "a single instance of each type of hook class. This can also occur when you forget ";
					msg += "to unregister or dispose a previous instance of the class.";

					throw new ManagedHooksException(msg);

				case SetCallBackResults.ArgumentError:
					msg = "Failed to set hook callback due to an error in the arguments.";

					throw new ArgumentException(msg);

				case SetCallBackResults.NotImplemented:
					msg = "The hook type of type " + type + " is not implemented in the C++ layer. ";
					msg += "You must implement this hook type before you can use it. See the C++ function ";
					msg += "SetUserHookCallback.";

					throw new HookTypeNotImplementedException(msg);
			}

			msg = "Unrecognized exception during hook callback setup. Error code " + result + ".";
			throw new ManagedHooksException(msg);
		}