Exemple #1
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);
        }
        public XElement GetXElement(ArtistWebInfo webInfo)
        {
            var xml = new XElement(PropertyNames.WebInfo);

            xml.AddAttribute(PropertyNames.WebInfoUpdated, webInfo.Updated.ToString(StandardDateFormat));
            xml.AddAttribute(PropertyNames.WebInfoWiki, webInfo.Wiki);
            xml.AddAttribute(PropertyNames.WebInfoImageSmall, webInfo.MediumImageUrl);
            xml.AddAttribute(PropertyNames.WebInfoImageMedium, webInfo.SmallImageUrl);
            xml.AddAttribute(PropertyNames.WebInfoImageLarge, webInfo.LargeImageUrl);
            xml.AddAttribute(PropertyNames.WebInfoImageExtraLarge, webInfo.ExtraLargeImageUrl);

            var similarArtistsXml = new XElement(PropertyNames.WebInfoSimilarArtists);

            foreach (var artist in webInfo.SimilarArtists)
            {
                var artistXml = new XElement(PropertyNames.WebInfoSimilarArtist);
                artistXml.AddAttribute(PropertyNames.WebInfoSimilarArtistName, artist.Name);
                artistXml.AddAttribute(PropertyNames.WebInfoSimilarArtistUrl, artist.Url);
                artistXml.AddAttribute(PropertyNames.WebInfoSimilarArtistImage, artist.ImageUrl);
                similarArtistsXml.Add(artistXml);
            }
            xml.Add(similarArtistsXml);

            return(xml);
        }
        public void SaveFeeds(List <Feed> feeds)
        {
            var xml = _xmlProvider.Get();

            var rootXml = new XElement(RssRoot);

            xml.Add(rootXml);

            var feedsXml = new XElement(RssFeeds);

            rootXml.Add(feedsXml);

            foreach (var feed in feeds)
            {
                var feedXml = new XElement(RssFeed);
                feedXml.AddAttribute(RssTitle, feed.Title);
                feedXml.AddAttribute(RssUrl, feed.Url);
                feedXml.AddAttribute(RssFeedUrl, feed.FeedUrl);
                feedXml.AddAttribute(RssIconUrl, feed.IconUrl);
                feedXml.AddAttribute(RssColor, feed.Color);
                feedsXml.Add(feedXml);
            }

            _xmlProvider.Save(xml);
        }
        private void convertPopulationSettings(XElement element)
        {
            //here we need to convert the nodes for a population simulation
            var allSelectedQuantities = element.Descendants("SelectedQuantities").FirstOrDefault();

            if (allSelectedQuantities == null)
            {
                return;
            }

            var populationSettings = new XElement("PopulationSimulationSettings");

            populationSettings.AddAttribute("dynamicName", "Settings");
            var newSelectedQuantities = new XElement("SelectedQuantities");

            populationSettings.Add(newSelectedQuantities);

            foreach (var moleculeSelection in allSelectedQuantities.Descendants("MoleculeSelection").ToList())
            {
                var quantitySelection = new XElement("QuantitySelection");
                quantitySelection.AddAttribute(CoreConstants.Serialization.Attribute.Name, moleculeSelection.GetAttribute(CoreConstants.Serialization.Attribute.Name));
                quantitySelection.AddAttribute(CoreConstants.Serialization.Attribute.Path, moleculeSelection.GetAttribute(CoreConstants.Serialization.Attribute.Path));

                newSelectedQuantities.Add(quantitySelection);
            }
            element.Add(populationSettings);
        }
        public XElement GetXElement(Disc disc)
        {
            var xml = new XElement(PropertyNames.Disc);

            xml.AddAttribute(PropertyNames.DiscNo, disc.DiscNo);
            xml.AddAttribute(PropertyNames.TrackCount, disc.TrackCount);

            return(xml);
        }
Exemple #6
0
        public static XElement Text(double x, double y, string text, string id = null)
        {
            var textElement = new XElement("text".SvgName(), text);

            textElement.AddAttribute("x", x);
            textElement.AddAttribute("y", y);

            return(textElement);
        }
        public static PackageReferenceXElement New(string name, string versionString)
        {
            var xPackageReference = new XElement(ProjectFileXmlElementName.PackageReference);

            xPackageReference.AddAttribute(ProjectFileXmlElementName.Include, name);
            xPackageReference.AddAttribute(ProjectFileXmlElementName.Version, versionString);

            var packageReferenceXElement = PackageReferenceXElement.From(xPackageReference);

            return(packageReferenceXElement);
        }
Exemple #8
0
        public static XElement Circle(double cx, double cy, double radius, string style, string id = null)
        {
            var circle = new XElement("circle".SvgName());

            circle.AddAttribute("cx", cx);
            circle.AddAttribute("cy", cy);
            circle.AddAttribute("r", radius);
            circle.AddAttribute("style", style);
            circle.SafeAddIdAttribute(id);
            return(circle);
        }
        public XElement GetXElement(Album album)
        {
            var xml = new XElement(PropertyNames.Album);

            xml.AddAttribute(PropertyNames.Title, album.Title);
            xml.AddAttribute(PropertyNames.Year, album.Year);
            xml.AddAttribute(PropertyNames.DiscCount, album.DiscCount);
            xml.AddAttribute(PropertyNames.ReleaseType, album.ReleaseType.ToString());

            return(xml);
        }
Exemple #10
0
        public XElement ToXml()
        {
            var xml = new XElement("Address");

            xml.AddAttribute(nameof(Street), Street);
            xml.AddAttribute(nameof(Number), Number);
            xml.AddAttribute(nameof(City), City);
            xml.AddAttribute(nameof(Country), Country);

            return(xml);
        }
Exemple #11
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);
        }
Exemple #12
0
        public static XElement Line(double x1, double y1, double x2, double y2, string style, string id = null)
        {
            var line = new XElement("line".SvgName());

            line.AddAttribute("x1", x1);
            line.AddAttribute("y1", y1);
            line.AddAttribute("x2", x2);
            line.AddAttribute("y2", y2);
            line.AddAttribute("style", style);
            line.SafeAddIdAttribute(id);
            return(line);
        }
        internal static void ImportIValueSet(this XElement valueSetElement, IValueSet valueSet)
        {
            if (valueSet.StartIndex.HasValue)
            {
                valueSetElement.AddAttribute("startIndex", XmlConvert.ToString(valueSet.StartIndex.Value));
            }

            if (valueSet.EndIndex.HasValue)
            {
                valueSetElement.AddAttribute("endIndex", XmlConvert.ToString(valueSet.EndIndex.Value));
            }
        }
Exemple #14
0
        public XElement GetXElement(ArtistEvent ev)
        {
            var xml = new XElement(PropertyNames.Event);

            xml.AddAttribute(PropertyNames.EventDate, ev.Date.ToString(StandardDateFormat));
            xml.AddAttribute(PropertyNames.EventVenue, ev.Venue);
            xml.AddAttribute(PropertyNames.EventCity, ev.City);
            xml.AddAttribute(PropertyNames.EventCountry, ev.Country);
            xml.AddAttribute(PropertyNames.EventArtistList, ev.ArtistList);

            return(xml);
        }
 public static void AddImageAttribute(this XElement owner, bool imageVisible, string imagePath,
                                      string imageMso)
 {
     if (imageVisible)
     {
         owner.AddAttribute("image", imagePath);
         owner.AddAttribute("imageMso", imageMso);
     }
     else
     {
         owner.AddAttribute("showImage", false);
     }
 }
Exemple #16
0
        internal XElement ToXElement()
        {
            XElement diffElement = new XElement(NamespaceHelper.GetXName("Diff"));

            //// Export all attributes
            diffElement.AddAttribute("scope", this.Scope.GetXmlRepresentation());
            diffElement.AddAttribute("changedItem", this.ChangedItem);

            //// Export the child elements of the current object
            diffElement.Add(new XElement(NamespaceHelper.GetXName("OldValue"), this.OldValue));
            diffElement.Add(new XElement(NamespaceHelper.GetXName("NewValue"), this.NewValue));

            return(diffElement);
        }
        private XElement createSolverParameterElement(string parameterName, string parameterValue)
        {
            var parameterElement = new XElement("Parameter");

            parameterElement.AddAttribute(Constants.Serialization.Attribute.ID, _idGenerator.NewId());
            parameterElement.AddAttribute(Constants.Serialization.Attribute.NAME, parameterName);
            parameterElement.AddAttribute("quantityType", QuantityType.Parameter.ToString());
            parameterElement.AddAttribute(Constants.Serialization.Attribute.VALUE, parameterValue);
            parameterElement.AddAttribute("icon", ApplicationIcons.Parameter.IconName);
            var parameterInfoElement = new XElement("Info");

            parameterInfoElement.AddAttribute("group", _groupRepository.GroupByName(Constants.Groups.SOLVER_SETTINGS).Id);
            parameterElement.Add(parameterInfoElement);
            return(parameterElement);
        }
Exemple #18
0
        protected override void Because()
        {
            var element = new XElement("Individual");

            element.AddAttribute(CoreConstants.Serialization.Attribute.XmlVersion, ProjectVersions.CurrentAsString);
            _result = sut.Deserialize <Individual>(Encoding.UTF8.GetBytes(element.ToString()));
        }
Exemple #19
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);
        }
        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);
        }
Exemple #21
0
 protected void AddGetPressed(XElement element, object condition)
 {
     if (condition != null)
     {
         element.AddAttribute(CallbackNames.getPressed, nameof(IRibbonFluentCallback.GetPressed));
     }
 }
 /// <summary>
 /// Добавить новый атрибут после целевого атрибута
 /// </summary>
 /// <param name="targetElement"></param>
 /// <param name="newAttrName">Имя нового атрибута</param>
 /// <param name="newAttrValue">Значение нового атрибута</param>
 /// <param name="targetAttrName">Имя атрибута, после которого надо добавить атрибут</param>
 /// <returns></returns>
 public static XElement AddAttributeAfterTargetAttribute(this XElement targetElement, XName newAttrName, string newAttrValue, XName targetAttrName)
 {
     if (string.IsNullOrEmpty(newAttrName.ToString()) || newAttrValue == null)
     {
         return(targetElement);
     }
     if (!targetElement.HasAttribute(targetAttrName))
     {
         targetElement.AddAttribute(newAttrName, newAttrValue);
     }
     else
     {
         var attributes         = targetElement.Attributes();
         var newCollectionAttrs = new List <XAttribute>();
         foreach (var attr in attributes)
         {
             newCollectionAttrs.Add(attr);
             if (attr.Name == targetAttrName)
             {
                 newCollectionAttrs.Add(new XAttribute(newAttrName, newAttrValue));
             }
         }
         targetElement.ReplaceAttributes(newCollectionAttrs);
     }
     return(targetElement);
 }
    public static XNode GetOrCreateChild(this XNode node, string childName,
                                         string attribute, string value, bool atFirstPosition)
    {
        XNode childNode = node.FindUnique(childName, attribute, value);

        if (null == childNode)
        {
            XNode      newNode = new XElement(childName);
            XAttribute att     = new XAttribute(attribute, value);
            newNode.AddAttribute(att);
            if (atFirstPosition)
            {
                ((XElement)node).AddFirst(newNode);
            }
            else
            {
                ((XElement)node).Add(newNode);
            }
            return(newNode);
        }
        else
        {
            return(childNode);
        }
    }
Exemple #24
0
 protected void AddGetSelectedItemIndex(XElement element, object condition)
 {
     if (condition != null)
     {
         element.AddAttribute(CallbackNames.getSelectedItemIndex, nameof(IRibbonFluentCallback.GetSelectedItemIndex));
     }
 }
Exemple #25
0
 protected void AddGetItemSupertip(XElement element, object condition)
 {
     if (condition != null)
     {
         element.AddAttribute(CallbackNames.getItemSupertip, nameof(IRibbonFluentCallback.GetItemSuperTip));
     }
 }
Exemple #26
0
 protected void AddOnChange(XElement element, object condition)
 {
     if (condition != null)
     {
         element.AddAttribute(CallbackNames.onChange, nameof(IRibbonFluentCallback.OnChange));
     }
 }
Exemple #27
0
        public static XElement Path(PathBuilder pathBuilder, string id = null)
        {
            var path = new XElement("path".SvgName());

            path.AddAttribute("d", pathBuilder.ToString());
            path.SafeAddIdAttribute(id);
            return(path);
        }
Exemple #28
0
        protected override void Because()
        {
            var element = new XElement("Simulation");

            element.AddAttribute(CoreConstants.Serialization.Attribute.XmlVersion, ProjectVersions.CurrentAsString);
            element.Add(new XElement("FormulaCache"));
            _simulation = sut.Deserialize <Simulation>(Encoding.UTF8.GetBytes(element.ToString()));
        }
        public static XAttribute AddAttribute(this XElement xElement, XName xName, string value)
        {
            var xAttribute = xElement.AddAttribute(xName);

            xAttribute.Value = value;

            return(xAttribute);
        }
Exemple #30
0
        internal XElement ToXElement()
        {
            XElement unitElement = new XElement(NamespaceHelper.GetXName("Unit"));

            //// Export all attributes
            unitElement.AddAttribute("label", this.Label);

            if (this.Quantity != null)
            {
                unitElement.AddAttribute("quantity", this.Quantity);
            }

            //// Export all child elements
            this.SIUnits.ForEach(s => unitElement.Add(s.ToXElement()));

            return(unitElement);
        }