Esempio n. 1
0
        public override int CompareTo(object obj)
        {
            ONBool lVal = obj as ONBool;

            if (lVal == null)
            {
                return(1);
            }

            if (Value == null && lVal.Value == null)
            {
                return(0);
            }

            if (Value == null)
            {
                return(-1);
            }

            if (lVal.Value == null)
            {
                return(1);
            }

            return(TypedValue.CompareTo(lVal.TypedValue));
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="val">Value for this type</param>
 public ONBool(ONBool val)
 {
     if (val == null)
         Value = null;
     else
     Value = val.Value;
 }
Esempio n. 3
0
        /// <summary>
        /// Creates XML elements from the data of the system.
        /// </summary>
        /// <param name="xmlWriter">Object with the XML message to add new information and return to client side</param>
        /// <param name="val">Value to be puted inside the XML message</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        /// <param name="xmlElement">Element of the XML that is checked</param>
        public static void ON2XML(XmlWriter xmlWriter, ONBool val, double dtdVersion, string xmlElement)
        {
            if (val == null)
            {
                if (xmlElement == ONXml.XMLTAG_V)
                    xmlWriter.WriteElementString(xmlElement, "");
                else
                    xmlWriter.WriteElementString(ONXml.XMLTAG_NULL, null);
            }
            else
            {
                if (dtdVersion < 2.0) // Apply the locale format
                {
                    if (val.TypedValue)
                        xmlWriter.WriteElementString(xmlElement, "Verdadero");
                    else
                        xmlWriter.WriteElementString(xmlElement, "Falso");
                }
                else
                {
                    xmlWriter.WriteStartElement(xmlElement);
                    if (xmlElement == ONXml.XMLTAG_OIDFIELD && dtdVersion > 2.0)
                        xmlWriter.WriteAttributeString("Type", "bool");

                    if (val.TypedValue)
                        xmlWriter.WriteString("true");
                    else
                        xmlWriter.WriteString("false");

                    xmlWriter.WriteEndElement();
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="val">Value for this type</param>
 public ONBool(ONBool val)
 {
     if (val == null)
     {
         Value = null;
     }
     else
     {
         Value = val.Value;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Compares two regions defined by the arguments of this method: The first string 
        /// region is defined by the substring of the aString string starting at the from position 
        /// with a length size, the second one is a substring which starts at the otherfrom 
        /// position of the other string with the length size. If both regions are equals 
        /// (depending on the ignoreCase parameter) this method returns true, if not, or if one
        ///  of the from or otherfrom arguments is negative, or some of the regions exceeds the
        ///   end of the string, this method returns false
        /// </summary>				
        public static ONBool strRegionMatches(ONString aString, ONBool ignoreCase, ONInt from, ONString other, ONInt otherFrom, ONInt length)
        {
            if (aString == null || ignoreCase == null || from == null || other == null || otherFrom == null || length == null)
                return ONBool.Null;

            string lAString = aString.TypedValue;
            int lFrom = from.TypedValue;
            int lOtherFrom = otherFrom.TypedValue;
            string lOther = other.TypedValue;
            int lLength = length.TypedValue;

            if (lFrom < 0 || lOtherFrom < 0 || lFrom + lLength > lAString.Length ||
                lOtherFrom + lLength > lOther.Length)
                return new ONBool(false);
            if (ignoreCase.TypedValue)
            {
                lAString = lAString.ToUpper();
                lOther = lOther.ToUpper();
            }
            return new ONBool(lAString.Substring(lFrom, lLength).Equals(lOther.Substring(lOtherFrom, lLength)));
        }