Esempio n. 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;
            }
        }
Esempio n. 2
0
 public MT4TradeBadVolumeExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_BAD_VOLUME)
 {
 }
Esempio n. 3
0
 public MT4OldVersionExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.OLD_VERSION)
 {
 }
Esempio n. 4
0
 public MT4InvalidDataExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.INVALID_DATA)
 {
 }
Esempio n. 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;
 }
Esempio n. 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);
        }
Esempio n. 7
0
 public MT4TradeHedgeProhibitedByFifoExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_PROHIBITED_BY_FIFO)
 {
 }
Esempio n. 8
0
 public MT4TradeTooManyOrdersExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_TOO_MANY_ORDERS)
 {
 }
Esempio n. 9
0
 public MT4TradeRequoteExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_REQUOTE)
 {
 }
Esempio n. 10
0
 public MT4TradeBrokerBusyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_BROKER_BUSY)
 {
 }
Esempio n. 11
0
 public MT4TradeOffquotesExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_OFFQUOTES)
 {
 }
Esempio n. 12
0
 public MT4TradePriceChangedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_PRICE_CHANGED)
 {
 }
Esempio n. 13
0
 public MT4TradeNoMoneyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_NO_MONEY)
 {
 }
Esempio n. 14
0
 public MT4TradeDisableExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_DISABLE)
 {
 }
Esempio n. 15
0
 public MT4TradeMarketClosedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_MARKET_CLOSED)
 {
 }
Esempio n. 16
0
 public MT4TradeContextBusyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_CONTEXT_BUSY)
 {
 }
Esempio n. 17
0
 public MT4TradeExpirationDeniedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_EXPIRATION_DENIED)
 {
 }
Esempio n. 18
0
 public MT4TradeOrderLockedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_ORDER_LOCKED)
 {
 }
Esempio n. 19
0
 public MT4TradeHedgeProhibitedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_HEDGE_PROHIBITED)
 {
 }
Esempio n. 20
0
 public MT4TradeLongOnlyExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_LONG_ONLY)
 {
 }
Esempio n. 21
0
 public MT4NetworkProblemExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.NETWORK_PROBLEM)
 {
 }
Esempio n. 22
0
 public MT4TradeTooManyReqExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_TOO_MANY_REQ)
 {
 }
Esempio n. 23
0
 public MT4TradeAcceptedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_ACCEPTED)
 {
 }
Esempio n. 24
0
 public MT4TradeProcessExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_PROCESS)
 {
 }
Esempio n. 25
0
 public MT4CommonErrorExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.GENERAL_ERROR)
 {
 }
Esempio n. 26
0
 public MT4TradeUserCancelExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_USER_CANCEL)
 {
 }
Esempio n. 27
0
 public MT4TechProblemExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TECH_PROBLEM)
 {
 }
Esempio n. 28
0
 public MT4TradeRModifyDeniedExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_MODIFY_DENIED)
 {
 }
Esempio n. 29
0
 public MT4NoConnectionExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.NO_CONNECTION)
 {
 }
Esempio n. 30
0
 public MT4TradeBadStopsExeption(MT4Interface MT4Interface) : base(MT4Interface, ResultCode.TRADE_BAD_STOPS)
 {
 }