private static Class ElementToClass(XElement xElement, ICollection<Class> classes)
        {
            var @class = new Class
            {
                Name = xElement.Name.LocalName,
                XmlName = xElement.Name.LocalName,
                Fields =  ReplaceDuplicatesWithLists(ExtractFields(xElement, classes)).ToList(),
                Namespace = xElement.Name.NamespaceName
            };

            SafeName(@class, @classes);

            if (xElement.Parent == null || ([email protected](@class) && @class.Fields.Any()))
                @classes.Add(@class);

            return @class;
        }
Beispiel #2
0
 public void SetPredicate(Xml2CSharp.Class x)
 {
     myClass     = x;
     myText.text = x.Label;
     Label       = x.Label;
 }
Beispiel #3
0
 protected bool Equals(Class other)
 {
     return string.Equals(XmlName, other.XmlName) &&  Fields.Matches(other.Fields);
 }
 private static string StripBadCharacters(Class @class)
 {
     return @class.Name.Replace("-", "");
 }
 private static void SafeName(Class @class, IEnumerable<Class> classes)
 {
     var count = classes.Count(c => c.XmlName == @class.Name);
     if (count > 0 && [email protected](@class))
     {
         @class.Name = StripBadCharacters(@class) + (count + 1);
     }
     else
     {
         @class.Name = StripBadCharacters(@class);
     }
 }