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


C# DicomAttribute.ToString方法代码示例

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


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

示例1: Create

		public static ImageProperty Create(DicomAttribute attribute, string category, string name, string description, string separator)
		{
			// always use the hex value as the identifier, so that private and unknown tags aren't all mapped to the same identifier
			string identifier = attribute.Tag.HexString;

			if (category == null)
				category = string.Empty;

			if (string.IsNullOrEmpty(name))
				name = GetTagName(attribute.Tag);

			if (string.IsNullOrEmpty(description))
				description = GetTagDescription(attribute.Tag);

			if (attribute.IsNull || attribute.IsEmpty)
				return new ImageProperty(identifier, category, name, description, string.Empty);

			if (String.IsNullOrEmpty(separator))
				separator = ", ";

			object value;
			if (attribute.Tag.VR.Name == DicomVr.DAvr.Name)
			{
				value = StringUtilities.Combine(attribute.Values as string[], separator,
				                                delegate(string dateString)
				                                	{
				                                		DateTime? date = DateParser.Parse(dateString);
				                                		if (!date.HasValue)
				                                			return null;
				                                		else
				                                			return Format.Date(date.Value);
				                                	}, true);
			}
			else if (attribute.Tag.VR.Name == DicomVr.TMvr.Name)
			{
				value = StringUtilities.Combine(attribute.Values as string[], separator,
				                                delegate(string timeString)
				                                	{
				                                		DateTime? time = TimeParser.Parse(timeString);
				                                		if (!time.HasValue)
				                                			return null;
				                                		else
				                                			return Format.Time(time.Value);
				                                	}, true);
			}
			else if (attribute.Tag.VR.Name == DicomVr.DTvr.Name)
			{
				value = StringUtilities.Combine(attribute.Values as string[], separator,
				                                delegate(string dateTimeString)
				                                	{
				                                		DateTime? dateTime = DateTimeParser.Parse(dateTimeString);
				                                		if (!dateTime.HasValue)
				                                			return null;
				                                		else
				                                			return Format.Time(dateTime.Value);
				                                	}, true);
			}
			else if (attribute.Tag.VR.Name == DicomVr.PNvr.Name)
			{
				value = StringUtilities.Combine(attribute.Values as string[], separator,
				                                delegate(string nameString)
				                                	{
				                                		PersonName personName = new PersonName(nameString ?? "");
				                                		return personName.FormattedName;
				                                	}, true);
			}
			else if (attribute.Tag.VR == DicomVr.SQvr)
			{
				value = string.Empty;

				var values = attribute.Values as DicomSequenceItem[];
				if (values != null && values.Length > 0)
				{
					// handle simple use case by listing only the attributes of the first sequence item
					// since user can always use DICOM editor for more complex use cases
					var subproperties = new List<IImageProperty>();
					foreach (var subattribute in values[0])
						subproperties.Add(Create(subattribute, string.Empty, null, null, null));
					subproperties.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase));
					value = subproperties.ToArray();
				}
			}
			else if (attribute.Tag.VR.IsTextVR && attribute.GetValueType() == typeof(string[]))
			{
				value = StringUtilities.Combine(attribute.Values as string[], separator, true);
			}
			else
			{
				value = attribute.ToString();
			}

			return new ImageProperty(identifier, category, name, description, value);
		}
开发者ID:nhannd,项目名称:Xian,代码行数:93,代码来源:ImageProperty.cs


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