本文整理汇总了C#中WritingSystemDefinition.AddKnownKeyboard方法的典型用法代码示例。如果您正苦于以下问题:C# WritingSystemDefinition.AddKnownKeyboard方法的具体用法?C# WritingSystemDefinition.AddKnownKeyboard怎么用?C# WritingSystemDefinition.AddKnownKeyboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WritingSystemDefinition
的用法示例。
在下文中一共展示了WritingSystemDefinition.AddKnownKeyboard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RoundTrippingLdmlDoesNotDuplicateSections
public void RoundTrippingLdmlDoesNotDuplicateSections()
{
using(var roundTripOut2 = new TempFile())
using(var roundTripOut = new TempFile())
using(var tempFile = new TempFile())
{
using(var writer = new StreamWriter(tempFile.Path, false, Encoding.UTF8))
{
writer.Write(
@"<?xml version='1.0' encoding='utf-8'?>
<ldml>
<identity>
<version
number='' />
<language
type='qaa' />
<variant
type='x-lel' />
</identity>
<collations />
<special xmlns:fw='urn://fieldworks.sil.org/ldmlExtensions/v1'>
<fw:graphiteEnabled
value='False' />
<fw:windowsLCID
value='1036' />
</special>
</ldml>".Replace("'", "\""));
}
var ws = new WritingSystemDefinition();
var dataMapper = new LdmlDataMapper();
dataMapper.Read(tempFile.Path, ws);
var keyboard1 = new DefaultKeyboardDefinition();
keyboard1.Locale = "en-US";
keyboard1.Layout = "MyFavoriteKeyboard";
keyboard1.OperatingSystem = PlatformID.MacOSX; // pick something that for sure won't be our default
ws.AddKnownKeyboard(keyboard1);
using(var fileStream = new FileStream(tempFile.Path, FileMode.Open))
{
dataMapper.Write(roundTripOut.Path, ws, fileStream);
}
AssertThatXmlIn.File(roundTripOut.Path).HasSpecifiedNumberOfMatchesForXpath("/ldml/special/*[local-name()='windowsLCID']", 1);
var secondTripMapper = new LdmlDataMapper();
var secondTripWs = new WritingSystemDefinition();
secondTripMapper.Read(roundTripOut.Path, secondTripWs);
secondTripWs.AddKnownKeyboard(new DefaultKeyboardDefinition()
{
Locale = "qaa",
Layout = "x-tel",
OperatingSystem = PlatformID.Xbox
});
secondTripWs.WindowsLcid = "1037";
using(var fileStream = new FileStream(roundTripOut.Path, FileMode.Open))
{
secondTripMapper.Write(roundTripOut2.Path, secondTripWs, fileStream);
}
AssertThatXmlIn.File(roundTripOut2.Path).HasSpecifiedNumberOfMatchesForXpath("/ldml/special/*[local-name()='windowsLCID']", 1); //Element duplicated on round trip
}
}
示例2: RoundtripKnownKeyboards
public void RoundtripKnownKeyboards()
{
var ldmlAdaptor = new LdmlDataMapper();
Keyboard.Controller = new MyKeyboardController();
const string sortRules = "(A̍ a̍)";
var wsWithKnownKeyboards = new WritingSystemDefinition();
var keyboard1 = new DefaultKeyboardDefinition();
keyboard1.Locale = "en-US";
keyboard1.Layout = "MyFavoriteKeyboard";
keyboard1.OperatingSystem = PlatformID.MacOSX; // pick something that for sure won't be our default
wsWithKnownKeyboards.AddKnownKeyboard(keyboard1);
var keyboard2 = new DefaultKeyboardDefinition();
keyboard2.Locale = "en-GB";
keyboard2.Layout = "SusannasFavoriteKeyboard";
keyboard2.OperatingSystem = PlatformID.Unix;
wsWithKnownKeyboards.AddKnownKeyboard(keyboard2);
var wsFromLdml = new WritingSystemDefinition();
using (var tempFile = new TempFile())
{
ldmlAdaptor.Write(tempFile.Path, wsWithKnownKeyboards, null);
ldmlAdaptor.Read(tempFile.Path, wsFromLdml);
}
var knownKeyboards = wsFromLdml.KnownKeyboards.ToList();
Assert.That(knownKeyboards, Has.Count.EqualTo(2), "restored WS should have known keyboards");
var keyboard1FromLdml = knownKeyboards[0];
Assert.That(keyboard1FromLdml.Layout, Is.EqualTo("MyFavoriteKeyboard"));
Assert.That(keyboard1FromLdml.Locale, Is.EqualTo("en-US"));
Assert.That(keyboard1FromLdml.OperatingSystem, Is.EqualTo(PlatformID.MacOSX));
Assert.That(keyboard1FromLdml, Is.InstanceOf<MyKeyboardDefn>(), "Reader should have used controller to create keyboard defn");
var keyboard2FromLdml = knownKeyboards[1];
Assert.That(keyboard2FromLdml.Layout, Is.EqualTo("SusannasFavoriteKeyboard"));
Assert.That(keyboard2FromLdml.Locale, Is.EqualTo("en-GB"));
Assert.That(keyboard2FromLdml.OperatingSystem, Is.EqualTo(PlatformID.Unix));
}