Example #1
0
        internal static Series FromXElement(XElement seriesElement)
        {
            Series series = new Series();

            //// Import attributes for the interfaces a Series implements
            series.ImportISignableItemWithName(seriesElement);

            //// Import all other attributes for a Series
            series.Dependency = seriesElement.Attribute("dependency").ImportDependency();
            series.SeriesId   = seriesElement.Attribute("seriesID").Value;

            XAttribute visibleAttribute = seriesElement.Attribute("visible");

            if (visibleAttribute != null)
            {
                series.Visible = XmlConvert.ToBoolean(visibleAttribute.Value);
            }

            XAttribute plotScaleAttribute = seriesElement.Attribute("plotScale");

            if (plotScaleAttribute != null)
            {
                series.PlotScale = plotScaleAttribute.ImportPlotScale();
            }

            series.SeriesType = seriesElement.Attribute("seriesType").ImportSeriesType();

            //// Import the child elements of the Series
            series.ValueSets.AddRange(seriesElement.Elements(NamespaceHelper.GetXName("IndividualValueSet")).Select(x => IndividualValueSet.FromXElement(x, series.SeriesType)));
            series.ValueSets.AddRange(seriesElement.Elements(NamespaceHelper.GetXName("EncodedValueSet")).Select(x => EncodedValueSet.FromXElement(x, series.SeriesType)));
            series.ValueSets.AddRange(seriesElement.Elements(NamespaceHelper.GetXName("AutoIncrementedValueSet")).Select(x => AutoIncrementedValueSet.FromXElement(x, series.SeriesType)));

            XElement unitElement = seriesElement.Element(NamespaceHelper.GetXName("Unit"));

            if (unitElement != null)
            {
                series.Unit = Unit.FromXElement(unitElement);
            }

            return(series);
        }