Beispiel #1
0
        /// <summary>
        /// Выбрасывает исключение в случае если переданный код является ошибкой
        /// </summary>
        /// <param name="MT4Interface"></param>
        /// <param name="code"></param>
        public static void ThrowIfError(this MT4Interface MT4Interface, ResultCode code)
        {
            var exception = MT4Interface.ToException(code);

            if (exception != null)
            {
                throw exception;
            }
        }
Beispiel #2
0
 public MT4TradeBadVolumeExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_BAD_VOLUME)
 {
 }
Beispiel #3
0
 public MT4OldVersionExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.OLD_VERSION)
 {
 }
Beispiel #4
0
 public MT4InvalidDataExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.INVALID_DATA)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Конструктор принимает текст ошибки и исключение
 /// </summary>
 /// <param name="message"></param>
 /// <param name="cause"></param>
 public MT4ServerException(MT4Interface MT4Interface, ResultCode code, Exception cause) : base(MT4Interface.ErrorDescription(code), cause)
 {
     this.Code = code;
 }
Beispiel #6
0
        /// <summary>
        /// Преобразует код ответа от МТ4 сервера в исключение, если данный код носит харрактер ошибки
        /// В случае если код это не ошибка, то возвращает null
        /// В случае если был передан код ошибки, которого нет в enum ResultCode, то будет сгенерировано исключение базового типа MT4ServerException с данным кодом, а в сообщении исключения будет содержаться описание ошибки, которое вернул МТ4 сервер на данный код
        /// </summary>
        /// <param name="MT4Interface"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static MT4ServerException ToException(this MT4Interface MT4Interface, ResultCode code)
        {
            MT4ServerException exeption = null;

            switch (code)
            {
            case ResultCode.OK:
            case ResultCode.OK_NONE: exeption = null; break;

            case ResultCode.GENERAL_ERROR: exeption = new MT4CommonErrorExeption(MT4Interface); break;

            case ResultCode.INVALID_DATA: exeption = new MT4InvalidDataExeption(MT4Interface); break;

            case ResultCode.TECH_PROBLEM: exeption = new MT4TechProblemExeption(MT4Interface); break;

            case ResultCode.OLD_VERSION: exeption = new MT4OldVersionExeption(MT4Interface); break;

            case ResultCode.NO_CONNECTION: exeption = new MT4NoConnectionExeption(MT4Interface); break;

            case ResultCode.NOT_ENOUGH_RIGHTS: exeption = new MT4NotEnoughRightsExeption(MT4Interface); break;

            case ResultCode.TOO_FREQUENT: exeption = new MT4TooFrequentExeption(MT4Interface); break;

            case ResultCode.MALFUNCTION: exeption = new MT4MalfunctionExeption(MT4Interface); break;

            case ResultCode.GENERATE_KEY: exeption = new MT4GenerateKeyExeption(MT4Interface); break;

            case ResultCode.SECURITY_SESSION: exeption = new MT4SecuritySessionExeption(MT4Interface); break;

            case ResultCode.ACCOUNT_DISABLED: exeption = new MT4AccountDisabledExeption(MT4Interface); break;

            case ResultCode.BAD_ACCOUNT_INFO: exeption = new MT4BadAccountInfoExeption(MT4Interface); break;

            case ResultCode.PUBLIC_KEY_MISSING: exeption = new MT4PublicKeyMissingExeption(MT4Interface); break;

            case ResultCode.TRADE_TIMEOUT: exeption = new MT4TradeTimeoutExeption(MT4Interface); break;

            case ResultCode.TRADE_BAD_PRICES: exeption = new MT4TradeBadPricesExeption(MT4Interface); break;

            case ResultCode.TRADE_BAD_STOPS: exeption = new MT4TradeBadStopsExeption(MT4Interface); break;

            case ResultCode.TRADE_BAD_VOLUME: exeption = new MT4TradeBadVolumeExeption(MT4Interface); break;

            case ResultCode.TRADE_MARKET_CLOSED: exeption = new MT4TradeMarketClosedExeption(MT4Interface); break;

            case ResultCode.TRADE_DISABLE: exeption = new MT4TradeDisableExeption(MT4Interface); break;

            case ResultCode.TRADE_NO_MONEY: exeption = new MT4TradeNoMoneyExeption(MT4Interface); break;

            case ResultCode.TRADE_PRICE_CHANGED: exeption = new MT4TradePriceChangedExeption(MT4Interface); break;

            case ResultCode.TRADE_OFFQUOTES: exeption = new MT4TradeOffquotesExeption(MT4Interface); break;

            case ResultCode.TRADE_BROKER_BUSY: exeption = new MT4TradeContextBusyExeption(MT4Interface); break;

            case ResultCode.TRADE_REQUOTE: exeption = new MT4TradeRequoteExeption(MT4Interface); break;

            case ResultCode.TRADE_ORDER_LOCKED: exeption = new MT4TradeOrderLockedExeption(MT4Interface); break;

            case ResultCode.TRADE_LONG_ONLY: exeption = new MT4TradeLongOnlyExeption(MT4Interface); break;

            case ResultCode.TRADE_TOO_MANY_REQ: exeption = new MT4TradeTooManyReqExeption(MT4Interface); break;

            case ResultCode.TRADE_ACCEPTED: exeption = new MT4TradeAcceptedExeption(MT4Interface); break;

            case ResultCode.TRADE_PROCESS: exeption = new MT4TradeProcessExeption(MT4Interface); break;

            case ResultCode.TRADE_USER_CANCEL: exeption = new MT4TradeUserCancelExeption(MT4Interface); break;

            case ResultCode.TRADE_MODIFY_DENIED: exeption = new MT4TradeRModifyDeniedExeption(MT4Interface); break;

            case ResultCode.TRADE_CONTEXT_BUSY: exeption = new MT4TradeContextBusyExeption(MT4Interface); break;

            case ResultCode.TRADE_EXPIRATION_DENIED: exeption = new MT4TradeExpirationDeniedExeption(MT4Interface); break;

            case ResultCode.TRADE_TOO_MANY_ORDERS: exeption = new MT4TradeTooManyOrdersExeption(MT4Interface); break;

            case ResultCode.TRADE_HEDGE_PROHIBITED: exeption = new MT4TradeHedgeProhibitedExeption(MT4Interface); break;

            case ResultCode.TRADE_PROHIBITED_BY_FIFO: exeption = new MT4TradeHedgeProhibitedByFifoExeption(MT4Interface); break;

            case ResultCode.NETWORK_PROBLEM: exeption = new MT4NetworkProblemExeption(MT4Interface); break;

            default: exeption = new MT4ServerException(MT4Interface, code); break;
            }

            return(exeption);
        }
Beispiel #7
0
 public MT4TradeHedgeProhibitedByFifoExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_PROHIBITED_BY_FIFO)
 {
 }
Beispiel #8
0
 public MT4TradeTooManyOrdersExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_TOO_MANY_ORDERS)
 {
 }
Beispiel #9
0
 public MT4TradeRequoteExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_REQUOTE)
 {
 }
Beispiel #10
0
 public MT4TradeBrokerBusyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_BROKER_BUSY)
 {
 }
Beispiel #11
0
 public MT4TradeOffquotesExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_OFFQUOTES)
 {
 }
Beispiel #12
0
 public MT4TradePriceChangedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_PRICE_CHANGED)
 {
 }
Beispiel #13
0
 public MT4TradeNoMoneyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_NO_MONEY)
 {
 }
Beispiel #14
0
 public MT4TradeDisableExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_DISABLE)
 {
 }
Beispiel #15
0
 public MT4TradeMarketClosedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_MARKET_CLOSED)
 {
 }
Beispiel #16
0
 public MT4TradeContextBusyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_CONTEXT_BUSY)
 {
 }
Beispiel #17
0
 public MT4TradeExpirationDeniedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_EXPIRATION_DENIED)
 {
 }
Beispiel #18
0
 public MT4TradeOrderLockedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_ORDER_LOCKED)
 {
 }
Beispiel #19
0
 public MT4TradeHedgeProhibitedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_HEDGE_PROHIBITED)
 {
 }
Beispiel #20
0
 public MT4TradeLongOnlyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_LONG_ONLY)
 {
 }
Beispiel #21
0
 public MT4NetworkProblemExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.NETWORK_PROBLEM)
 {
 }
Beispiel #22
0
 public MT4TradeTooManyReqExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_TOO_MANY_REQ)
 {
 }
Beispiel #23
0
 public MT4TradeAcceptedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_ACCEPTED)
 {
 }
Beispiel #24
0
 public MT4TradeProcessExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_PROCESS)
 {
 }
Beispiel #25
0
 public MT4CommonErrorExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.GENERAL_ERROR)
 {
 }
Beispiel #26
0
 public MT4TradeUserCancelExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_USER_CANCEL)
 {
 }
Beispiel #27
0
 public MT4TechProblemExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TECH_PROBLEM)
 {
 }
Beispiel #28
0
 public MT4TradeRModifyDeniedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_MODIFY_DENIED)
 {
 }
Beispiel #29
0
 public MT4NoConnectionExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.NO_CONNECTION)
 {
 }
Beispiel #30
0
 public MT4TradeBadStopsExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_BAD_STOPS)
 {
 }