private static LayoutOptions GetLayoutOptions(string option)
        {
            LayoutOptionsConverter converter = new LayoutOptionsConverter();

            if (option != null && option != "")
            {
                return((LayoutOptions)converter.ConvertFromInvariantString(option));
            }

            return(LayoutOptions.Fill);
        }
		public void TestTypeConverter ()
		{
			var converter = new LayoutOptionsConverter ();
			Assert.True (converter.CanConvertFrom (typeof(string)));
			Assert.AreEqual (LayoutOptions.Center, converter.ConvertFromInvariantString ("LayoutOptions.Center"));
			Assert.AreEqual (LayoutOptions.Center, converter.ConvertFromInvariantString ("Center"));
			Assert.AreNotEqual (LayoutOptions.CenterAndExpand, converter.ConvertFromInvariantString ("Center"));
			Assert.Throws<InvalidOperationException> (() => converter.ConvertFromInvariantString ("foo"));
			Assert.Throws<InvalidOperationException> (() => converter.ConvertFromInvariantString ("foo.bar"));
			Assert.Throws<InvalidOperationException> (() => converter.ConvertFromInvariantString ("foo.bar.baz"));
		}
Exemple #3
0
        public void TestTypeConverter()
        {
            var converter = new LayoutOptionsConverter();

            Assert.True(converter.CanConvertFrom(typeof(string)));
            Assert.AreEqual(LayoutOptions.Center, converter.ConvertFromInvariantString("LayoutOptions.Center"));
            Assert.AreEqual(LayoutOptions.Center, converter.ConvertFromInvariantString("Center"));
            Assert.AreNotEqual(LayoutOptions.CenterAndExpand, converter.ConvertFromInvariantString("Center"));
            Assert.Throws <InvalidOperationException>(() => converter.ConvertFromInvariantString("foo"));
            Assert.Throws <InvalidOperationException>(() => converter.ConvertFromInvariantString("foo.bar"));
            Assert.Throws <InvalidOperationException>(() => converter.ConvertFromInvariantString("foo.bar.baz"));
        }
Exemple #4
0
 public override object ConvertFrom(object o)
 {
     return(_converter.ConvertFromInvariantString(o as string));
 }