コード例 #1
0
        private static string ReplaceToken(this NuGet.IPropertyProvider propertyProvider, Match match, bool throwIfNotFound)
        {
            string propertyName = match.Groups["propertyName"].Value;
            var    value        = propertyProvider.GetPropertyValue(propertyName);

            if (value == null && throwIfNotFound)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "The replacement token '{0}' has no value.", propertyName));
            }
            return(value);
        }
コード例 #2
0
 /// <summary>
 /// Replaces tokens in parameter text
 /// </summary>
 /// <param name="text">
 /// Text with tokens to replace
 /// </param>
 /// <param name="throwIfNotFound">
 /// Whether to throw if token not found
 /// </param>
 /// <returns>
 /// Text with replaced tokens
 /// </returns>
 public static Stream Process(this NuGet.IPropertyProvider propertyProvider, Stream stream, bool throwIfNotFound = true) =>
 _tokenRegex.Replace(stream.ReadToEnd(), match => ReplaceToken(propertyProvider, match, throwIfNotFound)).AsStream();
コード例 #3
0
 /// <summary>
 /// Replaces tokens in parameter text
 /// </summary>
 /// <param name="text">
 /// Text with tokens to replace
 /// </param>
 /// <param name="throwIfNotFound">
 /// Whether to throw if token not found
 /// </param>
 /// <returns>
 /// Text with replaced tokens
 /// </returns>
 public static string Process(this NuGet.IPropertyProvider propertyProvider, string text, bool throwIfNotFound = true) =>
 _tokenRegex.Replace(text, match => ReplaceToken(propertyProvider, match, throwIfNotFound));