コード例 #1
0
ファイル: UnitsOfMeasure.cs プロジェクト: schellack/spark
        // This code might have a better place somewhere else: //mh
        public static Model.Quantity ToModelQuantity(this ValueExpression expression)
        {
            QuantityValue q = QuantityValue.Parse(expression.ToString());

            Model.Quantity quantity = new Model.Quantity
            {
                Value  = q.Number,
                System = q.Namespace,
                Units  = q.Unit,
                Code   = q.Unit
            };
            return(quantity);
        }
コード例 #2
0
ファイル: CriteriumTests.cs プロジェクト: ztfuqingvip/spark
        public void HandleQuantityParam()
        {
            var p1 = new QuantityValue(3.141M, "http://unitsofmeasure.org", "mg");

            Assert.AreEqual("3.141|http://unitsofmeasure.org|mg", p1.ToString());

            var p2 = new QuantityValue(3.141M, "mg");

            Assert.AreEqual("3.141||mg", p2.ToString());

            var p3 = new QuantityValue(3.141M, "http://system.com/id$4", "$/d");

            Assert.AreEqual(@"3.141|http://system.com/id\$4|\$/d", p3.ToString());

            var p4 = QuantityValue.Parse("3.141|http://unitsofmeasure.org|mg");

            Assert.AreEqual(3.141M, p4.Number);
            Assert.AreEqual("http://unitsofmeasure.org", p4.Namespace);
            Assert.AreEqual("mg", p4.Unit);

            var p5 = QuantityValue.Parse("3.141||mg");

            Assert.AreEqual(3.141M, p5.Number);
            Assert.IsNull(p5.Namespace);
            Assert.AreEqual("mg", p5.Unit);

            var p6 = QuantityValue.Parse(@"3.141|http://system.com/id\$4|\$/d");

            Assert.AreEqual(3.141M, p6.Number);
            Assert.AreEqual("http://system.com/id$4", p6.Namespace);
            Assert.AreEqual("$/d", p6.Unit);

            var crit = Criterium.Parse("paramX=3.14||mg");
            var p7   = ((UntypedValue)crit.Operand).AsQuantityValue();

            Assert.AreEqual(3.14M, p7.Number);
            Assert.IsNull(p7.Namespace);
            Assert.AreEqual("mg", p7.Unit);
        }
コード例 #3
0
 public QuantityValue AsQuantityValue()
 {
     return(QuantityValue.Parse(Value));
 }