Exemple #1
0
        internal XElement ToXElement()
        {
            XElement sampleElement = new XElement(NamespaceHelper.GetXName("Sample"));

            //// Export attributes of all implemented interfaces
            sampleElement.ImportISignableItemWithName(this);
            sampleElement.ImportISourceDataLocation(this);

            //// Export all other attributes
            sampleElement.AddAttribute("sampleID", this.SampleId);
            sampleElement.AddAttributeIfValueNotNullOrEmpty("barcode", this.Barcode);
            sampleElement.AddAttributeIfValueNotNullOrEmpty("comment", this.Comment);
            sampleElement.AddAttributeIfNotNull("derived", this.Derived);
            sampleElement.AddAttributeIfNotNull("containerType", this.ContainerType);
            sampleElement.AddAttributeIfValueNotNullOrEmpty("containerID", this.ContainerId);
            sampleElement.AddAttributeIfValueNotNullOrEmpty("locationInContainer", this.LocationInContainer);

            //// Export the child elements of the current object

            //// Do not export an empty TagSet
            if (this.TagSet?.Tags.Count > 0)
            {
                sampleElement.Add(this.TagSet.ToXElement());
            }

            this.Categories.ForEach(c => sampleElement.Add(c.ToXElement()));

            return(sampleElement);
        }
Exemple #2
0
        internal XElement ToXElement()
        {
            XElement seriesElement = new XElement(NamespaceHelper.GetXName("Series"));

            //// Export attributes of all implemented interfaces
            seriesElement.ImportISignableItemWithName(this);

            //// Export all other attributes
            seriesElement.AddAttribute("dependency", this.Dependency.GetXmlRepresentation());
            seriesElement.AddAttribute("seriesID", this.SeriesId);
            seriesElement.AddAttributeIfNotNull("visible", this.Visible);

            if (this.PlotScale.HasValue)
            {
                seriesElement.AddAttribute("plotScale", this.PlotScale.Value.GetXmlRepresentation());
            }

            seriesElement.AddAttribute("seriesType", this.SeriesType.GetXmlRepresentation());

            //// Export the child elements of the current object
            foreach (IValueSet valueSet in this.ValueSets)
            {
                if (valueSet is IndividualValueSet indValueSet)
                {
                    seriesElement.Add(indValueSet.ToXElement());
                }
                else if (valueSet is EncodedValueSet encValueSet)
                {
                    seriesElement.Add(encValueSet.ToXElement());
                }
                else if (valueSet is AutoIncrementedValueSet autoIncValueSet)
                {
                    seriesElement.Add(autoIncValueSet.ToXElement());
                }
            }

            if (this.Unit != null)
            {
                seriesElement.Add(this.Unit.ToXElement());
            }

            return(seriesElement);
        }