GetBoolean() public method

Returns a bool that contains the value of the specified variable.
public GetBoolean ( string name, bool defaultValue ) : bool
name string The name of the variable to be read.
defaultValue bool The value to be returned if returns null.
return bool
Example #1
0
        public void GetBoolean()
        {
            VariableAccessor va = new VariableAccessor(_testVariableSource);

            Assert.AreEqual(true, va.GetBoolean("ValidBoolean", false));
            Assert.AreEqual(true, va.GetBoolean("InvalidBoolean", true, false));
        }
        /// <summary>
        /// Initializes a new <see cref="ConfigSectionSessionScopeSettings"/> instance.
        /// </summary>
        /// <param name="ownerType">The type, who's name will be used to prefix setting variables with</param>
        /// <param name="variableSource">The variable source to obtain settings from.</param>
        public ConfigSectionSessionScopeSettings(Type ownerType, IVariableSource variableSource)
            : base()
        {
            string sessionFactoryObjectNameSettingsKey = UniqueKey.GetTypeScopedString(ownerType, "SessionFactoryObjectName");
            string entityInterceptorObjectNameSettingsKey = UniqueKey.GetTypeScopedString(ownerType, "EntityInterceptorObjectName");
            string singleSessionSettingsKey = UniqueKey.GetTypeScopedString(ownerType, "SingleSession");
            string defaultFlushModeSettingsKey = UniqueKey.GetTypeScopedString(ownerType, "DefaultFlushMode");

            VariableAccessor variables = new VariableAccessor(variableSource);
            this.sessionFactoryObjectName = variables.GetString(sessionFactoryObjectNameSettingsKey, DEFAULT_SESSION_FACTORY_OBJECT_NAME);
            this.entityInterceptorObjectName = variables.GetString(entityInterceptorObjectNameSettingsKey, null);
            this.SingleSession = variables.GetBoolean(singleSessionSettingsKey, this.SingleSession);
            this.DefaultFlushMode = (FlushMode)variables.GetEnum(defaultFlushModeSettingsKey, this.DefaultFlushMode);

            AssertUtils.ArgumentNotNull(sessionFactoryObjectName, "sessionFactoryObjectName"); // just to be sure
        }
 public void GetBoolean()
 {
     VariableAccessor va = new VariableAccessor(_testVariableSource);
     Assert.AreEqual(true, va.GetBoolean("ValidBoolean", false));
     Assert.AreEqual(true, va.GetBoolean("InvalidBoolean", true, false));
     try
     {
         va.GetBoolean("InvalidBoolean", true, true);
         Assert.Fail();
     }catch {}
 }