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


C# WritingSystemDefinition.SetAllComponents方法代码示例

本文整理汇总了C#中WritingSystemDefinition.SetAllComponents方法的典型用法代码示例。如果您正苦于以下问题:C# WritingSystemDefinition.SetAllComponents方法的具体用法?C# WritingSystemDefinition.SetAllComponents怎么用?C# WritingSystemDefinition.SetAllComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WritingSystemDefinition的用法示例。


在下文中一共展示了WritingSystemDefinition.SetAllComponents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadIdentityElement

		private void ReadIdentityElement(XmlReader reader, WritingSystemDefinition ws)
		{
			Debug.Assert(reader.NodeType == XmlNodeType.Element && reader.Name == "identity");
			using (XmlReader identityReader = reader.ReadSubtree())
			{
				identityReader.MoveToContent();
				identityReader.ReadStartElement("identity");
				if (FindElement(identityReader, "version"))
				{
					ws.VersionNumber = identityReader.GetAttribute("number") ?? string.Empty;
					if (!identityReader.IsEmptyElement)
					{
						ws.VersionDescription = identityReader.ReadString();
						identityReader.ReadEndElement();
					}
				}
				string dateTime = GetSubNodeAttributeValue(identityReader, "generation", "date");
				DateTime modified = DateTime.UtcNow;
				if (!string.IsNullOrEmpty(dateTime.Trim()) && !DateTime.TryParse(dateTime, out modified))
				{
					//CVS format:    "$Date: 2008/06/18 22:52:35 $"
					modified = DateTime.ParseExact(dateTime, "'$Date: 'yyyy/MM/dd HH:mm:ss $", null,
												   DateTimeStyles.AssumeUniversal);
				}

				ws.DateModified = modified;

				string language = GetSubNodeAttributeValue(identityReader, "language", "type");
				string script = GetSubNodeAttributeValue(identityReader, "script", "type");
				string region = GetSubNodeAttributeValue(identityReader, "territory", "type");
				string variant = GetSubNodeAttributeValue(identityReader, "variant", "type");

				if ((language.StartsWith("x-", StringComparison.OrdinalIgnoreCase) || language.Equals("x", StringComparison.OrdinalIgnoreCase)))
				{
					var flexRfcTagInterpreter = new FlexConformPrivateUseRfc5646TagInterpreter();
					flexRfcTagInterpreter.ConvertToPalasoConformPrivateUseRfc5646Tag(language, script, region, variant);
					ws.SetAllComponents(flexRfcTagInterpreter.Language, flexRfcTagInterpreter.Script, flexRfcTagInterpreter.Region, flexRfcTagInterpreter.Variant);

					_wsIsFlexPrivateUse = true;
				}
				else
				{
					ws.SetAllComponents(language, script, region, variant);

					_wsIsFlexPrivateUse = false;
				}
				//Set the id simply as the concatenation of whatever was in the ldml file.
				ws.Id = String.Join("-", new[] {language, script, region, variant}.Where(subtag => !String.IsNullOrEmpty(subtag)).ToArray());
				// move to end of identity node
				while (identityReader.Read()) ;
			}
			if (!reader.IsEmptyElement)
			{
				reader.ReadEndElement();
			}
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:56,代码来源:LdmlDataMapper.cs


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