本文整理汇总了C#中TextSource.RenToLog方法的典型用法代码示例。如果您正苦于以下问题:C# TextSource.RenToLog方法的具体用法?C# TextSource.RenToLog怎么用?C# TextSource.RenToLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextSource
的用法示例。
在下文中一共展示了TextSource.RenToLog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiUniformRuns
public void MultiUniformRuns()
{
// Run 0
string part0 = "abc def";
AssembledStyles styles = new AssembledStyles().WithWs(wsEn);
StringClientRun clientRun0 = new StringClientRun(part0, styles);
var clientRuns = new List<IClientRun>();
clientRuns.Add(clientRun0);
// Run 1
string part1 = " ghijk";
string part2 = " lmno";
ITsString tss = tsf.MakeString(part2, wsEn);
ITsStrBldr bldr = tss.GetBldr();
bldr.Replace(0, 0, part1, ttpFrn);
TssClientRun clientRun1 = new TssClientRun(bldr.GetString(), styles);
clientRuns.Add(clientRun1);
// Run 2
string part3 = " pq";
string part4 = "\xfffc";
string part5 = "r";
StringClientRun clientRun2 = new StringClientRun(part3+part4+part5, styles);
clientRuns.Add(clientRun2);
TextSource source = new TextSource(clientRuns, MockInterpretOrc);
MapRun[] runs = source.Runs;
Assert.AreEqual(6, runs.Length);
VerifyRun(0, clientRun0, 0, 0, part0, runs[0], "first run of complex source (abcdef)");
int len = part0.Length;
VerifyRun(len, clientRun1, len, 0, part1, runs[1], "2nd run of complex source( ghijk)");
len += part1.Length;
VerifyRun(len, clientRun1, len, 0, 1, part2, runs[2], "3rd run of complex source( lmno)");
len += part2.Length;
VerifyRun(len, clientRun2, len, 0, part3, runs[3], "4th run of complex source (pq)");
len += part3.Length;
int orcPos = len;
VerifyRun(len, clientRun2, len, part3.Length, orcText, runs[4], "5th run of complex source (orc->xyz)");
int render = len + orcText.Length;
len += 1;
VerifyRun(len, clientRun2, render, part3.Length + part4.Length, part5, runs[5], "6th run of complex source(r)");
len += part5.Length;
render += part5.Length;
Assert.AreEqual(render, source.Length, "Length of complex source");
// LogToRen
Assert.AreEqual(0, source.LogToRen(0));
Assert.AreEqual(1, source.LogToRen(1));
Assert.AreEqual(part1.Length - 1, source.LogToRen(part1.Length - 1));
Assert.AreEqual(part1.Length, source.LogToRen(part1.Length));
Assert.AreEqual(part1.Length + 1, source.LogToRen(part1.Length + 1));
Assert.AreEqual(orcPos - 1, source.LogToRen(orcPos - 1));
Assert.AreEqual(orcPos, source.LogToRen(orcPos));
int delta = orcText.Length - 1;
Assert.AreEqual(orcPos + 1 + delta, source.LogToRen(orcPos + 1));
Assert.AreEqual(len + delta, source.LogToRen(len));
Assert.AreEqual(len - 1 + delta, source.LogToRen(len - 1));
//RenToLog
Assert.AreEqual(0, source.RenToLog(0));
Assert.AreEqual(1, source.RenToLog(1));
Assert.AreEqual(part1.Length - 1, source.RenToLog(part1.Length - 1));
Assert.AreEqual(part1.Length, source.RenToLog(part1.Length));
Assert.AreEqual(part1.Length + 1, source.RenToLog(part1.Length + 1));
Assert.AreEqual(orcPos - 1, source.RenToLog(orcPos - 1));
Assert.AreEqual(orcPos, source.RenToLog(orcPos));
Assert.AreEqual(orcPos, source.RenToLog(orcPos + orcText.Length - 1));
Assert.AreEqual(orcPos + 1, source.RenToLog(orcPos + orcText.Length));
Assert.AreEqual(len, source.RenToLog(len + delta));
Assert.AreEqual(len - 1, source.RenToLog(len + delta - 1));
// Fetch
VerifyFetch(source, 0, 0, "");
VerifyFetch(source, 0, 1, "a");
VerifyFetch(source, 0, part0.Length, part0);
VerifyFetch(source, orcPos, orcPos + orcText.Length, orcText);
VerifyFetch(source, part0.Length, part0.Length + part1.Length, part1);
VerifyFetch(source, part0.Length + part1.Length - 2, part0.Length + part1.Length + 2, part1.Substring(part1.Length - 2) + part2.Substring(0, 2));
VerifyFetch(source, part0.Length, part0.Length + part1.Length + part2.Length + 1,
part1 + part2 + part3.Substring(0, 1));
VerifyFetch(source, orcPos + orcText.Length - 1, orcPos + orcText.Length + 1,
orcText.Substring(orcText.Length - 1) + part5);
// GetCharProps. (This test is too restrictive. In several cases, a larger range could be returned. OTOH it is weak
// in only verifying the writing system to check the properties returned.)
VerifyCharProps(source, 0, wsEn, 0, part0.Length, "props at 0 in complex string");
VerifyCharProps(source, 2, wsEn, 0, part0.Length, "props in middle of first run in complex string");
VerifyCharProps(source, part0.Length - 1, wsEn, 0, part0.Length, "props of last char of first run in complex string");
VerifyCharProps(source, part0.Length, wsFrn, part0.Length, part0.Length + part1.Length, "props at start of second run in complex string");
VerifyCharProps(source, orcPos - 1, wsEn, orcPos - part3.Length, orcPos, "props of last char before ORC");
VerifyCharProps(source, orcPos, wsFrn, orcPos, orcPos + orcText.Length, "props of first char of ORC expansion");
VerifyCharProps(source, orcPos + 1, wsFrn, orcPos, orcPos + orcText.Length, "props of mid char of ORC expansion");
VerifyCharProps(source, orcPos + orcText.Length - 1, wsFrn, orcPos, orcPos + orcText.Length, "props of last char of ORC expansion");
VerifyCharProps(source, orcPos + orcText.Length, wsEn, orcPos + orcText.Length, orcPos + orcText.Length + part5.Length,
"props of first char after ORC expansion");
}