public SubClassReference(GenDataBase genDataBase, GenObject parent, int classId, GenDataDefSubClass subClassDef)
 {
     GenDataBase = genDataBase;
     Definition  = subClassDef;
     ClassId     = classId;
     Parent      = parent;
 }
Example #2
0
 private void AddInheritedSubClasses(GenDataDefClass parentDef, GenDataBase genDataBase)
 {
     if (parentDef != null && parentDef.IsInherited)
     {
         AddInheritedSubClasses(parentDef.Parent, genDataBase);
         AddSubClasses(parentDef.Parent, genDataBase);
     }
 }
Example #3
0
 private void AddSubClasses(GenDataDefClass parentDef, GenDataBase genDataBase)
 {
     if (parentDef != null)
     {
         foreach (var t in parentDef.SubClasses)
         {
             AddSubClass(t, genDataBase);
         }
     }
 }
Example #4
0
        private void AddSubClass(GenDataDefSubClass subClassDef, GenDataBase genDataBase)
        {
            var subClassClassDef = subClassDef.SubClass;

            if (string.IsNullOrEmpty(subClassDef.ReferenceDefinition))
            {
                Add(new GenSubClass(genDataBase, Parent, subClassClassDef.ClassId, subClassDef));
            }
            else
            {
                Add(new SubClassReference(genDataBase, Parent, subClassClassDef.ClassId, subClassDef));
            }
        }
Example #5
0
        public GenDataBase AsGenDataBase()
        {
            var f = CreateMinimal();
            var d = new GenDataBase(f)
            {
                DataName = DefinitionName
            };
            var a = new GenAttributes(f, 1);

            for (var i = 1; i < Classes.Count; i++)
            {
                if (!string.IsNullOrEmpty(Classes[i].ReferenceDefinition))
                {
                    continue;
                }
                var @class = d.Root.CreateGenObject("Class");
                a.GenObject = @class;
                var c = Classes[i];
                a.SetString("Name", c.Name);
                a.SaveFields();
                foreach (var inheritor in c.Inheritors)
                {
                    a.GenObject = @class.CreateGenObject("SubClass");
                    var inheritorId = inheritor.ClassId;
                    a.SetString("Name", Classes[inheritorId].Name);
                    a.SetString("Relationship", "Extends");
                    a.SaveFields();
                    a.GenObject = ((GenObject)a.GenObject).Parent;
                    a.SetString("Inheritance", "Abstract");
                    a.SaveFields();
                }
                foreach (var subClass in c.SubClasses)
                {
                    a.GenObject = @class.CreateGenObject("SubClass");
                    var sc = subClass.SubClass;
                    a.SetString("Name", sc.Name);
                    a.SetString("Reference", sc.Reference);
                    a.SaveFields();
                }
                foreach (var property in c.InstanceProperties)
                {
                    a.GenObject = @class.CreateGenObject("Property");
                    a.SetString("Name", property);
                    a.SaveFields();
                }
            }
            return(d);
        }
Example #6
0
        public void CheckReference(string dataFile, GenDataBase genData)
        {
            var fn = dataFile.ToLowerInvariant().Replace('\\', '/');

            if (!Cache.ContainsKey(fn))
            {
                Cache.Add(fn, genData);
            }
            foreach (var key in genData.Cache.Keys)
            {
                if (!Cache.ContainsKey(key))
                {
                    Cache.Add(key, genData.Cache[key]);
                }
            }
        }
Example #7
0
        public GenDataToDef(GenDataBase genData)
        {
            GenDataBase = genData;
            GenDataDef  = GenDataBase.GenDataDef;
            _nClass     = GenDataDef.GetClassId("Class");
            var nSubClass = GenDataDef.GetClassId("SubClass");
            var nProperty = GenDataDef.GetClassId("Property");

            _xClassName            = GenDataDef.GetClassProperties(_nClass).IndexOf("Name");
            _xSubClassName         = GenDataDef.GetClassProperties(nSubClass).IndexOf("Name");
            _xSubClassRelationship = GenDataDef.GetClassProperties(nSubClass).IndexOf("Relationship");
            _xSubClassReference    = GenDataDef.GetClassProperties(nSubClass).IndexOf("Reference");
            _xPropertyName         = GenDataDef.GetClassProperties(nProperty).IndexOf("Name");

            if (_nClass == -1 || nSubClass == -1 || nProperty == -1)
            {
                return;
            }

            _xSubClass = GenDataDef.Classes[_nClass].IndexOfSubClass("SubClass");
            _xProperty = GenDataDef.Classes[_nClass].IndexOfSubClass("Property");
        }
Example #8
0
        private GenSubClass GetSubClassByIndex(int subClassId, int idx, GenDataDefClass subClassDef)
        {
            var subClassRef = SubClass[idx] as SubClassReference;

            if (subClassRef != null)
            {
                if (String.IsNullOrEmpty(subClassRef.Reference))
                {
                    return(GenSubClass.Empty);
                }
                var d = GenDataBase.CheckReference(subClassRef.Definition.Reference, subClassRef.Reference);
                foreach (var o in d.Root.SubClass[0])
                {
                    o.RefParent = this;
                }
                return((GenSubClass)d.Root.SubClass[0]);
            }

            var subClass = (GenSubClass)SubClass[idx];

            if (subClass.ClassId == subClassId)
            {
                return(subClass);
            }

            var newSubClass = new GenSubClass(GenDataBase, Parent, subClassId, subClass.Definition);

            foreach (var o in subClass)
            {
                if (subClassDef.IsInheritor(o.ClassId))
                {
                    newSubClass.Add(o);
                }
            }
            return(newSubClass);
        }