Пример #1
0
        private static ValueExpression splitIntoComposite(string text)
        {
            var composite = CompositeValue.Parse(text);

            // If there's only one component, this really was a single value
            if (composite.Components.Length == 1)
            {
                return(composite.Components[0]);
            }
            else
            {
                return(composite);
            }
        }
Пример #2
0
        public void HandleComposites()
        {
            var pX = new CompositeValue(new ValueExpression[] { new StringValue("hello, world!"), new NumberValue(14.8M) });
            var pY = new TokenValue("NOK", "http://somesuch.org");
            var p1 = new ChoiceValue(new ValueExpression[] { pX, pY });
            Assert.AreEqual(@"hello\, world!$14.8,http://somesuch.org|NOK", p1.ToString());

            var crit1 = ChoiceValue.Parse(@"hello\, world$14.8,http://somesuch.org|NOK");
            Assert.AreEqual(2, crit1.Choices.Length);
            Assert.IsTrue(crit1.Choices[0] is CompositeValue);
            var comp1 = crit1.Choices[0] as CompositeValue;
            Assert.AreEqual(2, comp1.Components.Length);
            Assert.AreEqual("hello, world", ((UntypedValue)comp1.Components[0]).AsStringValue().Value);
            Assert.AreEqual(14.8M, ((UntypedValue)comp1.Components[1]).AsNumberValue().Value);
            Assert.AreEqual("http://somesuch.org|NOK", ((UntypedValue)crit1.Choices[1]).AsTokenValue().ToString());
        }