using System.Globalization;
using System.Linq;
using System.Text;
namespace jQueryBuddy.Utilities
{
public static class StringExtensions
{
///
/// Returns the zero-based line number where
/// appears in . Lines are counted wherever \n appears.
///
///
///
///
public static int GetLineNumberContaining(this string target, string source)
{
if (string.IsNullOrEmpty(target)) return -1;
if (string.IsNullOrEmpty(source)) return -1;
var position = target.IndexOf(source);
if (position == -1) return -1;
var lineCount = 0;
for (var i = 0; i < position; i++)
{
if (target[i] == '\n') lineCount++;
}
return lineCount;
}
}
}