Ejemplo n.º 1
0
 /// <summary>
 /// Replaces Ant-style expression placeholder with expression value.
 /// </summary>
 /// <remarks>
 /// <p>
 ///
 /// </p>
 /// </remarks>
 /// <param name="text">The string to set the value in.</param>
 /// <param name="expression">The name of the expression to set.</param>
 /// <param name="expValue">The expression value.</param>
 /// <returns>
 /// A new string with the expression value set; the
 /// <see cref="String.Empty"/> value if the supplied
 /// <paramref name="text"/> is <see langword="null"/>, has a length
 /// equal to zero <c>(0)</c>, or is composed entirely of whitespace
 /// characters.
 /// </returns>
 public static string SetAntExpression(string text, string expression, object expValue)
 {
     if (StringUtils.IsNullOrEmpty(text))
     {
         return(String.Empty);
     }
     if (expValue == null)
     {
         expValue = String.Empty;
     }
     return(text.Replace(
                StringUtils.Surround(AntExpressionPrefix, expression, AntExpressionSuffix), expValue.ToString()));
 }
 public void SurroundObject()
 {
     Assert.AreEqual("[:Hi]", StringUtils.Surround("[", new Foo("Hi"), "]"));
 }
 public void SurroundObjectWithEmptyStrings()
 {
     Assert.AreEqual(":Hi", StringUtils.Surround(string.Empty, new Foo("Hi"), string.Empty));
 }
 public void FullSurroundObjectWithNulls()
 {
     Assert.AreEqual(":Hi", StringUtils.Surround(null, new Foo("Hi"), null));
 }
 public void SurroundNullWithNulls()
 {
     Assert.AreEqual(string.Empty, StringUtils.Surround(null, null));
 }
 public void SurroundEmptyStringWithEmptyStrings()
 {
     Assert.AreEqual(string.Empty, StringUtils.Surround(string.Empty, string.Empty));
 }
 public void Surround()
 {
     Assert.AreEqual("-Hi-", StringUtils.Surround("-", "Hi"));
 }
 public void SurroundWithEmptyStrings()
 {
     Assert.AreEqual("Hi", StringUtils.Surround(string.Empty, "Hi"));
 }
 public void FullSurroundNullWithEmptyStrings()
 {
     Assert.AreEqual(string.Empty, StringUtils.Surround(string.Empty, null, string.Empty));
 }
 public void FullSurround()
 {
     Assert.AreEqual("[Hi]", StringUtils.Surround("[", "Hi", "]"));
 }
 public void FullSurroundWithNulls()
 {
     Assert.AreEqual("Hi", StringUtils.Surround(null, "Hi", null));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Surrounds (prepends and appends) the string value of the supplied
 /// <paramref name="fix"/> to the supplied <paramref name="target"/>.
 /// </summary>
 /// <remarks>
 /// <p>
 /// The return value of this method call is always guaranteed to be non
 /// <see langword="null"/>. If every value passed as a parameter to this method is
 /// <see langword="null"/>, the <see cref="System.String.Empty"/> string will be returned.
 /// </p>
 /// </remarks>
 /// <param name="fix">
 /// The pre<b>fix</b> and suf<b>fix</b> that respectively will be prepended and
 /// appended to the target <paramref name="target"/>. If this value
 /// is not a <see cref="System.String"/> value, it's attendant
 /// <see cref="System.Object.ToString()"/> value will be used.
 /// </param>
 /// <param name="target">
 /// The target that is to be surrounded. If this value is not a
 /// <see cref="System.String"/> value, it's attendant
 /// <see cref="System.Object.ToString()"/> value will be used.
 /// </param>
 /// <returns>The surrounded string.</returns>
 public static string Surround(object fix, object target)
 {
     return(StringUtils.Surround(fix, target, fix));
 }