Пример #1
0
        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;
        }
Пример #2
0
 public void SetPredicate(Xml2CSharp.Class x)
 {
     myClass     = x;
     myText.text = x.Label;
     Label       = x.Label;
 }
Пример #3
0
 protected bool Equals(Class other)
 {
     return string.Equals(XmlName, other.XmlName) &&  Fields.Matches(other.Fields);
 }
Пример #4
0
 private static string StripBadCharacters(Class @class)
 {
     return @class.Name.Replace("-", "");
 }
Пример #5
0
 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);
     }
 }