Ejemplo n.º 1
0
        // ----------------------------------------------------------------------------------------
        //  Short methods and properties
        /* ------------------------------------------------------------------------------------- */ /// <summary>Determines whether a particular file exists in the location identified by a folder path in a string member</summary>
        //public static bool FileExistsAt(object inObject, string folderMemberName, string fileName) { return FileAt(inObject, folderMemberName, fileName).Exists  ; }
        //public static void DeleteFileAt(object inObject, string folderMemberName, string fileName) {        FileAt(inObject, folderMemberName, fileName).Delete(); }


        // ----------------------------------------------------------------------------------------
        /// <!-- BoolValueSet -->
        /// <summary>
        ///      Changes a boolean member value
        /// </summary>
        /// <param name="inObject">the object containing the member</param>
        /// <param name="memberName">the name of the member</param>
        /// <param name="value"></param>
        /// <returns>the original boolean value or false if it was null or not boolean</returns>
        public static bool BoolValueSet(object inObject, string memberName, bool value)
        {
            FieldInfo member = inObject.GetType().GetField(memberName
                                                           , BindingFlags.Public
                                                           | BindingFlags.Instance
                                                           | BindingFlags.NonPublic
                                                           | BindingFlags.Static);
            object before = member.GetValue(inObject);

            member.SetValue(inObject, value);
            return(TreatAs.BoolValue(before, false));
        }
Ejemplo n.º 2
0
        // ----------------------------------------------------------------------------------------
        /// <!-- Bool -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="form">allows no-op if the control is not on the form</param>
        /// <param name="control"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static Boolean Bool(Form form, Control control, bool defaultValue)
        {
            Boolean value = defaultValue;

            if (Active(form, control))
            {
                if (control.GetType() == typeof(RadioButton))
                {
                    value = ((RadioButton)control).Checked;
                }
                else
                {
                    value = TreatAs.BoolValue(control.Text, defaultValue);
                }
            }
            return(value);
        }
Ejemplo n.º 3
0
        // ----------------------------------------------------------------------------------------
        //  Custom Methods
        // ----------------------------------------------------------------------------------------


        // ----------------------------------------------------------------------------------------
        /// <!-- _Bool -->
        /// <summary>
        ///
        /// </summary>
        /// <param name="xdoc"></param>
        /// <param name="namespacePrefix"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public bool _Bool(PathSlicer xpath, string namespacePrefix, bool defaultValue)
        {
            return(TreatAs.BoolValue(_Str(xpath, namespacePrefix, ""), defaultValue));
        }
Ejemplo n.º 4
0
        private static void TreatAs_BoolValue_testcase(object obj, bool defaultValue, bool target)
        {
            bool value = TreatAs.BoolValue(obj, defaultValue);

            Assert.That(value, Is.equal_to, target);
        }