/// <summary> /// Classifies the character into normal chars, spaces, semicola, quotes, /// control chars. /// </summary> /// <param name="ch">a char</param> /// <returns>Return the character kind.</returns> private static UnicodeKind ClassifyCharacter(char ch) { if (Spaces.IndexOf(ch) >= 0 || (0x2000 <= ch && ch <= 0x200B)) { return(UnicodeKind.Space); } if (Commas.IndexOf(ch) >= 0) { return(UnicodeKind.Comma); } if (Semicola.IndexOf(ch) >= 0) { return(UnicodeKind.Semicolon); } if (Quotes.IndexOf(ch) >= 0 || (0x3008 <= ch && ch <= 0x300F) || (0x2018 <= ch && ch <= 0x201F)) { return(UnicodeKind.Quote); } if (ch < 0x0020 || Controls.IndexOf(ch) >= 0) { return(UnicodeKind.Control); } // Assume typical case. return(UnicodeKind.Normal); }
/// <summary> /// Classifies the character into normal chars, spaces, semicola, quotes, /// control chars. /// </summary> /// <param name="ch">a char</param> /// <returns>Return the character kind.</returns> private static int ClassifyCharacter(char ch) { if (Spaces.IndexOf(ch) >= 0 || (unchecked ((int)(0x2000)) <= ch && ch <= unchecked ((int)(0x200B)))) { return(UckSpace); } else { if (Commas.IndexOf(ch) >= 0) { return(UckComma); } else { if (Semicola.IndexOf(ch) >= 0) { return(UckSemicolon); } else { if (Quotes.IndexOf(ch) >= 0 || (unchecked ((int)(0x3008)) <= ch && ch <= unchecked ((int)(0x300F))) || (unchecked ((int)(0x2018)) <= ch && ch <= unchecked ((int)(0x201F)))) { return(UckQuote); } else { if (ch < unchecked ((int)(0x0020)) || Controls.IndexOf(ch) >= 0) { return(UckControl); } else { // Assume typical case. return(UckNormal); } } } } } }
string replace(string text, Commas separator) { Zeroes zeroes = new Zeroes(); string sep = ""; if (separator == Commas.Comma) { sep = "#,"; } if (settings.PaddingZeroes) { zeroes.bpm = new string('0', settings.BPMintPad) + "." + new string('0', settings.BPMDecPtPad); zeroes.nc = new string('0', settings.NoteCountPad); zeroes.plph = new string('0', settings.PolyphonyPad); zeroes.nps = new string('0', settings.NPSPad); zeroes.tick = new string('0', settings.TicksPad); zeroes.bars = new string('0', settings.BarCountPad); zeroes.frms = new string('0', settings.FrCountPad); } text = text.Replace("{bpm}", tempo.ToString(zeroes.bpm)); text = text.Replace("{nc}", noteCount.ToString(sep + zeroes.nc)); text = text.Replace("{nr}", (CurrentMidi.noteCount - noteCount).ToString(sep + zeroes.nc)); text = text.Replace("{tn}", CurrentMidi.noteCount.ToString(sep + zeroes.nc)); text = text.Replace("{nps}", nps.ToString(sep + zeroes.nps)); text = text.Replace("{mnps}", Mnps.ToString(sep + zeroes.nps)); text = text.Replace("{plph}", polyphony.ToString(sep + zeroes.plph)); text = text.Replace("{mplph}", Mplph.ToString(sep + zeroes.plph)); text = text.Replace("{currsec}", ((double)(seconds / 100) / 10).ToString(sep + "0.0")); text = text.Replace("{currtime}", time.ToString("mm\\:ss")); text = text.Replace("{cmiltime}", time.ToString("mm\\:ss\\.fff")); text = text.Replace("{cfrtime}", time.ToString("mm\\:ss") + ";" + (frames % renderSettings.fps).ToString(fzp)); text = text.Replace("{totalsec}", ((double)(totalsec / 100) / 10).ToString(sep + "0.0")); text = text.Replace("{totaltime}", totaltime.ToString("mm\\:ss")); text = text.Replace("{tmiltime}", totaltime.ToString("mm\\:ss\\.fff")); text = text.Replace("{tfrtime}", totaltime.ToString("mm\\:ss") + ";" + (totalframes % renderSettings.fps).ToString(fzp)); text = text.Replace("{remsec}", ((double)((totalsec - seconds) / 100) / 10).ToString(sep + "0.0")); text = text.Replace("{remtime}", (totaltime - time).ToString("mm\\:ss")); text = text.Replace("{rmiltime}", (totaltime - time).ToString("mm\\:ss\\.fff")); text = text.Replace("{rfrtime}", (totaltime - time).ToString("mm\\:ss") + ";" + ((totalframes - frames + renderSettings.fps) % renderSettings.fps).ToString(fzp)); text = text.Replace("{currticks}", (limMidiTime).ToString(sep + zeroes.tick)); text = text.Replace("{totalticks}", (CurrentMidi.tickLength).ToString(sep + zeroes.tick)); text = text.Replace("{remticks}", (CurrentMidi.tickLength - limMidiTime).ToString(sep + zeroes.tick)); text = text.Replace("{currbars}", bar.ToString(sep + zeroes.bars)); text = text.Replace("{totalbars}", maxbar.ToString(sep + zeroes.bars)); text = text.Replace("{rembars}", (maxbar - bar).ToString(sep + zeroes.bars)); text = text.Replace("{ppq}", CurrentMidi.division.ToString()); text = text.Replace("{tsn}", CurrentMidi.timeSig.numerator.ToString()); text = text.Replace("{tsd}", CurrentMidi.timeSig.denominator.ToString()); text = text.Replace("{avgnps}", ((double)CurrentMidi.noteCount / (double)CurrentMidi.secondsLength).ToString(sep + "0.00")); text = text.Replace("{currframes}", frames.ToString(sep + zeroes.frms)); text = text.Replace("{totalframes}", totalframes.ToString(sep + zeroes.frms)); text = text.Replace("{remframes}", (totalframes - frames).ToString(sep + zeroes.frms)); text = text.Replace("{notep}", (((decimal)noteCount * 1000000 / (decimal)CurrentMidi.noteCount) / 10000).ToString("00.0000")); text = text.Replace("{tickp}", (((decimal)limMidiTime * 1000000 / (decimal)CurrentMidi.tickLength) / 10000).ToString("00.0000")); text = text.Replace("{timep}", (((decimal)seconds * 1000000 / (decimal)totalsec) / 10000).ToString("00.0000")); return(text); }
public void Parse_Throws_ArgumentException_When_Input_Is_Null() { Action act = () => Commas.Parse(null); var exception = Assert.Throws <ArgumentException>(act); }
public void Add_Returns_Comma_Seperated_String_When_Input_Is_UInt64() { Assert.Equal("12,345,678,901", Commas.Add((ulong)12345678901)); }
public void Add_Returns_Comma_Seperated_String_When_Input_Is_Int64() { Assert.Equal("1,234,567,890,123", Commas.Add(1234567890123)); }
public void Add_Returns_Comma_Seperated_String_When_Input_Is_UInt32() { Assert.Equal("123,456,789", Commas.Add((uint)123456789)); }
public void Add_Returns_Comma_Seperated_String_When_Input_Is_UInt16() { Assert.Equal("1,023", Commas.Add((ushort)1023)); }
public void Add_Returns_Comma_Seperated_String_When_Input_Is_Int16() { Assert.Equal("10,279", Commas.Add((short)10279)); }