11using System ;
22using System . Collections ;
33using System . Collections . Generic ;
4+ using System . Globalization ;
45using System . Linq ;
56using System . Management . Automation . Language ;
67using System . Text ;
@@ -126,34 +127,12 @@ private void ValidateTextEditExtent(TextEdit textEdit)
126127 || textEdit . StartColumnNumber > Lines [ textEdit . StartLineNumber - 1 ] . Length
127128 || textEdit . EndColumnNumber > Lines [ textEdit . EndLineNumber - 1 ] . Length + 1 )
128129 {
129- // TODO Localize
130- throw new ArgumentException ( "TextEdit extent not completely contained in EditableText." ) ;
130+ throw new ArgumentException ( String . Format (
131+ CultureInfo . CurrentCulture ,
132+ Strings . EditableTextRangeIsNotContained ) ) ;
131133 }
132134 }
133135
134- private int GetOffset ( int lineNumber , int columnNumber )
135- {
136- if ( lineNumber < 1 )
137- {
138- throw new ArgumentException ( "Line number must be greater than 0." , nameof ( lineNumber ) ) ;
139- }
140-
141- if ( columnNumber < 1 )
142- {
143- throw new ArgumentException ( "Column number must be greater than 0." , nameof ( lineNumber ) ) ;
144- }
145-
146- var zeroBasedLineNumber = lineNumber - 1 ;
147- var zeroBasedColumnNumber = columnNumber - 1 ;
148- var offset = 0 ;
149- for ( var k = 0 ; k < zeroBasedLineNumber ; k ++ )
150- {
151- offset += Lines [ k ] . Length + NewLine . Length ;
152- }
153-
154- return offset + zeroBasedColumnNumber ;
155- }
156-
157136 private static string GetNewLineCharacters ( string text , out string [ ] lines )
158137 {
159138 int numNewLineChars = GetNumNewLineCharacters ( text , out lines ) ;
@@ -178,8 +157,9 @@ private static int GetNumNewLineCharacters(string text, out string[] lines)
178157 int remainder = numCharDiff % ( lines . Length - 1 ) ;
179158 if ( remainder != 0 )
180159 {
181- // TODO localize
182- throw new ArgumentException ( "Cannot determine line endings as the text probably contain mixed line endings." , nameof ( text ) ) ;
160+ throw new ArgumentException (
161+ String . Format ( CultureInfo . CurrentCulture , Strings . EditableTextInvalidLineEnding ) ,
162+ nameof ( text ) ) ;
183163 }
184164
185165 return numCharDiff / ( lines . Length - 1 ) ;
0 commit comments