本文整理匯總了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));
}