本文整理汇总了C#中DicomAttributeCollection.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# DicomAttributeCollection.GetEnumerator方法的具体用法?C# DicomAttributeCollection.GetEnumerator怎么用?C# DicomAttributeCollection.GetEnumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomAttributeCollection
的用法示例。
在下文中一共展示了DicomAttributeCollection.GetEnumerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMementoForCollection
private XmlElement GetMementoForCollection(XmlDocument theDocument, DicomAttributeCollection baseCollection,
DicomAttributeCollection collection, StudyXmlOutputSettings settings)
{
XmlElement instance;
if (collection is DicomSequenceItem)
{
instance = theDocument.CreateElement("Item");
}
else
{
instance = theDocument.CreateElement("Instance");
XmlAttribute sopInstanceUid = theDocument.CreateAttribute("UID");
sopInstanceUid.Value = _sopInstanceUid;
instance.Attributes.Append(sopInstanceUid);
if (_sopClass != null)
{
XmlAttribute sopClassAttribute = theDocument.CreateAttribute("SopClassUID");
sopClassAttribute.Value = _sopClass.Uid;
instance.Attributes.Append(sopClassAttribute);
}
if (_transferSyntax != null && !(this is BaseInstanceXml))
{
XmlAttribute transferSyntaxAttribute = theDocument.CreateAttribute("TransferSyntaxUID");
transferSyntaxAttribute.Value = _transferSyntax.UidString;
instance.Attributes.Append(transferSyntaxAttribute);
}
if (_sourceFileName != null && settings.IncludeSourceFileName)
{
XmlAttribute sourceFileNameAttribute = theDocument.CreateAttribute("SourceFileName");
string fileName = SecurityElement.Escape(_sourceFileName);
sourceFileNameAttribute.Value = fileName;
instance.Attributes.Append(sourceFileNameAttribute);
}
if (_fileSize != 0)
{
XmlAttribute fileSize = theDocument.CreateAttribute("FileSize");
fileSize.Value = _fileSize.ToString();
instance.Attributes.Append(fileSize);
}
}
IPrivateInstanceXmlDicomAttributeCollection thisCollection = null;
if (collection is IPrivateInstanceXmlDicomAttributeCollection)
{
thisCollection = (IPrivateInstanceXmlDicomAttributeCollection)collection;
foreach (DicomTag tag in thisCollection.ExcludedTags)
{
//Artificially seed the collection with empty attributes from this
//instance and the base instance so we can add them in the right order.
//Note in the case of the base instance, this will never alter
//the collection because the empty attribute is already there (see ParseAttribute).
DicomAttribute attribute = collection[tag];
}
}
IEnumerator<DicomAttribute> baseIterator = null;
IPrivateInstanceXmlDicomAttributeCollection privateBaseCollection = null;
if (baseCollection != null)
{
privateBaseCollection = baseCollection as IPrivateInstanceXmlDicomAttributeCollection;
if (privateBaseCollection != null)
{
foreach (DicomTag tag in privateBaseCollection.ExcludedTags)
{
//Artificially seed the collection with empty attributes from this
//instance and the base instance so we can add them in the right order.
//Note in the case of the base instance, this will never alter
//the collection because the empty attribute is already there (see ParseAttribute).
DicomAttribute attribute = collection[tag];
}
}
baseIterator = baseCollection.GetEnumerator();
if (!baseIterator.MoveNext())
baseIterator = null;
}
List<DicomTag> newlyExcludedTags = new List<DicomTag>();
foreach (DicomAttribute attribute in collection)
{
bool isExcludedFromThisCollection = thisCollection != null &&
thisCollection.IsTagExcluded(attribute.Tag.TagValue);
bool isExcludedFromBase = privateBaseCollection != null &&
privateBaseCollection.ExcludedTagsHelper.IsTagExcluded(attribute.Tag.TagValue);
bool isInBase = isExcludedFromBase;
bool isSameAsInBase = isExcludedFromThisCollection && isExcludedFromBase;
if (baseIterator != null)
{
while (baseIterator != null && baseIterator.Current.Tag < attribute.Tag)
{
//.........这里部分代码省略.........
示例2: ValidateEqualExceptExclusions
private void ValidateEqualExceptExclusions(DicomAttributeCollection collection1, DicomAttributeCollection collection2, params uint[] ignoreTags)
{
IEnumerator<DicomAttribute> iterator1 = collection1.GetEnumerator();
IEnumerator<DicomAttribute> iterator2 = collection2.GetEnumerator();
while(iterator1.MoveNext())
{
bool ignored = false;
foreach (uint ignoreTag in ignoreTags)
{
if (ignoreTag == iterator1.Current.Tag.TagValue)
{
ignored = true;
break;
}
}
if (ignored)
continue;
DicomAttribute attribute = iterator1.Current;
if (collection1 is InstanceXmlDicomAttributeCollection)
{
if (((InstanceXmlDicomAttributeCollection)collection1).ExcludedTags.Contains(attribute.Tag))
continue;
}
if (collection2 is InstanceXmlDicomAttributeCollection)
{
if (((InstanceXmlDicomAttributeCollection)collection2).ExcludedTags.Contains(attribute.Tag))
continue;
}
while (true)
{
if (!iterator2.MoveNext())
throw new Exception("Tag exists in collection 1, but not collection 2.");
else if (iterator2.Current.Tag == iterator1.Current.Tag)
break;
else
{
ignored = false;
foreach (uint ignoreTag in ignoreTags)
{
if (ignoreTag == iterator2.Current.Tag.TagValue)
{
ignored = true;
break;
}
}
if (ignored)
continue;
else if (!iterator2.Current.IsEmpty)
throw new Exception("Tag exists in collection 2, but not collection 1.");
}
}
DicomAttribute attribute2 = iterator2.Current;
if (attribute2.IsEmpty && attribute.IsEmpty)
continue;
if (!attribute.Equals(attribute2))
throw new Exception("Attributes should be equal.");
}
while(iterator2.MoveNext())
{
bool ignored = false;
foreach (uint ignoreTag in ignoreTags)
{
if (ignoreTag == iterator2.Current.Tag.TagValue)
{
ignored = true;
break;
}
}
if (ignored)
continue;
else if (!iterator2.Current.IsEmpty)
throw new Exception("Tag exists in collection 2, but not collection 1.");
}
}
示例3: InstanceXml
public InstanceXml(XmlNode instanceNode, DicomAttributeCollection baseCollection)
{
InstanceXmlDicomAttributeCollection thisCollection = new InstanceXmlDicomAttributeCollection();
_collection = thisCollection;
_collection.ValidateVrValues = false;
_collection.ValidateVrLengths = false;
if (baseCollection != null)
{
AddExcludedTagsFromBase(baseCollection);
_baseCollectionEnumerator = baseCollection.GetEnumerator();
if (!_baseCollectionEnumerator.MoveNext())
_baseCollectionEnumerator = null;
}
if (!instanceNode.HasChildNodes)
return;
_instanceXmlEnumerator = instanceNode.ChildNodes.GetEnumerator();
if (!_instanceXmlEnumerator.MoveNext())
_instanceXmlEnumerator = null;
if (instanceNode.Attributes["UID"] != null)
{
_sopInstanceUid = instanceNode.Attributes["UID"].Value;
}
if (instanceNode.Attributes["SopClassUID"] != null)
{
_sopClass = SopClass.GetSopClass(instanceNode.Attributes["SopClassUID"].Value);
}
_transferSyntax = instanceNode.Attributes["TransferSyntaxUID"] != null
? TransferSyntax.GetTransferSyntax(instanceNode.Attributes["TransferSyntaxUID"].Value)
: TransferSyntax.ExplicitVrLittleEndian;
if (instanceNode.Attributes["SourceFileName"] != null)
{
_sourceFileName = instanceNode.Attributes["SourceFileName"].Value;
}
if (instanceNode.Attributes["FileSize"] != null)
{
long.TryParse(instanceNode.Attributes["FileSize"].Value, out _fileSize);
}
// This should never happen
if (_sopClass == null)
{
_sopClass = SopClass.GetSopClass(Collection[DicomTags.SopClassUid].GetString(0, String.Empty));
}
}