internal static AutoIncrementedValueSet FromXElement(XElement autoIncrementedValueSetElement, SeriesType seriesType)
        {
            if (seriesType == SeriesType.Int32 || seriesType == SeriesType.Int64 || seriesType == SeriesType.Float32 || seriesType == SeriesType.Float64)
            {
                AutoIncrementedValueSet autoIncrementedValueSet = new AutoIncrementedValueSet();

                //// Import attributes for the implemented interfaces
                autoIncrementedValueSet.ImportIValueSet(autoIncrementedValueSetElement);

                //// Import the child elements of the current object
                autoIncrementedValueSet.StartValue = autoIncrementedValueSetElement.Element(NamespaceHelper.GetXName("StartValue")).ImportNumericValue();
                autoIncrementedValueSet.Increment  = autoIncrementedValueSetElement.Element(NamespaceHelper.GetXName("Increment")).ImportNumericValue();

                return(autoIncrementedValueSet);
            }
            else
            {
                throw new TypeNotAllowedException($"SeriesType '{seriesType}' is not allowed for AutoIncrementedValueSet.");
            }
        }
Exemple #2
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);
        }