コード例 #1
0
        public static void TestStringCollection()
        {
            var testCollection = new StringCollection();

            string testID        = "test_id";
            string testString    = "test_string";
            string testStringTwo = "test_string_two";

            testCollection.AddString(testID, testString);
            string testNewString = testCollection.GetString(testID);

            Debug.Assert(testString.Equals(testNewString), "Input/output replication test failed for StringCollection");

            bool exceptionCaught;

            try
            {
                // Adding same string with same ID
                testCollection.AddString(testID, testString);
                exceptionCaught = false;
            }
            catch (Exception e)
            {
                exceptionCaught = true;
            }

            Debug.Assert(exceptionCaught == false, "Same ID same string test failed for StringCollection");

            try
            {
                // Adding different string with same ID
                testCollection.AddString(testID, testStringTwo);
                exceptionCaught = false;
            }
            catch (Exception e)
            {
                exceptionCaught = true;
            }

            Debug.Assert(exceptionCaught == true, "Same ID different string test failed for StringCollection");

            try
            {
                // Trying to access non-existent string
                string nonExistentID     = "afesrgrt3qr\aefgsgggaftr3qr4q4";
                string nonExistentString = testCollection.GetString(nonExistentID);
                exceptionCaught = false;
            }
            catch (Exception e)
            {
                exceptionCaught = true;
            }

            Debug.Assert(exceptionCaught == true, "Non-existent ID test failed for StringCollection");

            var testCollectionWithID = new StringCollection("TEST");

            Debug.Assert(testCollectionWithID.GenerateNewID() == "$TEST_0", "ID generation test failed for StringCollection"); // this test does not account for variable idPrefix etc. which are technicallty not supported at the moment
        }
コード例 #2
0
ファイル: CSVFileWriter.cs プロジェクト: shindouj/KPT
        public void WriteCSVFile(string fileName, List <IInstruction> fileContents, StringCollection fileStrings)
        {
            fileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".csv");

            DirectoryGuard.CheckDirectory(fileName);
            FileStream   fs = new FileStream(fileName, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            var csv = new CsvHelper.CsvWriter(sw);

            csv.Configuration.RegisterClassMap <CSVRecordMap>();

            csv.WriteHeader <CSVRecord>();
            csv.NextRecord();

            string lastSpeaker = "";

            foreach (var instruction in fileContents)
            {
                if (instruction is IHasStrings)
                {
                    var temp = instruction as IHasStrings;
                    List <CSVRecord> csvRecords = temp.GetCSVRecords();
                    foreach (var record in csvRecords)
                    {
                        record.originalText = fileStrings.GetString(record.stringID);
                        if (record.speaker != lastSpeaker)
                        {
                            lastSpeaker = record.speaker;
                        }
                        else
                        {
                            record.speaker = ""; // blank out the name of the speaker if it is being repeated to make it easier to note when speaker changes and avoid massive walls of speakers text
                        }
                        csv.WriteRecord(record);
                        csv.NextRecord();
                    }
                }
            }

            csv.Flush();

            sw.Close();
            fs.Close();
        }
コード例 #3
0
ファイル: DialogueBox.cs プロジェクト: shindouj/KPT
 public void GetStrings(StringCollection collection)
 {
     dialogue     = collection.GetString(dialogue);
     isTranslated = true; // We're assuming that the primary reason for the strings changing is loading translated strings - it's possible this may not be the case, but it is very unlikely
 }
コード例 #4
0
ファイル: LocationCard.cs プロジェクト: shindouj/KPT
 public void GetStrings(StringCollection collection)
 {
     time     = collection.GetString(time);
     location = collection.GetString(location);
 }
コード例 #5
0
 public void GetStrings(StringCollection collection)
 {
     choiceText = collection.GetString(choiceText);
 }