Esempio n. 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);
        }
Esempio n. 2
0
        internal XElement ToXElement()
        {
            XElement categoryElement = new XElement(NamespaceHelper.GetXName("Category"));

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

            //// Export the child elements of the current object
            if (this.Parameters.Count > 0)
            {
                this.Parameters.ForEach(p => categoryElement.Add(p.ToXElement()));
            }

            if (this.SeriesSets.Count > 0)
            {
                this.SeriesSets.ForEach(s => categoryElement.Add(s.ToXElement()));
            }

            if (this.Categories.Count > 0)
            {
                this.Categories.ForEach(c => categoryElement.Add(c.ToXElement()));
            }

            return(categoryElement);
        }
Esempio n. 3
0
        internal XElement ToXElement()
        {
            XElement siUnitElement = new XElement(NamespaceHelper.GetXName("SIUnit"));

            //// Export all attributes
            if (this.Factor.HasValue)
            {
                siUnitElement.AddAttribute("factor", XmlConvert.ToString(this.Factor.Value));
            }

            if (this.Exponent.HasValue)
            {
                siUnitElement.AddAttribute("exponent", XmlConvert.ToString(this.Exponent.Value));
            }

            if (this.Offset.HasValue)
            {
                siUnitElement.AddAttribute("offset", XmlConvert.ToString(this.Offset.Value));
            }

            //// Export the base unit as content of the SIUnit element
            siUnitElement.Value = this.BaseUnit.GetXmlRepresentation();

            return(siUnitElement);
        }
Esempio n. 4
0
        internal static Result FromXElement(XElement resultElement)
        {
            Result result = new Result();

            //// Import attributes for the implemented interfaces
            result.ImportISignableItemWithName(resultElement);

            //// Import the child elements of the current object
            XElement seriesSetElement = resultElement.Element(NamespaceHelper.GetXName("SeriesSet"));

            if (seriesSetElement != null)
            {
                result.SeriesSet = SeriesSet.FromXElement(seriesSetElement);
            }

            result.Categories.AddRange(resultElement.Elements(NamespaceHelper.GetXName("Category")).Select(Category.FromXElement));

            XElement experimentStepSetElement = resultElement.Element(NamespaceHelper.GetXName("ExperimentStepSet"));

            if (experimentStepSetElement != null)
            {
                result.ExperimentStepSet = ExperimentStepSet.FromXElement(experimentStepSetElement);
            }

            return(result);
        }
Esempio n. 5
0
        internal XElement ToXElement()
        {
            XElement resultElement = new XElement(NamespaceHelper.GetXName("Result"));

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

            //// Export the child elements of the current object
            if (this.SeriesSet != null)
            {
                resultElement.Add(this.SeriesSet.ToXElement());
            }

            if (this.Categories?.Count > 0)
            {
                this.Categories.ForEach(c => resultElement.Add(c.ToXElement()));
            }

            if (this.ExperimentStepSet != null)
            {
                resultElement.Add(this.ExperimentStepSet.ToXElement());
            }

            return(resultElement);
        }
Esempio n. 6
0
        internal XElement ToXElement()
        {
            XElement infrastructureElement = new XElement(NamespaceHelper.GetXName("Infrastructure"));

            //// Export attributes of all implemented interfaces
            infrastructureElement.ImportISignableItem(this);

            //// Export the child elements of the current object
            if (this.SampleReferencetSet != null)
            {
                infrastructureElement.Add(this.SampleReferencetSet.ToXElement());
            }

            if (this.ParentDataPointReferenceSet != null)
            {
                infrastructureElement.Add(this.ParentDataPointReferenceSet.ToXElement());
            }

            if (this.ExperimentDataReferenceSet != null)
            {
                infrastructureElement.Add(this.ExperimentDataReferenceSet.ToXElement());
            }

            if (this.Timestamp.HasValue)
            {
                infrastructureElement.Add(new XElement(NamespaceHelper.GetXName("Timestamp"), XmlConvert.ToString(this.Timestamp.Value, XmlDateTimeSerializationMode.Utc)));
            }

            return(infrastructureElement);
        }
Esempio n. 7
0
        /// <summary>
        /// Returns the current AnimlDocument as its AnIML-XDocument representation.
        /// </summary>
        /// <returns>A XDocument representing the current AnimlDocument.</returns>
        public XDocument ToXDocument()
        {
            //// Create a new XDocument that follows the definition of the AnIML core schema in terms of declaration, namespace and root element.
            XDeclaration xDecl        = new XDeclaration("1.0", "utf-8", "yes");
            XDocument    xDoc         = new XDocument(xDecl);
            XElement     animlElement = new XElement(NamespaceHelper.GetXName("AnIML"));

            animlElement.Add(new XAttribute("version", this.Version));
            xDoc.Add(animlElement);

            //// Add all data elements
            if (this.SampleSet != null)
            {
                animlElement.Add(this.SampleSet.ToXElement());
            }

            if (this.ExperimentStepSet != null)
            {
                animlElement.Add(this.ExperimentStepSet.ToXElement());
            }

            if (this.AuditTrailEntrySet != null)
            {
                animlElement.Add(this.AuditTrailEntrySet.ToXElement());
            }

            return(xDoc);
        }
        internal XElement ToXElement()
        {
            XElement parentDataPointReferenceElement = new XElement(NamespaceHelper.GetXName("ParentDataPointReference"));

            //// Export attributes of all implemented interfaces
            parentDataPointReferenceElement.ImportISignableItem(this);

            //// Export all other attributes
            parentDataPointReferenceElement.AddAttribute("seriesID", this.SeriesId);

            //// Export the child elements of the current object
            XElement startValueElement = new XElement(NamespaceHelper.GetXName("StartValue"));

            startValueElement.Add(DynamicValueHelper.XElementFromValue(this.StartValue));
            parentDataPointReferenceElement.Add(startValueElement);

            if (this.EndValue != null)
            {
                XElement endValueElement = new XElement(NamespaceHelper.GetXName("EndValue"));
                endValueElement.Add(DynamicValueHelper.XElementFromValue(this.EndValue));
                parentDataPointReferenceElement.Add(endValueElement);
            }

            return(parentDataPointReferenceElement);
        }
Esempio n. 9
0
        internal XElement ToXElement()
        {
            XElement auditTrailEntryElement = new XElement(NamespaceHelper.GetXName("AuditTrailEntry"));

            //// Export attributes of all implemented interfaces
            auditTrailEntryElement.ImportISignableItem(this);

            //// Export the child elements of the current object
            auditTrailEntryElement.Add(new XElement(NamespaceHelper.GetXName("Timestamp"), XmlConvert.ToString(this.Timestamp, XmlDateTimeSerializationMode.Utc)));
            auditTrailEntryElement.Add(this.Author.ToXElement());

            if (this.Software != null)
            {
                auditTrailEntryElement.Add(this.Software.ToXElement());
            }

            auditTrailEntryElement.Add(this.Action.GetXmlRepresentation());

            if (this.Reason != null)
            {
                auditTrailEntryElement.Add(new XElement(NamespaceHelper.GetXName("Reason"), this.Reason));
            }

            if (this.Comment != null)
            {
                auditTrailEntryElement.Add(new XElement(NamespaceHelper.GetXName("Comment"), this.Comment));
            }

            if (this.References?.Count > 0)
            {
                this.References.ForEach(r => auditTrailEntryElement.Add(new XElement(NamespaceHelper.GetXName("Reference"), r)));
            }

            return(auditTrailEntryElement);
        }
Esempio n. 10
0
        internal XElement ToXElement()
        {
            XElement methodElement = new XElement(NamespaceHelper.GetXName("Method"));

            //// Export attributes of all implemented interfaces
            methodElement.ImportISignableItem(this);

            //// Export all other attributes
            methodElement.AddAttributeIfValueNotNullOrEmpty("name", this.Name);

            //// Export the child elements of the current object
            if (this.Author != null)
            {
                methodElement.Add(this.Author.ToXElement());
            }

            if (this.Device != null)
            {
                methodElement.Add(this.Device.ToXElement());
            }

            if (this.Software != null)
            {
                methodElement.Add(this.Software.ToXElement());
            }

            if (this.Categories?.Count > 0)
            {
                this.Categories.ForEach(c => methodElement.Add(c.ToXElement()));
            }

            return(methodElement);
        }
Esempio n. 11
0
        internal XElement ToXElement()
        {
            XElement encodedValueSetElement = new XElement(NamespaceHelper.GetXName("EncodedValueSet"));

            //// Export attributes of all implemented interfaces
            encodedValueSetElement.ImportIValueSet(this);

            //// Export the values to the content
            if (this.SeriesType == SeriesType.Int32)
            {
                encodedValueSetElement.Value = this.Cast <int>().ToArray().ToBase64String();
            }
            else if (this.SeriesType == SeriesType.Int64)
            {
                encodedValueSetElement.Value = this.Cast <long>().ToArray().ToBase64String();
            }
            else if (this.SeriesType == SeriesType.Float32)
            {
                encodedValueSetElement.Value = this.Cast <float>().ToArray().ToBase64String();
            }
            else if (this.SeriesType == SeriesType.Float64)
            {
                encodedValueSetElement.Value = this.Cast <double>().ToArray().ToBase64String();
            }
            else
            {
                throw new NotSupportedException($"SeriesType {this.SeriesType} is not supported when generating an XElement from an EncodedValueSet.");
            }

            return(encodedValueSetElement);
        }
Esempio n. 12
0
 internal static void AddElementIfValueNotNullOrEmpty(this XElement element, string name, string value)
 {
     if (!string.IsNullOrEmpty(value))
     {
         element.Add(new XElement(NamespaceHelper.GetXName(name), value));
     }
 }
        internal XElement ToXElement()
        {
            XElement parentDataPointReferenceSetElement = new XElement(NamespaceHelper.GetXName("ParentDataPointReferenceSet"));

            //// Export the child elements of the current object
            this.ParentDataPointReferences.ForEach(p => parentDataPointReferenceSetElement.Add(p.ToXElement()));

            return(parentDataPointReferenceSetElement);
        }
Esempio n. 14
0
        internal static TagSet FromXElement(XElement tagSetElement)
        {
            TagSet tagSet = new TagSet();

            //// Import the child elements of the current object
            tagSet.Tags.AddRange(tagSetElement.Elements(NamespaceHelper.GetXName("Tag")).Select(Tag.FromXElement));

            return(tagSet);
        }
Esempio n. 15
0
        internal XElement ToXElement()
        {
            XElement tagSetElement = new XElement(NamespaceHelper.GetXName("TagSet"));

            //// Export the child elements of the current object
            this.Tags.ForEach(t => tagSetElement.Add(t.ToXElement()));

            return(tagSetElement);
        }
Esempio n. 16
0
        internal static void AddElement(this XElement element, string name, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("Value of the element must not be null or empty.", nameof(value));
            }

            element.Add(new XElement(NamespaceHelper.GetXName(name), value));
        }
Esempio n. 17
0
        internal XElement ToXElement()
        {
            XElement tagElement = new XElement(NamespaceHelper.GetXName("Tag"));

            // Export all attributes
            tagElement.AddAttribute("name", this.Name);
            tagElement.AddAttributeIfValueNotNullOrEmpty("value", this.Value);

            return(tagElement);
        }
Esempio n. 18
0
        internal XElement ToXElement()
        {
            XElement sampleInheritanceElement = new XElement(NamespaceHelper.GetXName("SampleInheritance"));

            //// Export attributes of all implemented interfaces
            sampleInheritanceElement.ImportISignableItem(this);
            sampleInheritanceElement.ImportISampleAttributes(this);

            return(sampleInheritanceElement);
        }
Esempio n. 19
0
        internal XElement ToXElement()
        {
            XElement extensionElement = new XElement(NamespaceHelper.GetXName("Extension"));

            //// Export all attributes
            extensionElement.AddAttribute("uri", this.Uri.OriginalString);
            extensionElement.AddAttribute("name", this.Name);
            extensionElement.AddAttributeIfValueNotNullOrEmpty("sha256", this.Sha256);

            return(extensionElement);
        }
Esempio n. 20
0
        internal XElement ToXElement()
        {
            XElement softwareElement = new XElement(NamespaceHelper.GetXName("Software"));

            softwareElement.AddElementIfValueNotNullOrEmpty("Manufacturer", this.Manufacturer);
            softwareElement.AddElement("Name", this.Name);
            softwareElement.AddElementIfValueNotNullOrEmpty("Version", this.Version);
            softwareElement.AddElementIfValueNotNullOrEmpty("OperatingSystem", this.OperatingSystem);

            return(softwareElement);
        }
Esempio n. 21
0
        internal XElement ToXElement()
        {
            XElement individualValueSetElement = new XElement(NamespaceHelper.GetXName("IndividualValueSet"));

            //// Export attributes of all implemented interfaces
            individualValueSetElement.ImportIValueSet(this);

            //// Export the values to child elements
            this.ForEach(v => individualValueSetElement.Add(DynamicValueHelper.XElementFromValue(v)));

            return(individualValueSetElement);
        }
Esempio n. 22
0
        internal XElement ToXElement()
        {
            XElement sampleSetElement = new XElement(NamespaceHelper.GetXName("SampleSet"));

            //// Export attributes of all implemented interfaces
            sampleSetElement.ImportISignableItem(this);

            //// Export the child elements of the current object
            this.Samples.ForEach(s => sampleSetElement.Add(s.ToXElement()));

            return(sampleSetElement);
        }
Esempio n. 23
0
        internal static Software FromXElement(XElement softwareElement)
        {
            Software software = new Software();

            //// Import the child elements of the current object
            software.Manufacturer    = softwareElement.Element(NamespaceHelper.GetXName("Manufacturer"))?.Value;
            software.Name            = softwareElement.Element(NamespaceHelper.GetXName("Name")).Value;
            software.Version         = softwareElement.Element(NamespaceHelper.GetXName("Version"))?.Value;
            software.OperatingSystem = softwareElement.Element(NamespaceHelper.GetXName("OperatingSystem"))?.Value;

            return(software);
        }
Esempio n. 24
0
        internal XElement ToXElement()
        {
            XElement auditTrailEntrySetElement = new XElement(NamespaceHelper.GetXName("AuditTrailEntrySet"));

            //// Export attributes of all implemented interfaces
            auditTrailEntrySetElement.ImportISignableItem(this);

            //// Export the child elements of the current object
            this.AuditTrailEntries.ForEach(a => auditTrailEntrySetElement.Add(a.ToXElement()));

            return(auditTrailEntrySetElement);
        }
Esempio n. 25
0
        internal XElement ToXElement()
        {
            XElement sampleReferenceElement = new XElement(NamespaceHelper.GetXName("SampleReference"));

            //// Export attributes of all implemented interfaces
            sampleReferenceElement.ImportISignableItem(this);
            sampleReferenceElement.ImportISampleAttributes(this);

            //// Export all other attributes
            sampleReferenceElement.AddAttribute("sampleID", this.SampleId);

            return(sampleReferenceElement);
        }
Esempio n. 26
0
        internal XElement ToXElement()
        {
            XElement experimentDataBulkReferenceElement = new XElement(NamespaceHelper.GetXName("ExperimentDataBulkReference"));

            //// Export attributes of all implemented interfaces
            experimentDataBulkReferenceElement.ImportISignableItem(this);
            experimentDataBulkReferenceElement.ImportIExperimentDataAttributes(this);

            //// Export all other attributes
            experimentDataBulkReferenceElement.AddAttribute("experimentStepIDPrefix", this.ExperimentStepIdPrefix);

            return(experimentDataBulkReferenceElement);
        }
Esempio n. 27
0
        internal XElement ToXElement()
        {
            XElement experimentStepSetElement = new XElement(NamespaceHelper.GetXName("ExperimentStepSet"));

            //// Export attributes of all implemented interfaces
            experimentStepSetElement.ImportISignableItem(this);

            //// Export the child elements of the current object
            this.ExperimentSteps.ForEach(s => experimentStepSetElement.Add(s.ToXElement()));
            this.Templates.ForEach(t => experimentStepSetElement.Add(t.ToXElement()));

            return(experimentStepSetElement);
        }
Esempio n. 28
0
        internal XElement ToXElement()
        {
            XElement autoIncrementedValueSetElement = new XElement(NamespaceHelper.GetXName("AutoIncrementedValueSet"));

            //// Export attributes of all implemented interfaces
            autoIncrementedValueSetElement.ImportIValueSet(this);

            //// Export the child elements of the current object
            autoIncrementedValueSetElement.Add(new XElement(NamespaceHelper.GetXName("StartValue"), DynamicValueHelper.XElementFromValue(this.StartValue)));
            autoIncrementedValueSetElement.Add(new XElement(NamespaceHelper.GetXName("Increment"), DynamicValueHelper.XElementFromValue(this.Increment)));

            return(autoIncrementedValueSetElement);
        }
Esempio n. 29
0
        internal XElement ToXElement()
        {
            XElement deviceElement = new XElement(NamespaceHelper.GetXName("Device"));

            //// Export the child elements of the current object
            deviceElement.AddElementIfValueNotNullOrEmpty("DeviceIdentifier", this.DeviceIdentifier);
            deviceElement.AddElementIfValueNotNullOrEmpty("Manufacturer", this.Manufacturer);
            deviceElement.AddElement("Name", this.Name);
            deviceElement.AddElementIfValueNotNullOrEmpty("FirmwareVersion", this.FirmwareVersion);
            deviceElement.AddElementIfValueNotNullOrEmpty("SerialNumber", this.SerialNumber);

            return(deviceElement);
        }
Esempio n. 30
0
        internal static Device FromXElement(XElement deviceElement)
        {
            Device device = new Device();

            //// Import the child elements of the current object
            device.DeviceIdentifier = deviceElement.Element(NamespaceHelper.GetXName("DeviceIdentifier"))?.Value;
            device.Manufacturer     = deviceElement.Element(NamespaceHelper.GetXName("Manufacturer"))?.Value;
            device.Name             = deviceElement.Element(NamespaceHelper.GetXName("Name")).Value;
            device.FirmwareVersion  = deviceElement.Element(NamespaceHelper.GetXName("FirmwareVersion"))?.Value;
            device.SerialNumber     = deviceElement.Element(NamespaceHelper.GetXName("SerialNumber"))?.Value;

            return(device);
        }