Index: Tools/Google.Build.Utils/Text/TextUtils.cs
===================================================================
deleted file mode 100644
--- a/Tools/Google.Build.Utils/Text/TextUtils.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-Copyright 2011 Google Inc
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-using System;
-using System.IO;
-
-namespace Google.Build.Utils.Text
-{
- ///
- /// Text helper utility.
- ///
- public static class TextUtils
- {
- ///
- /// Inserts the specified content in the place between the start and end tag, which can be found in the
- /// specified source text.
- ///
- /// Text which contains the tags.
- /// The tag marking the start of the replacement area.
- /// The tag marking the end of the replacement area.
- /// The content to insert into the replacement area.
- /// [..] {startTag} content {endTag} [..]
- public static string InsertIntoText(string sourceText, string startTag, string endTag, string content)
- {
- return ReplaceInText(sourceText, startTag, endTag, old => content);
- }
-
- ///
- /// Replaces the text within the given tags using the specified replace function.
- ///
- /// The text containing the tags.
- /// The tag marking the start of the replacement area.
- /// The tag marking the end of the replacement area.
- /// The function used to replace the tag content.
- /// The resulting text.
- public static string ReplaceInText(string sourceText,
- string startTag,
- string endTag,
- Func replace)
- {
- // Find the start tag.
- int startIndex = sourceText.IndexOf(startTag);
- if (startIndex < 0)
- {
- throw new ArgumentException("Start Tag not found: " + startTag);
- }
- startIndex += startTag.Length;
-
- // Find the end tag.
- int endIndex = sourceText.IndexOf(endTag, startIndex);
- if (endIndex < 0)
- {
- throw new ArgumentException("End Tag not found: " + endTag);
- }
-
- // Replace the text
- string oldText = sourceText.Substring(startIndex, endIndex - startIndex).Trim('\r', '\n');
- string newText = replace(oldText);
- return sourceText.Substring(0, startIndex) + Environment.NewLine +
- newText + Environment.NewLine +
- sourceText.Substring(endIndex);
- }
-
- ///
- /// Replaces the text within the given tags using the specified replace function.
- ///
- /// The file to replace the text in.
- /// The tag marking the start of the replacement area.
- /// The tag marking the end of the replacement area.
- /// The function used to replace the tag content.
- public static void ReplaceInFile(string file, string startTag, string endTag, Func replace)
- {
- File.WriteAllText(file, ReplaceInText(File.ReadAllText(file), startTag, endTag, replace));
- }
-
- ///
- /// Inserts the specified content in the place between the start and end tag, which can be found in the
- /// specified source text.
- ///
- /// The file containing the tags.
- /// The tag marking the start of the replacement area.
- /// The tag marking the end of the replacement area.
- /// The content to insert into the replacement area.
- /// [..] {startTag} content {endTag} [..]
- public static void InsertIntoFile(string file, string startTag, string endTag, string content)
- {
- File.WriteAllText(file, InsertIntoText(File.ReadAllText(file), startTag, endTag, content));
- }
-
- ///
- /// Transforms the first letter of the string into uppercase.
- ///
- public static string ToUpperFirstChar(this string str)
- {
- if (string.IsNullOrEmpty(str))
- {
- return str;
- }
- return Char.ToUpper(str[0]) + str.Substring(1);
- }
-
- ///
- /// Finishes the specified string with the specified character.
- ///
- /// The sentence to end.
- /// The character with which this sentence should end.
- public static string MakeSentence(this string str, char endChar)
- {
- string trimmed = str.TrimEnd(' ', '\r', '\n');
-
- if (trimmed.EndsWith(endChar.ToString()))
- {
- return str;
- }
- return trimmed + endChar + str.Substring(trimmed.Length);
- }
-
- ///
- /// Joins the two specified lines into a common string.
- ///
- public static string JoinLines(string a, string b)
- {
- return a + Environment.NewLine + b;
- }
- }
-}