Treefrog.Framework.Model.BoolProperty.Parse C# (CSharp) Method

Parse() public method

public Parse ( string value ) : void
value string
return void
        public override void Parse(string value)
        {
            try {
                Value = Convert.ToBoolean(value);
            }
            catch (Exception e) {
                throw new ArgumentException("Failed to convert value to this property's value type.", e);
            }
        }

Usage Example

Example #1
0
        public void ParseBoolTrue()
        {
            Property prop = new BoolProperty("test", false);
            AttachEvents(prop);

            prop.ValueChanged += (s, e) =>
            {
                Assert.AreSame(prop, s);
                Assert.AreEqual(true, ((BoolProperty)prop).Value);
            };

            prop.Parse("true");

            Assert.AreEqual(true, ((BoolProperty)prop).Value);
            Assert.AreEqual(EventFlags.ValueChanged | EventFlags.Modified, _eventsFired);
        }