Esempio n. 1
0
        public int CompareTo(object obj)
        {
            IntelligentString intelligentString = (IntelligentString)obj;

            String thisString = PrepareValueForSort(Value);
            String thatString = PrepareValueForSort(intelligentString.Value);

            Int64 thisInt;
            Int64 thatInt;

            if ((Int64.TryParse(thisString, out thisInt)) && (Int64.TryParse(thatString, out thatInt)))
            {
                return(thisInt.CompareTo(thatInt));
            }

            DateTime thisDate;
            DateTime thatDate;

            if ((DateTime.TryParse(thisString, out thisDate)) && (DateTime.TryParse(thatString, out thatDate)))
            {
                return(thisDate.CompareTo(thatDate));
            }

            return(thisString.CompareTo(thatString));
        }
Esempio n. 2
0
 public override bool Equals(object obj)
 {
     if ((Value != null) &&
         (obj != null) &&
         (obj.GetType() == typeof(IntelligentString)))
     {
         IntelligentString intelligentString = (IntelligentString)obj;
         return(Value.Equals(intelligentString.Value));
     }
     else
     {
         return(base.Equals(obj));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Formats a size into a string with the corrent denomination
        /// </summary>
        /// <param name="size">Size being formatted</param>
        /// <returns>Size expressed as a string with the correct denomination</returns>
        public static IntelligentString FormatSize(Double size)
        {
            Double  newSize = size;
            Int32   denominationLevel;
            Boolean negative;

            GetSizeDenomination(ref newSize, out denominationLevel, out negative);


            IntelligentString formattedSize = newSize.ToString("0.00") + " " + DenominationLevels[denominationLevel];

            if (negative)
            {
                formattedSize = "-" + formattedSize;
            }

            return(formattedSize);
        }
Esempio n. 4
0
 /// <summary>
 /// Returns an IntelligentString array that contains the substrings in this instance that are delimited by a specified intelligent string
 /// </summary>
 /// <param name="separator">Intelligent string that delimits the substrings in this instance</param>
 /// <returns>An array whose elements contain the substrings in this instance that are delimited by separator</returns>
 public                          IntelligentString[] Split(IntelligentString separator)
 {
     return(Split(Convert.ToChar(separator.Value)));
 }
Esempio n. 5
0
 /// <summary>
 /// Indicates whether the specified value is null or an IntelligentString.Empty value
 /// </summary>
 /// <param name="value">The string to test</param>
 /// <returns>True if the value is null or empty, false otherwise</returns>
 public static Boolean IsNullOrEmpty(IntelligentString value)
 {
     return(String.IsNullOrEmpty(value.Value));
 }
Esempio n. 6
0
 /// <summary>
 /// Returns a new intelligent string in which all occurrences of a specified intelligent string in the current instance are replaced with another specified intelligent string
 /// </summary>
 /// <param name="oldValue">The intelligent string to be replaced</param>
 /// <param name="newValue">The intelligent string to replace all occurrences of oldValue</param>
 /// <returns>An intelligent string that is equivalent to the current intelligent string except that all instances of oldValue are replaced with newValue</returns>
 public IntelligentString Replace(IntelligentString oldValue, IntelligentString newValue)
 {
     return(Value.Replace(oldValue.Value, newValue.Value));
 }
Esempio n. 7
0
 /// <summary>
 /// Reports the index position of the last occurrence of a specified intelligent string within this instance
 /// </summary>
 /// <param name="value">The string to seek</param>
 /// <returns>The zero-based index position of value if that intelligent string is found, or -1 if it is not. If value is IntelligentString.Empty, the return value is the last index position in this instance</returns>
 public int LastIndexOf(IntelligentString value)
 {
     return(Value.LastIndexOf(value.Value));
 }
Esempio n. 8
0
 /// <summary>
 /// Returns a value indicating whether the specified intelligent string object occurs within this intelligent string
 /// </summary>
 /// <param name="value">The intelligent string to seek</param>
 /// <returns>True if the value parameter occurs within this intelligent string, or if value is the empty string (""); otherwise, false</returns>
 public Boolean Contains(IntelligentString value)
 {
     return(Value.Contains(value.Value));
 }
Esempio n. 9
0
 /// <summary>
 /// Determines whether the end of this intelligent string instance matches a specified intelligent string
 /// </summary>
 /// <param name="value">The intelligent string to compare to the substring at the end of this instance</param>
 /// <returns>True if value matches the end of this instance; otherwise, false</returns>
 public Boolean EndsWith(IntelligentString value)
 {
     return(Value.EndsWith(value.Value));
 }
Esempio n. 10
0
 /// <summary>
 /// Determines whether the beginning of this intelligent string instance matches the specified intelligent string
 /// </summary>
 /// <param name="value">The intelligent string to compare</param>
 /// <returns>True if this intelligent string started with the specified intelligent string, false if not</returns>
 public Boolean StartsWith(IntelligentString value)
 {
     return(Value.StartsWith(value.Value));
 }