예제 #1
0
 public void ConversionUtility_ToBoolean_1()
 {
     Assert.AreEqual(true, ConversionUtility.ToBoolean("true"));
     Assert.AreEqual(true, ConversionUtility.ToBoolean("yes"));
     Assert.AreEqual(false, ConversionUtility.ToBoolean("false"));
     Assert.AreEqual(false, ConversionUtility.ToBoolean("no"));
 }
예제 #2
0
        /// <summary>
        /// Get boolean value from application configuration.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static bool GetBoolean
        (
            string key,
            bool defaultValue)
        {
            string s = CM.AppSettings [key];

            if (!string.IsNullOrEmpty(s))
            {
                defaultValue = ConversionUtility.ToBoolean(s);
            }
            return(defaultValue);
        }
        /// <summary>
        /// Get boolean value from application configuration.
        /// </summary>
        public static bool GetBoolean
        (
            [NotNull] string key,
            bool defaultValue = false
        )
        {
            bool   result  = defaultValue;
            string setting = CM.AppSettings[key];

            if (!string.IsNullOrEmpty(setting))
            {
                result = ConversionUtility.ToBoolean(setting);
            }

            return(result);
        }
예제 #4
0
        /// <summary>
        /// Get boolean value from application configuration.
        /// </summary>
        public static bool GetBoolean
        (
            [NotNull] string key,
            bool defaultValue
        )
        {
#if DROID || ANDROID || UAP
            return(defaultValue);
#else
            bool   result = defaultValue;
            string s      = CM.AppSettings[key];
            if (!string.IsNullOrEmpty(s))
            {
                result = ConversionUtility.ToBoolean(s);
            }

            return(result);
#endif
        }
예제 #5
0
 public void ConversionUtility_ToBoolean_6()
 {
     ConversionUtility.ToBoolean("bullshit");
 }
예제 #6
0
 public void ConversionUtility_ToBoolean_5()
 {
     ConversionUtility.ToBoolean(new SourceType2());
 }
예제 #7
0
 public void ConversionUtility_ToBoolean_4()
 {
     // TypeConverter
     Assert.AreEqual(false, ConversionUtility.ToBoolean(new SourceType()));
 }
예제 #8
0
 public void ConversionUtility_ToBoolean_3()
 {
     // value is IConverttible
     Assert.AreEqual(true, ConversionUtility.ToBoolean(1));
     Assert.AreEqual(false, ConversionUtility.ToBoolean(0));
 }
예제 #9
0
 public void ConversionUtility_ToBoolean_2()
 {
     // value is bool
     Assert.AreEqual(true, ConversionUtility.ToBoolean(true));
     Assert.AreEqual(false, ConversionUtility.ToBoolean(false));
 }