private void AddToXml(Feature feature, XElement element)
        {
            if (feature.Value != null) {
                element.Value = feature.Value;
            }

            foreach (var style in feature.GetStyles())
            {
                XAttribute tmp = new XAttribute(style.Name, style.Value);
                element.Add(tmp);
            }

            IEnumerable<Feature> subElements = feature.GetChildFeatures();

            foreach (var subElement in subElements)
            {
                XElement tmp = new XElement(subElement.Name);
                element.Add(tmp);
                AddToXml(subElement, tmp);
            }
        }
        private void AddSpecificStyle(Feature feature)
        {
            String path = document.GetNodePath(feature);
            IEnumerable<StyleInfo> styleConstraints = configFacade.GetStylesPartial(path);

            List<Style> specificStyles = new List<Style>();

            foreach (var item in styleConstraints)
            {
                specificStyles.Add(StyleFactory.CreateStyle(item, defaults));
            }

            foreach (var style in specificStyles)
            {
                feature.AddStyle(style, true); //Should we check style compatibility here
            }

            foreach (var subFeature in feature.GetChildFeatures())
            {
                AddSpecificStyle(subFeature);
            }
        }
 private void CalculateLeafNodes(Feature node, List<Feature> leaves)
 {
     if (IsLeaf(node))
     {
         leaves.Add(node);
         return;
     }
     else {
         foreach (var childNode in node.GetChildFeatures())
         {
             CalculateLeafNodes(childNode, leaves);
         }
     }
 }
        private void AddStyle(Feature feature)
        {
            IEnumerable<StyleInfo> stylesConstraints = randomizer.GetRandomStyleSubset(feature.Name);

            float styleAddingProb = Config.Default.StyleAddProb;

            float randomVal = (float) randomNumber.NextDouble();

            //Only add styles to fraction of features
            if (randomVal < styleAddingProb)
            {
                List<Style> possibleStyles = new List<Style>();

                foreach (var item in stylesConstraints)
                {
                    possibleStyles.Add(StyleFactory.CreateStyle(item, defaults));
                }

                foreach (var style in possibleStyles)
                {
                    feature.AddStyle(style);
                }
            }

            foreach (var subFeature in feature.GetChildFeatures())
            {
                AddStyle(subFeature);
            }
        }