Пример #1
0
        /// <summary>
        /// Adds a new series instance to the collection
        /// of series instances in this channel instance.
        /// </summary>
        /// <returns>New series instance.</returns>
        public SeriesInstance AddNewSeriesInstance()
        {
            if (Definition.SeriesDefinitions.Count <= SeriesInstances.Count)
            {
                throw new InvalidOperationException("Cannot create a series instance without a corresponding series definition.");
            }

            CollectionElement seriesInstanceElement = new CollectionElement {
                TagOfElement = OneSeriesInstanceTag
            };
            SeriesDefinition seriesDefinition = Definition.SeriesDefinitions[SeriesInstances.Count];
            SeriesInstance   seriesInstance   = new SeriesInstance(seriesInstanceElement, this, seriesDefinition);

            seriesInstanceElement.AddOrUpdateVector(SeriesInstance.SeriesValuesTag, PhysicalType.UnsignedInteger1, new byte[0]);

            CollectionElement?seriesInstancesElement = m_physicalStructure.GetCollectionByTag(SeriesInstancesTag);

            if (seriesInstancesElement == null)
            {
                seriesInstancesElement = new CollectionElement {
                    TagOfElement = SeriesInstancesTag
                };
                m_physicalStructure.AddElement(seriesInstancesElement);
            }

            seriesInstancesElement.AddElement(seriesInstanceElement);

            return(seriesInstance);
        }
Пример #2
0
        /// <summary>
        /// Removes the given series instance from the collection of series instances.
        /// </summary>
        /// <param name="seriesInstance">The series instance to be removed.</param>
        public void Remove(SeriesInstance seriesInstance)
        {
            CollectionElement?seriesInstancesElement = m_physicalStructure.GetCollectionByTag(SeriesInstancesTag);

            if (seriesInstancesElement == null)
            {
                return;
            }

            IList <SeriesDefinition> seriesDefinitions      = Definition.SeriesDefinitions;
            List <CollectionElement> seriesInstanceElements = seriesInstancesElement.GetElementsByTag(OneSeriesInstanceTag).Cast <CollectionElement>().ToList();

            for (int i = seriesInstanceElements.Count; i >= 0; i--)
            {
                SeriesInstance instance = new SeriesInstance(seriesInstanceElements[i], this, seriesDefinitions[i]);

                if (Equals(seriesInstance, instance))
                {
                    seriesInstancesElement.RemoveElement(seriesInstancesElement);
                }
            }
        }