当前位置: 首页>>代码示例>>C#>>正文


C# WritingSystemDefinition.AddKnownKeyboard方法代码示例

本文整理汇总了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
			}
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:61,代码来源:LdmlDataMapperTests.cs

示例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));
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:40,代码来源:LdmlDataMapperTests.cs


注:本文中的WritingSystemDefinition.AddKnownKeyboard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。