IsBoolString() static public method

Determine if the passed in string represents a 'true' of 'false' string and return it. If it's not determined, then return the default value.
static public IsBoolString ( string text, bool defaultValueIfUnknown ) : bool
text string string to examine for t or f
defaultValueIfUnknown bool true or false
return bool
コード例 #1
0
        public bool ReadXmlNode(XmlNode optDef)
        {
            bool success = true;

            foreach (XmlAttribute Attribute in optDef.Attributes)
            {
                switch (Attribute.Name)
                {
                case "id":
                    if (Attribute.Value == "")
                    {
                        success = false;
                    }
                    else
                    {
                        m_id = Attribute.Value;
                    }
                    break;

                case "type":
                    if (Attribute.Value == "")
                    {
                        success = false;
                    }
                    else
                    {
                        m_type = Attribute.Value;
                    }
                    break;

                case "checked":
                    if (Attribute.Value == "")
                    {
                        success = false;
                    }
                    else
                    {
                        m_isChecked = STATICS.IsBoolString(Attribute.Value, false);
                    }
                    break;

                default:
                    Converter.Log.AddWarning(String.Format(Sfm2XmlStrings.UnknownAttribute0InTheOptions, Attribute.Name));
                    break;
                }
            }

            if (!string.IsNullOrEmpty(Id))
            {
                return(success);
            }

            Converter.Log.AddError(Sfm2XmlStrings.IdNotDefinedInAnOption);
            return(false);
        }
コード例 #2
0
        new public bool ReadXmlNode(System.Xml.XmlNode customfieldNode, Hashtable languages, string topAnalysisWS)
        {
            // Iterate through all the attributes of the "field" sub-element of this custom field:
            System.Xml.XmlNode fieldNode = customfieldNode.SelectSingleNode("field");
            if (fieldNode == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.NoFieldNodeInTheCustomField, m_Sfm));
                return(false);
            }
            else
            {
                if (!base.ReadXmlNode(fieldNode, languages, "en"))
                {
                    return(false);
                }
            }

            foreach (System.Xml.XmlAttribute Attribute in customfieldNode.Attributes)
            {
                // Create new attribute details, which may be altered later on:
                string NewName  = Attribute.Name;
                string NewValue = Attribute.Value;
                switch (Attribute.Name)
                {
//					case "guid":
//						m_guid = Attribute.Value;
//						break;
                case "wsSelector":
                    m_wsSelector = Convert.ToInt32(Attribute.Value);
                    break;

                case "big":
                    m_big = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                case "flid":
                    m_flid = Convert.ToInt32(Attribute.Value);
                    break;

                case "class":
                    m_class = NewValue;
                    break;

                case "uiclass":
                    m_uiClass = NewValue;
                    break;

                default:
                    throw new Exception("Invalid attribute on Custom Field Element.");
                }
            }

            return(true);
        }
コード例 #3
0
        public bool ReadXmlNode(System.Xml.XmlNode node, Hashtable languages)
        {
            bool Success = true;

            m_fEndWithField = false;
            m_fEndWithWord  = false;
            foreach (System.Xml.XmlAttribute Attribute in node.Attributes)
            {
                // Create new attribute details, which may be altered later on:
                string newValue = Attribute.Value;
                switch (Attribute.Name)
                {
                case "element":
                    m_XmlElementName = Attribute.Value;
                    break;

                case "begin":
                    m_Begin = Attribute.Value;
                    break;

                case "end":
                case "endList":
                    STATICS.SplitString(newValue, delim, ref m_EndList);
                    break;

                case "endWithField":
                    m_fEndWithField = IsTrue(Attribute.Value);
                    break;

                case "endWithWord":
                    m_fEndWithWord = IsTrue(Attribute.Value);
                    break;

                /*
                 * case "lang":
                 * // Look up replacement language name:
                 * ClsLanguage language = languages[Attribute.Value] as ClsLanguage;
                 * if (language == null)
                 * {
                 *      Converter.Log.AddError("Error in Mapping File: Unknown 'lang' value '" + Attribute.Value + "' in the 'fieldDescriptions' section.");
                 *      m_xmlLanguage = newValue;
                 * }
                 * else
                 *      m_xmlLanguage = language.XmlLang;
                 *
                 * m_Language = newValue;
                 * break;
                 * */
                case "lang":
                    newValue = null;
                    // Look up replacement language name:
                    ClsLanguage language = languages[Attribute.Value] as ClsLanguage;
                    if (language != null)
                    {
                        newValue   = language.XmlLang;
                        m_Language = language.KEY;
                        m_xmlLang  = language.XmlLang;
                    }
                    else
                    {
                        Converter.Log.AddError(String.Format(Sfm2XmlStrings.UnknownLangValue0InTheInFieldMarkers, Attribute.Value));
                        newValue = Attribute.Value;
                    }
                    break;

                case "style":
                    m_style = Attribute.Value;
                    break;

                case "ignore":
                    m_ignore = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                default:
                    Converter.Log.AddWarning(String.Format(Sfm2XmlStrings.UnknownAttribute0InTheInFieldMarkers, Attribute.Name));
                    Success = false;
                    break;
                }
            }

            if (m_Begin == null)
            {
                Converter.Log.AddError(Sfm2XmlStrings.BeginNotDefinedInAnInFieldMarker);
                Success = false;
            }
            if (m_EndList.Count == 0 && !m_fEndWithWord && !m_fEndWithField)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.InFieldMarker0HasNoEndAttribute, m_Begin));
                Success = false;
            }
            if (m_XmlElementName == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.InFieldMarker0HasNoElementNameAttribute, m_Begin));
                Success = false;
            }

            return(Success);
        }
コード例 #4
0
        public bool ReadXmlNode(System.Xml.XmlNode fieldNode, Hashtable languages, string topAnalysisWS)
        {
            m_OtherAttributes = "";
////			string allAttributes = "<field ";

            foreach (System.Xml.XmlAttribute Attribute in fieldNode.Attributes)
            {
                // Create new attribute details, which may be altered later on:
                string NewName  = Attribute.Name;
                string NewValue = Attribute.Value;
                switch (Attribute.Name)
                {
                case "sfm":
                    m_Sfm = Attribute.Value;
                    break;

                case "name":
                    m_Name = Attribute.Value;
                    break;

                case "type":
                    m_Type = Attribute.Value;
                    break;

                case "lang":
////						NewName = "xml:lang";
////						NewValue = Attribute.Value;
                    // Look up replacement language name:
                    ClsLanguage language = languages[Attribute.Value] as ClsLanguage;
                    if (language == null)
                    {
                        Converter.Log.AddError(String.Format(Sfm2XmlStrings.UnknownLangValue0InFieldDescs, Attribute.Value));
                        m_xmlLanguage = NewValue;
                    }
                    else
                    {
                        m_xmlLanguage = language.XmlLang;
                    }

                    m_Language = NewValue;
                    break;

                case "abbr":
                    IsAbbr = STATICS.IsBoolString(Attribute.Value, true);
                    break;

                case "exclude":
                    IsExcluded = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                case "autoImport":
                    IsAutoImportField = STATICS.IsBoolString(Attribute.Value, false);
                    break;

                case "autoSfm":                         // just ignore for now and re-assign
                    break;

                default:
                    m_OtherAttributes += " " + NewName + "=\"" + NewValue + "\"";
                    break;
                }
////				allAttributes += " " + NewName + "=\"" + NewValue + "\"";
            }

////			allAttributes += ">";

            // Iterate through all the attributes of the "meaning" sub-element of this field:
            System.Xml.XmlNode Meaning = fieldNode.SelectSingleNode("meaning");
            if (Meaning == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.MissingMeaningElementInField0InFieldDescs, m_Sfm));
            }
            else
            {
                m_Meaning = "<meaning ";

                foreach (System.Xml.XmlAttribute Attribute in Meaning.Attributes)
                {
                    m_Meaning += Attribute.Name + "=\"" + Attribute.Value + "\" ";
                    if (Attribute.Name == "app")
                    {
                        m_meaningApp = Attribute.Value;
                    }
                    else if (Attribute.Name == "id")
                    {
                        m_meaningId = MakeValidFwId(Attribute.Value);
                    }
                    else if (Attribute.Name == "func")
                    {
                        m_RefFunc = Attribute.Value;
                    }
                    else if (Attribute.Name == "funcWS")
                    {
                        m_RefFuncWS = Attribute.Value;
                    }
                }
                m_Meaning += " />";

                RebuildMeaningEntry(null, topAnalysisWS);
            }

//			xmlOutput.WriteRaw(System.Environment.NewLine + "</field>" + System.Environment.NewLine);

            SetAutoSfm();
            if (m_Sfm == null)
            {
                Converter.Log.AddError(Sfm2XmlStrings.FieldDefinedWithNoSfmAttributeInTheFieldDescs);
            }
            else if (m_Language == null)
            {
                Converter.Log.AddError(String.Format(Sfm2XmlStrings.FieldDescWithSFMOf0HasNoLangAttribute, m_Sfm));
            }
            if (m_Type == null)
            {
                Converter.Log.AddWarning(String.Format(Sfm2XmlStrings.FieldDescWithSFMOf0HasNoTypeAttribute, m_Sfm));
            }
            else
            {
                return(true);
            }

            return(false);
        }