Example #1
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        public static CSmartArray TestCalc(CFactory pFact, string name, int productCount = 1)
        {
            CSmartArray array = new CSmartArray();

            array.Add(name, productCount);
            pFact.SetInput(array);
            pFact.Calc();
            CSmartArray tempArray = pFact.GetResult();

            pFact.Refresh();
            return(tempArray);
        }
        protected void btnTransfer_Click(object sender, EventArgs e)
        {
            string test;

            BtnSubmit.Enabled = false;
            TxtAmt.Enabled    = false;
            TxtRmk.Enabled    = false;

            ICBO checkBO = CFactory.CreateInstance();

            checkBO.CustID = "101";
            checkBO.Pwd    = txtTxnPwd.Text;
            test           = UBll.CheckPassword(checkBO);



            if (test == "right")
            {
                ITBO ubo1 = TFactory.CreateInstance();
                ubo1.CustAcc = CustAcc;
                ubo1.Amt     = Convert.ToInt32(TxtAmt.Text);
                ubo1.Payee   = Payee;
                ubo1.Rmk     = TxtRmk.Text;

                IUBO updateBo = UFactory.CreateInstance();
                updateBo.Accno   = CustAcc;
                updateBo.Balance = Convert.ToInt32(TxtAmt.Text);
                string respond = BLL.UBll.Update(updateBo);
                lblrespond.Text = respond;

                IUpBO updateBOp = UPFactory.CreateInstance();
                updateBOp.PAccno = Payee;
                updateBOp.Amt1   = Convert.ToInt32(TxtAmt.Text);


                if (respond != "Insufficient Funds")
                {
                    string message = BLL.UBll.Transfer(ubo1);
                    lblTxID.Text = "Your Transcation ID is " + message;
                    string result = BLL.UBll.UpdatePayee1(updateBOp);
                    lblResult.Text = result;
                }
            }

            else if (test == "wrong")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Incorrect password" + "');", true);
            }
        }
Example #3
0
        /// <summary>
        /// (6) RPC
        /// Remote procedure call implementation
        /// </summary>
        /// <param name="host_name">호스트 명칭</param>
        /// <param name="ip_address"></param>
        /// <param name="virtual_host"></param>
        /// <param name="user_name"></param>
        /// <param name="password"></param>
        /// <param name="queue_name"></param>
        public RpcQ(
            string host_name  = null, string ip_address = null, string virtual_host = null,
            string user_name  = null, string password   = null,
            string queue_name = "remote_procedure_queue"
            )
            : base(host_name, ip_address, virtual_host, user_name, password, queue_name)
        {
            QConnection = CFactory.CreateConnection();
            QChannel    = QConnection.CreateModel();

            __replyQueueName = QChannel.QueueDeclare();

            QConsumer = new EventingBasicConsumer(QChannel);
            QChannel.BasicConsume(__replyQueueName, true, QConsumer);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        public void SendQ <T>(T value)
        {
            using (var _connection = CFactory.CreateConnection())
            {
                using (var _channel = _connection.CreateModel())
                {
                    _channel.QueueDeclare(queue: QueueName, durable: false, exclusive: false, autoDelete: false, arguments: null);

                    var _payload = JsonConvert.SerializeObject(value);
                    var _body    = Encoding.UTF8.GetBytes(_payload);

                    _channel.BasicPublish(exchange: "", routingKey: QueueName, basicProperties: null, body: _body);
                }
            }
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <param name="topic"></param>
        public void SendQ <T>(T value, string topic = null)
        {
            var _topic = topic ?? Topics[0];

            using (var _connection = CFactory.CreateConnection())
            {
                using (var _channel = _connection.CreateModel())
                {
                    _channel.ExchangeDeclare(exchange: ExchangeName, type: "topic");

                    var _payload = JsonConvert.SerializeObject(value);
                    var _body    = Encoding.UTF8.GetBytes(_payload);

                    _channel.BasicPublish(exchange: ExchangeName, routingKey: _topic, basicProperties: null, body: _body);
                }
            }
        }
        public ICFactory CreateCFactory()
        {
            ICFactory factory = null;

            try
            {
                factory = new CFactory();
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(factory);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        public async Task SendQAsync <T>(T value)
        {
            await Task.Run(() =>
            {
                using (var _connection = CFactory.CreateConnection())
                {
                    using (var _channel = _connection.CreateModel())
                    {
                        _channel.ExchangeDeclare(exchange: ExchangeName, type: "fanout");

                        var _payload = JsonConvert.SerializeObject(value);
                        var _body    = Encoding.UTF8.GetBytes(_payload);

                        _channel.BasicPublish(exchange: ExchangeName, routingKey: "", basicProperties: null, body: _body);
                    }
                }
            });
        }
Example #8
0
        public void TestFactory()
        {
            int count = Enum.GetNames(typeof(FactoryType)).Length;

            for (int i = 0; i < count; i++)
            {
                CFactory fact = FactoryFactory.CreateFactory((FactoryType)i);
                if (fact == null)
                {
                    continue;
                }
                bool good = fact.TestFactory();
                if (!good)
                {
                    Assert.IsTrue(good);
                }
            }
        }
Example #9
0
        public void TextExcludeWhatHave()
        {
            CFactory    test1  = FactoryFactory.CreateFactory(FactType.ftBackary);
            CFactory    test2  = FactoryFactory.CreateFactory(FactType.ftBackary);
            CSmartArray array1 = new CSmartArray();
            CSmartArray array2 = new CSmartArray();

            array1.Add("хлеб", 1);
            array2.Add("хлеб", 1);
            Assert.AreEqual(array1.GetCount(), 1);
            test1.SetInput(array1);
            Assert.AreEqual(array1.GetCount(), 0);
            Assert.AreEqual(array2.GetCount(), 1);
            test2.SetInput(array2);
            Assert.AreEqual(array2.GetCount(), 0);
            test1.ExcludeWhatHave(test2);
            Assert.AreEqual(test1.GetSmartInput().GetCount(), 0);
            Assert.AreEqual(test2.GetSmartInput().GetCount(), 1);
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        public async Task SendQAsync <T>(T value)
        {
            await Task.Run(() =>
            {
                using (var _connection = CFactory.CreateConnection())
                {
                    using (var _channel = _connection.CreateModel())
                    {
                        _channel.QueueDeclare(queue: QueueName, durable: true, exclusive: false, autoDelete: false, arguments: null);

                        var _payload = JsonConvert.SerializeObject(value);
                        var _body    = Encoding.UTF8.GetBytes(_payload);

                        var _properties = _channel.CreateBasicProperties();
                        //_properties.SetPersistent(true);
                        _properties.DeliveryMode = 2;

                        _channel.BasicPublish(exchange: "", routingKey: QueueName, basicProperties: _properties, body: _body);
                    }
                }
            });
        }
Example #11
0
        private bool make(
            string configFilePath,              // sure this is full path
            bool isReleaseMode,
            string gccConfigName,
            int jobs,
            string projectNameToBuild,
            bool isVerbose,
            string outputFolderPath)
        {
            CConsole.writeInfoLine("Config file: " + configFilePath);
            CConsole.writeInfoLine("Type of build: " + (isReleaseMode ? "release" : "debug"));
            CConsole.writeInfoLine("GCC config name: " + (string.IsNullOrEmpty(gccConfigName) ? "<default>" : gccConfigName));
            CConsole.writeInfoLine("Jobs: " + jobs);
            CConsole.writeInfoLine("Project to build: " + (string.IsNullOrEmpty(projectNameToBuild) ? "all" : projectNameToBuild));
            CConsole.writeInfoLine("Is verbose: " + (isVerbose ? "yes" : "no"));
            CConsole.writeInfoLine("Out folder: " + (string.IsNullOrEmpty(outputFolderPath) ? "<default>" : outputFolderPath));

            CConsole.writeLine();

            DateTime totalTimeBegin = DateTime.Now;
            bool     result         = true;

            XmlDocument win2TizXmlDoc;

            #region Load config file
            {
                CConsole.writeInfoLine("Load config file: " + configFilePath);
                win2TizXmlDoc = new XmlDocument();
                try
                {
                    win2TizXmlDoc.Load(configFilePath);
                }
                catch (Exception)
                {
                    CConsole.writeError("error: could not load config file " + configFilePath + "\n");
                    result = false;
                    goto my_end;
                }
            }
            #endregion

            string    slnWorkingDir;          // sure this is full path
            ASolution vcSolution;
            #region Load Visual solution file
            {
                slnWorkingDir = Path.GetDirectoryName(configFilePath);
                XmlNodeList nodes = win2TizXmlDoc.GetElementsByTagName(KXml.s_kSolutionTag);
                if (nodes == null || nodes.Count <= 0)
                {
                    CConsole.writeError("error: tag " + KXml.s_kSolutionTag + " is not found\n");
                    result = false;
                    goto my_end;
                }

                XmlAttribute attr = nodes[0].Attributes[KXml.s_kSolutionPathAttr];
                if (attr == null)
                {
                    CConsole.writeError("error: attribute " + KXml.s_kSolutionPathAttr + " of tag " + KXml.s_kSolutionTag + " is not found\n");
                    result = false;
                    goto my_end;
                }

                vcSolution = CFactory.createSolution();

                string vcSlnFilePath = PathUtils.combine(slnWorkingDir, attr.Value);
                CConsole.writeInfoLine("Load Visual solution file: " + vcSlnFilePath);
                if (!vcSolution.load(vcSlnFilePath))
                {
                    CConsole.writeError("error: could not load Visual solution file " + vcSlnFilePath + "\n");
                    result = false;
                    goto my_end;
                }
            }
            #endregion

            GccConfig gccConfig;
            #region Load GccConfig node
            {
                XmlNodeList nodes = win2TizXmlDoc.GetElementsByTagName(KXml.s_kCommonGccConfigTag);
                if (nodes == null || nodes.Count <= 0)
                {
                    CConsole.writeError("error: tag " + KXml.s_kCommonGccConfigTag + " is not found\n");
                    result = false;
                    goto my_end;
                }

                XmlNode nodeGccConfig = null;
                foreach (XmlNode node in nodes[0].ChildNodes)
                {
                    if (node.Name == KXml.s_kGccConfigTag && node.Attributes[KXml.s_kNameAttr] != null &&
                        node.Attributes[KXml.s_kNameAttr].Value == gccConfigName)
                    {
                        nodeGccConfig = node;
                        break;
                    }
                }

                if (nodeGccConfig == null)
                {
                    CConsole.writeWarning("warning: this is an old-style config file, the <CommonGccConfig> node will be used as <GccConfig> node\n");
                    nodeGccConfig = nodes[0];
                    gccConfigName = null;
                }

                gccConfig = new GccConfig(gccConfigName);
                if (!gccConfig.load(nodeGccConfig, isReleaseMode, slnWorkingDir))
                {
                    // TODO: when does it return false?
                }
            }
            CConsole.writeLine();
            #endregion

            string mainProjectName = gccConfig.get_MAIN_PROJECT();             // Can be null
            // Build only main project? It means buill all
            if (projectNameToBuild == mainProjectName)
            {
                projectNameToBuild = null;
            }
            bool onlyBuildOneProject =
                projectNameToBuild != null &&
                projectNameToBuild != "" &&
                projectNameToBuild != "all";

            List <XmlNode> projectNodesToBuild = new List <XmlNode>();

            #region Make projectNodesToBuild
            {
                XmlNodeList projectNodes = win2TizXmlDoc.GetElementsByTagName(KXml.s_kProjectTag);
                if (onlyBuildOneProject)
                {
                    foreach (XmlNode projectNode in projectNodes)
                    {
                        XmlAttribute nameAttr = projectNode.Attributes[KXml.s_kNameAttr];
                        if (nameAttr == null)
                        {
                            continue;
                        }
                        if (nameAttr.Value == projectNameToBuild)
                        {
                            projectNodesToBuild.Add(projectNode);
                            break;
                        }
                    }
                    if (projectNodesToBuild.Count == 0)
                    {
                        CConsole.writeError("error: project " + projectNameToBuild + " is not found in the config file\n");
                        result = false;
                        goto my_end;
                    }
                }
                else
                {
                    XmlNode mainProjectNode = null;
                    foreach (XmlNode projectNode in projectNodes)
                    {
                        XmlAttribute nameAttr = projectNode.Attributes[KXml.s_kNameAttr];
                        if (nameAttr == null)
                        {
                            continue;
                        }
                        if (nameAttr.Value == mainProjectName)
                        {
                            if (mainProjectNode == null)
                            {
                                mainProjectNode = projectNode;
                            }
                        }
                        else
                        {
                            projectNodesToBuild.Add(projectNode);
                        }
                    }
                    // mainProjectNode can be null
                    projectNodesToBuild.Add(mainProjectNode);
                }
            }
            #endregion

            //
            lock (m_lock)
            {
                m_builder = new Builder();
            }

            int projectCount = projectNodesToBuild.Count;             // Sure projectCount >= 1
            List <TDepProjectInfo> depProjectInfos = new List <TDepProjectInfo>();
            bool isSomethingNewFromDepProjects     = false;

            #region Loop through projectNodesToBuild to get list of commands to execute
            for (int i = 0; i < projectCount; i++)
            {
                XmlNode projectNode = projectNodesToBuild[i];
                if (projectNode == null)
                {
                    continue;
                }

                string projectName     = projectNode.Attributes[KXml.s_kNameAttr].Value;
                string projectNameSpec = projectName;

                CConsole.writeProject(projectName);

                AProject vcProject = vcSolution.getProject(projectName);
                if (vcProject == null)
                {
                    if (onlyBuildOneProject)
                    {
                        CConsole.writeError("error: project " + projectName + " is not found in the Visual solution, it will be ignored\n\n");
                        result = false;
                        goto my_end;
                    }

                    CConsole.writeWarning("warning: project " + projectName + " is not found in the Visual solution, it will be ignored\n\n");
                    continue;
                }

                #region Process S2G file
                {
                    XmlAttribute useS2GFileAttr = projectNode.Attributes[KXml.s_kUseS2GFileTag];
                    if (useS2GFileAttr != null)
                    {
                        XmlDocument s2gDoc = new XmlDocument();
                        try
                        {
                            s2gDoc.Load(PathUtils.combine(slnWorkingDir, useS2GFileAttr.Value));
                            XmlNodeList nodes = s2gDoc.GetElementsByTagName(KXml.s_kProjectTag);
                            if (nodes == null || nodes.Count <= 0)
                            {
                                CConsole.writeWarning("warning: could not found tag " + KXml.s_kProjectTag + " in the S2G file " +
                                                      useS2GFileAttr.Value + " for project " + projectName + ", it will not be used\n");
                            }
                            else
                            {
                                projectNode = nodes[0];                                 //===
                            }
                        }
                        catch (Exception)
                        {
                            CConsole.writeWarning("warning: could not found S2G file " +
                                                  useS2GFileAttr.Value + " for project " + projectName + ", it will not be used\n");
                        }
                    }
                }
                #endregion

                bool         isMainProject = !onlyBuildOneProject && i == projectCount - 1;
                EProjectType type          = EProjectType.eStaticLib;
                if (isMainProject)
                {
                    XmlAttribute tot = projectNode.Attributes["TargetOutType"];
                    type = (tot != null && tot.Value == "exe") ? EProjectType.eExecutable : EProjectType.eDynamicLib;
                }

                List <TCommand> projectCommands = CProject.load(
                    gccConfig, projectNode, vcProject, isReleaseMode,
                    type, depProjectInfos, isSomethingNewFromDepProjects,
                    slnWorkingDir, outputFolderPath,
                    out projectNameSpec);

                if (projectCommands == null)
                {
                    CConsole.writeError("error: something went wrong with project " + projectName + ", please double check\n\n");

                    result = false;
                    goto my_end;
                }

                CConsole.writeLine();

                if (isSignalToStop())
                {
                    result = false;
                    goto my_end;
                }

                //----------------------------------------------------------------------------------------
                m_builder.addCommands(projectCommands);
                //----------------------------------------------------------------------------------------

                if (!isMainProject)
                {
                    depProjectInfos.Add(new TDepProjectInfo(projectName, projectNameSpec));
                    if (projectCommands.Count > 0)
                    {
                        isSomethingNewFromDepProjects = true;
                    }
                }
            }
            #endregion

            result = m_builder.build(isVerbose, jobs);

my_end:

            m_builder = null;

            CConsole.writeTime("Total time: " + (DateTime.Now - totalTimeBegin).ToString() + "\n");

            return(result);
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="intercepter"></param>
        /// <param name="timeout_ms"></param>
        /// <param name="tokenSource"></param>
        public async Task RecvQ <T>(Func <T, ValueTask <string> > intercepter, int timeout_ms = 1000, CancellationTokenSource tokenSource = null)
        {
            await Task.Delay(0);

            using (var _connection = CFactory.CreateConnection())
            {
                using (var _channel = _connection.CreateModel())
                {
                    _channel.QueueDeclare(queue: QueueName, durable: false, exclusive: false, autoDelete: false, arguments: null);
                    _channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);

                    var _consumer = new EventingBasicConsumer(_channel);
                    _channel.BasicConsume(queue: QueueName, autoAck: false, consumer: _consumer);

                    _consumer.Received += async(model, evtargs) =>
                    {
                        if (tokenSource != null)
                        {
                            if (tokenSource.Token.IsCancellationRequested == true)
                            {
                                tokenSource.Token.ThrowIfCancellationRequested();
                            }
                        }

                        var _payload = evtargs.Body;
                        var _props   = evtargs.BasicProperties;

                        var _replyProps = _channel.CreateBasicProperties();
                        _replyProps.CorrelationId = _props.CorrelationId;

                        var _response = (string)null;

                        try
                        {
                            var _message = Encoding.UTF8.GetString(_payload);

                            var _value = JsonConvert.DeserializeObject <T>(_message);
                            _response = await intercepter(_value);
                        }
                        catch (Exception)
                        {
                            _response = "";
                        }
                        finally
                        {
                            var _responseBytes = Encoding.UTF8.GetBytes(_response);
                            _channel.BasicPublish(exchange: "", routingKey: _props.ReplyTo, basicProperties: _replyProps, body: _responseBytes);

                            _channel.BasicAck(deliveryTag: evtargs.DeliveryTag, multiple: false);
                        }
                    };

                    //while (true)
                    //{
                    //    BasicDeliverEventArgs _evtargs;
                    //    if (_consumer.Queue.Dequeue(timeout_ms, out _evtargs) == false)
                    //    {
                    //        if (tokenSource != null)
                    //        {
                    //            if (tokenSource.Token.IsCancellationRequested == true)
                    //                tokenSource.Token.ThrowIfCancellationRequested();
                    //        }

                    //        continue;
                    //    }

                    //    var _payload = _evtargs.Body;
                    //    var _props = _evtargs.BasicProperties;

                    //    var _replyProps = _channel.CreateBasicProperties();
                    //    _replyProps.CorrelationId = _props.CorrelationId;

                    //    var _response = (string)null;

                    //    try
                    //    {
                    //        var _message = Encoding.UTF8.GetString(_payload);

                    //        var _value = JsonConvert.DeserializeObject<T>(_message);
                    //        _response = await intercepter(_value);
                    //    }
                    //    catch (Exception)
                    //    {
                    //        _response = "";
                    //    }
                    //    finally
                    //    {
                    //        var _responseBytes = Encoding.UTF8.GetBytes(_response);
                    //        _channel.BasicPublish(exchange: "", routingKey: _props.ReplyTo, basicProperties: _replyProps, body: _responseBytes);

                    //        _channel.BasicAck(deliveryTag: _evtargs.DeliveryTag, multiple: false);
                    //    }
                    //}
                }
            }
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="intercepter"></param>
        /// <param name="timeout_ms"></param>
        /// <param name="cancelToken"></param>
        /// <returns></returns>
        public bool RecvQ <T>(Func <T, ValueTask <bool> > intercepter, int timeout_ms = 1000, CancellationToken?cancelToken = null)
        {
            var _result = true;

            using (var _connection = CFactory.CreateConnection())
            {
                using (var _channel = _connection.CreateModel())
                {
                    _channel.ExchangeDeclare(exchange: ExchangeName, type: "topic");

                    var _queueName = _channel.QueueDeclare().QueueName;
                    foreach (var _topic in Topics)
                    {
                        _channel.QueueBind(queue: _queueName, exchange: ExchangeName, routingKey: _topic);
                    }

                    var _consumer = new EventingBasicConsumer(_channel);

                    _consumer.Received += async(model, ea) =>
                    {
                        var _payload = ea.Body;
                        var _message = Encoding.UTF8.GetString(_payload);

                        var _value = JsonConvert.DeserializeObject <T>(_message);
                        if ((await intercepter(_value)) == false)
                        {
                            _result = false;
                        }
                    };

                    _channel.BasicConsume(queue: _queueName, autoAck: true, consumer: _consumer);

                    while (true)
                    {
                        if (cancelToken != null)
                        {
                            var _cancelled = cancelToken.Value.WaitHandle.WaitOne(timeout_ms * 1000);
                            if (_cancelled == true)
                            {
                                break;
                            }
                        }
                        else
                        {
                            Thread.Sleep(timeout_ms * 1000);
                        }
                    }

                    /*
                     * var _consumer = new EventingBasicConsumer(_channel);
                     * _channel.BasicConsume(queue: _queueName, noAck: true, consumer: _consumer);
                     *
                     * while (true)
                     * {
                     *  BasicDeliverEventArgs _evtargs;
                     *  if (_consumer.Queue.Dequeue(timeout_ms, out _evtargs) == false)
                     *  {
                     *      if (cancelToken != null)
                     *      {
                     *          if (cancelToken.Value.IsCancellationRequested == true)
                     *              cancelToken.Value.ThrowIfCancellationRequested();
                     *      }
                     *
                     *      continue;
                     *  }
                     *
                     *  var _payload = _evtargs.Body;
                     *  var _message = Encoding.UTF8.GetString(_payload);
                     *
                     *  var _value = JsonConvert.DeserializeObject<T>(_message);
                     *  if (await intercepter(_value) == false)
                     *  {
                     *      _result = false;
                     *      break;
                     *  }
                     * }
                     */
                }
            }

            return(_result);
        }
Example #14
0
 public CFactoryTest(FactType type)
 {
     m_pFactory = FactoryFactory.CreateFactory(type);
 }
Example #15
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="intercepter"></param>
        /// <param name="timeout_ms"></param>
        /// <param name="cancelToken"></param>
        /// <returns></returns>
        public async ValueTask <bool> RecvQAsync <T>(Func <T, ValueTask <bool> > intercepter, int timeout_ms = 1000, CancellationToken?cancelToken = null)
        {
            var _result = true;

            await Task.Run(() =>
            {
                using (var _connection = CFactory.CreateConnection())
                {
                    using (var _channel = _connection.CreateModel())
                    {
                        _channel.QueueDeclare(queue: QueueName, durable: true, exclusive: false, autoDelete: false, arguments: null);
                        _channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);

                        var _consumer = new EventingBasicConsumer(_channel);

                        _consumer.Received += async(model, ea) =>
                        {
                            var _payload = ea.Body;
                            var _message = Encoding.UTF8.GetString(_payload);

                            var _value = JsonConvert.DeserializeObject <T>(_message);
                            if ((await intercepter(_value)) == true)
                            {
                                _channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
                            }
                            else
                            {
                                _result = false;
                            }
                        };

                        _channel.BasicConsume(queue: QueueName, autoAck: false, consumer: _consumer);

                        while (true)
                        {
                            if (cancelToken != null)
                            {
                                var _cancelled = cancelToken.Value.WaitHandle.WaitOne(timeout_ms * 1000);
                                if (_cancelled == true)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                Thread.Sleep(timeout_ms * 1000);
                            }
                        }

                        /*
                         * var _consumer = new EventingBasicConsumer(_channel);
                         * _channel.BasicConsume(queue: QueueName, noAck: false, consumer: _consumer);
                         *
                         * while (true)
                         * {
                         *  BasicDeliverEventArgs _evtargs;
                         *  if (_consumer.Queue.Dequeue(timeout_ms, out _evtargs) == false)
                         *  {
                         *      if (cancelToken != null)
                         *      {
                         *          if (cancelToken.Value.IsCancellationRequested == true)
                         *              cancelToken.Value.ThrowIfCancellationRequested();
                         *      }
                         *
                         *      continue;
                         *  }
                         *
                         *  var _payload = _evtargs.Body;
                         *  var _message = Encoding.UTF8.GetString(_payload);
                         *
                         *  var _value = JsonConvert.DeserializeObject<T>(_message);
                         *  if ((await intercepter(_value)) == false)
                         *  {
                         *      _result = false;
                         *      break;
                         *  }
                         *
                         *  _channel.BasicAck(deliveryTag: _evtargs.DeliveryTag, multiple: false);
                         * }
                         */
                    }
                }
            });

            return(_result);
        }