private void ValidateEdit(string key, string newValue)
 {
     Complain.IfNull(_dictionary);
     Complain.IfNull(key);
     Complain.IfNull(newValue);
     Complain.If(!_dictionary.ContainsKey(key), Complaints.KEY_NOT_FOUND);
 }
 private void ValidateGlobalReplacement(string oldValue, string newValue)
 {
     Complain.IfNull(_dictionary);
     Complain.IfNull(oldValue);
     Complain.IfNull(newValue);
     Complain.If(oldValue == newValue, Complaints.CANNOT_REPLACE_WITH_IDENTICAL_VALUE, By.ThrowingAnException);
 }
예제 #3
0
 private void ValidateTranslation(Dictionary <string, string> originalKeyValues, string originalLanguage, string targetLanguage)
 {
     Complain.IfNull(originalKeyValues);
     Complain.IfStringIsNullOrWhitespace(originalLanguage);
     Complain.IfStringIsNullOrWhitespace(targetLanguage);
     Complain.If(!_translationClient.ListLanguages().Select(l => l.Code).ToList().Contains(originalLanguage), $"{Constants.ORIGINAL_LANGUAGE_CODE} '{originalLanguage}' is not in the list of {_translationClient.GetType().ToString()}'s translatable languages. Please double-check the code or try a different language.", By.ThrowingAnException);
     Complain.If(!_translationClient.ListLanguages().Select(l => l.Code).ToList().Contains(targetLanguage), $"Target language code '{targetLanguage}' is not in the list of {_translationClient.GetType().ToString()}'s translatable languages. Please double-check the code or try a different language.", By.ThrowingAnException);
 }
        public Dictionary <string, string> LoadDictionary(string filepath)
        {
            ValidateLoad(filepath);
            var readDict = new Dictionary <string, string>();
            var allLines = File.ReadAllText(filepath).Split("\r\n");

            for (int i = 0; i < allLines.Length; i++)
            {
                var lineValues = allLines[i].Split('\t');
                Complain.If(lineValues.Count() != 2, Complaints.MUST_BE_TWO_VALUES_PER_LINE + allLines[i]);
                readDict.Add(lineValues[0], lineValues[1]);
            }
            _dictionary = readDict;
            return(_dictionary);
        }
 private static void ValidateLoad(string filepath)
 {
     Complain.If(!File.Exists(filepath), Complaints.DICTIONARY_FILE_NOT_FOUND);
 }
 private void ValidateUndo()
 {
     Complain.If(_undoableEdits.Count() == 0, Complaints.NOTHING_TO_UNDO);
 }
 private void ValidateRedo()
 {
     Complain.If(_redoableEdits.Count() == 0, Complaints.NOTHING_TO_REDO);
 }