/// <summary>
        /// Compares the order of XmlClassEntitites based on how far nested they are in the file system.
        /// Generally to make sure the base classes and their directories are always generated before the inheriting classes.
        /// </summary>
        public static int CompareByDirectoryLength(XmlClassEntity dir1, XmlClassEntity dir2)
        {
            if (dir1 == null)
            {
                if (dir2 == null)
                {
                    return(0);   //Well, shit
                }
                else
                {
                    return(-1);  //Counter productive
                }
            }
            else
            {
                if (dir2 == null)
                {
                    return(1);   //Finally some progress
                }
                else
                {
                    int retval = dir1.Directory.Length.CompareTo(dir2.Directory.Length);

                    if (retval != 0)
                    {
                        return(retval);
                    }
                    else
                    {
                        return(dir1.Directory.CompareTo(dir2.Directory));
                    }
                }
            }
        }
        public void CalculateDirectory()
        {
            XmlClassEntity parent = ParentClass;

            while (parent != null)
            {
                Directory = (parent.Name.Substring(1, parent.Name.Length - 1)) + @"\" + Directory;

                parent = parent.ParentClass;
            }
        }
        private List <XmlClassEntity> ParseNode(XElement element, List <XmlClassEntity> entities, XmlClassEntity parent)
        {
            XmlClassEntity currentEntity = MakeEntityFromElement(element);

            currentEntity.ParentClass = parent;

            entities.Add(currentEntity);

            if (element.Elements().Count() > 0 && element != null)
            {
                //Only loop classes here.
                foreach (XElement node in element.Elements().Where(x => x.Name == "class"))
                {
                    entities = ParseNode(node, entities, currentEntity);
                }
            }
            return(entities);
        }
Example #4
0
 public ClassGeneratorClassFile(XmlClassEntity xmlClass, string outputDirectory)
 {
     XmlClass        = xmlClass;
     OutputDirectory = outputDirectory;
 }