Beispiel #1
0
        public void TestSerialize()
        {
            var json      = _params.SerializeJson();
            var newParams = ParamDescriptorExtensions.DeserializeJson(json, _params);

            Assert.Equal(10.0m, newParams.ConvertNum("num"));
            Assert.Equal("string", newParams.ConvertStr("str"));
            Assert.Equal(constDate, newParams.ConvertDate("dat"));
        }
Beispiel #2
0
        public void TestSetStr()
        {
            var json      = _params.SerializeJson();
            var newParams = ParamDescriptorExtensions.DeserializeJson(json, _params);

            Assert.Equal("string", newParams.ConvertStr("str"));
            newParams.SetStr("str", "roman");
            Assert.Equal("roman", newParams.ConvertStr("str"));
            Assert.Equal("string", _params.ConvertStr("str"));
        }
Beispiel #3
0
        public void TestSetDate()
        {
            var json      = _params.SerializeJson();
            var newParams = ParamDescriptorExtensions.DeserializeJson(json, _params);

            Assert.Equal(constDate, newParams.ConvertDate("dat"));
            newParams.SetDat("dat", constDate.AddDays(1));
            Assert.Equal(constDate.AddDays(1), newParams.ConvertDate("dat"));
            Assert.Equal(constDate, _params.ConvertDate("dat"));
        }
Beispiel #4
0
        public void TesSetNum()
        {
            var json      = _params.SerializeJson();
            var newParams = ParamDescriptorExtensions.DeserializeJson(json, _params);

            Assert.Equal(10.0m, newParams.ConvertNum("num"));
            newParams.SetNum("num", 11.0m);
            Assert.Equal(11.0m, newParams.ConvertNum("num"));
            Assert.Equal(10.0m, _params.ConvertNum("num"));
        }
        public IAlgorithm GetCalculation(CalculationJson json)
        {
            if (json.TaskType == (long)TaskTypes.DownloadCurrenciesCbrf)
            {
                var calculation = new DownloadForeignExchange(_logger,
                                                              _taskAction,
                                                              _cbrDownloader,
                                                              _xmlSave);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            if (json.TaskType == (long)TaskTypes.DownloadMosPrimeCbrf)
            {
                var calculation = new DownloadMosprime(_logger,
                                                       _taskAction,
                                                       _cbrDownloader,
                                                       _xmlSave);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            if (json.TaskType == (long)TaskTypes.DownloadKeyRateCbrf)
            {
                var calculation = new DownloadKeyRate(_logger,
                                                      _taskAction,
                                                      _cbrDownloader,
                                                      _xmlSave);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            if (json.TaskType == (long)TaskTypes.DownloadRoisFixCbrf)
            {
                var calculation = new DownloadRoisfix(_logger,
                                                      _taskAction,
                                                      _cbrDownloader,
                                                      _xmlSave);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            if (json.TaskType == (long)TaskTypes.DownloadRuoniaCbrf)
            {
                var calculation = new DownloadRuonia(_logger,
                                                     _taskAction,
                                                     _cbrDownloader,
                                                     _xmlSave);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            if (json.TaskType == (long)TaskTypes.DownloadMoexInstruments)
            {
                var calculation = new DownloadMoexInstruments(_logger,
                                                              _taskAction,
                                                              _moexDownloader,
                                                              _xmlSave,
                                                              _csvSaver);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            if (json.TaskType == (long)TaskTypes.SaveForeignExchange)
            {
                var calculation = new SaveForeignExchange(_logger,
                                                          _taskAction,
                                                          _convertFactory,
                                                          _saverMurrData,
                                                          _cbrDownloader);
                List <ParamDescriptor> values = ParamDescriptorExtensions.DeserializeJson(json.JsonParameters, calculation.GetParamDescriptors());
                foreach (var val in values)
                {
                    calculation.SetParamDescriptors(val);
                }
                return(calculation);
            }

            return(null);
        }