コード例 #1
0
        /// <summary>
        /// Using CSV-like results fetched from Scalarm (list of ValuesMap) and knowning input parameter ids,
        /// create a list of SimulationParams, which have Input and Output fields that contain values maps
        /// splitted into input parameters and output (results).
        /// </summary>
        /// <returns>List of SimulationParams objects. Each is a result from single simulation run.</returns>
        /// <param name="results">Results fetched from Scalarm in form of list of ValuesMap (see GetResults HTTP method).</param>
        /// <param name="parametersIds">Ids of input parameters for disinguishing input parameters from outputs.</param>
        public virtual IList <SimulationParams> MakeResults(IList <ValuesMap> results, IList <string> parametersIds)
        {
            List <SimulationParams> convertedResults = new List <SimulationParams>();

            foreach (var result in results)
            {
                ValuesMap input  = new ValuesMap();
                ValuesMap output = new ValuesMap();

                SimulationParams singleResult = new SimulationParams(input, output);

                foreach (string id in result.Keys)
                {
                    if (parametersIds.Contains(id))
                    {
                        singleResult.Input.Add(id, result[id]);
                    }
                    else
                    {
                        singleResult.Output.Add(id, result[id]);
                    }
                }

                convertedResults.Add(singleResult);
            }

            return(convertedResults);
        }
コード例 #2
0
        public void TestCastFromPair()
        {
            var v1 = new ValuesMap()
            {
                { "a", 1 }
            };
            var v2 = new ValuesMap()
            {
                { "b", 2 }
            };
            var pair = new KeyValuePair <ValuesMap, ValuesMap>(v1, v2);

            SimulationParams converted = (SimulationParams)pair;

            Assert.AreEqual(1, converted.Input["a"]);
            Assert.AreEqual(2, converted.Output["b"]);

            var list = new List <KeyValuePair <ValuesMap, ValuesMap> > ()
            {
                new KeyValuePair <ValuesMap, ValuesMap>(v1, v2)
            };

            Assert.AreEqual(1, list.Select(p => (SimulationParams)p).ToList()[0].Input["a"]);
        }