Пример #1
0
        public GenDataDef AsDef()
        {
            var f = new GenDataDef {
                DefinitionName = GenDataBase.DataName
            };

            Navigate(GenDataBase.Root, f);

            return(f);
        }
Пример #2
0
 private GenDataBase(GenDataDef genDataDef, Dictionary <string, GenDataBase> cache)
 {
     Cache      = cache ?? new Dictionary <string, GenDataBase>();
     GenDataDef = genDataDef;
     IgnorePropertyValidation = true;
     Root = new GenObject(null, null, 0)
     {
         GenDataBase = this
     };
 }
Пример #3
0
        public GenSubClass GetSubClass(string subClassName)
        {
            if (ClassNameIs(subClassName))
            {
                var subClass = new GenSubClass(GenDataBase, Parent, ClassId, ParentSubClass.Definition);
                subClass.Add(this);
                return(subClass);
            }
            var subClassId = GenDataDef.GetClassId(subClassName);

            return(subClassId == -1 ? null : GetSubClass(subClassId));
        }
Пример #4
0
        /// <summary>
        /// Cache a data file programatically.
        /// </summary>
        /// <param name="name">The name of the cached data.</param>
        /// <param name="genDataDef">The data being cached.</param>
        /// <returns></returns>
        public void Internal(string name, GenDataDef genDataDef)
        {
            var n = name.ToLowerInvariant().Replace('/', '\\');

            if (n.Equals("self"))
            {
                throw new ArgumentException("The 'self' generator data cannot be added explicitly to the cache", "name");
            }
            if (!LocalCache.ContainsKey(n))
            {
                LocalCache.Add(n, genDataDef);
            }
        }
Пример #5
0
 private static void PopulateMinimal(GenDataDef def)
 {
     def.DefinitionName = "Minimal";
     def.AddClass("", "Class");
     def.AddClass("Class", "SubClass");
     def.AddClass("Class", "Property");
     def.AddClassInstanceProperty(def.GetClassId("Class"), "Name");
     def.AddClassInstanceProperty(def.GetClassId("Class"), "Inheritance");
     def.AddClassInstanceProperty(def.GetClassId("SubClass"), "Name");
     def.AddClassInstanceProperty(def.GetClassId("SubClass"), "Reference");
     def.AddClassInstanceProperty(def.GetClassId("SubClass"), "Relationship");
     def.AddClassInstanceProperty(def.GetClassId("Property"), "Name");
 }
Пример #6
0
 public GenAttributes(GenDataDef genDataDef, int classId) : this()
 {
     ClassId = classId;
     foreach (var c in genDataDef.Classes)
     {
         Classes.Add(c.Name);
     }
     foreach (var property in genDataDef.GetClassProperties(ClassId))
     {
         Properties.Add(property);
     }
     foreach (var sc in genDataDef.GetClassSubClasses(ClassId))
     {
         SubClasses.Add(sc.SubClass.Name);
     }
 }
Пример #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");
        }
Пример #8
0
 public GenDataDefReferenceCache(GenDataDef genData)
 {
     Self = genData;
 }
Пример #9
0
 public GenDataDefReferenceCacheItem(string path, GenDataDef genDataDef) : this()
 {
     GenDataDef = genDataDef;
     Path       = path;
 }
Пример #10
0
 private int GetClassId(string className)
 {
     return(GenDataDef.GetClassId(className));
 }
Пример #11
0
        private void Navigate(GenObject c, GenDataDef f)
        {
            if (c.ClassId != _nClass)
            {
                foreach (var sc in c.SubClass)
                {
                    foreach (var s in sc)
                    {
                        Navigate(s, f);
                    }
                }
            }
            else
            {
                var sc = c.ParentSubClass;
                foreach (var pc in sc)
                {
                    var className = pc.Attributes[_xClassName];
                    if (!f.Classes.Contains(className))
                    {
                        if (f.Classes.Count <= 1)
                        {
                            f.AddSubClass("", className);
                        }
                        else
                        {
                            f.AddClass(className);
                        }
                    }
                }

                foreach (var pc in sc)
                {
                    var className = pc.Attributes[_xClassName];
                    for (var j = 0; j < pc.SubClass[_xSubClass].Count; j++)
                    {
                        var subClassName = pc.SubClass[_xSubClass][j].Attributes[_xSubClassName];
                        var relationship = _xSubClassRelationship != -1
                            ? pc.SubClass[_xSubClass][j].Attributes[_xSubClassRelationship]
                            : "";
                        var reference = _xSubClassReference != -1
                            ? pc.SubClass[_xSubClass][j].Attributes[_xSubClassReference]
                            : "";
                        if (relationship.Equals("Extends", StringComparison.InvariantCultureIgnoreCase))
                        {
                            f.AddInheritor(className, subClassName);
                        }
                        else
                        {
                            f.AddSubClass(className, subClassName, reference);
                        }
                    }
                }

                foreach (var pc in sc)
                {
                    var className = pc.Attributes[_xClassName];
                    var iClass    = f.GetClassId(className);
                    var @class    = f.GetClassDef(iClass);
                    for (var j = 0; j < pc.SubClass[_xProperty].Count; j++)
                    {
                        var name = pc.SubClass[_xProperty][j].Attributes[_xPropertyName];
                        if ([email protected] || [email protected](name))
                        {
                            @class.AddInstanceProperty(name);
                            @class.Properties.Add(name);
                        }
                    }
                }
            }
        }
Пример #12
0
 public GenDataBase(GenDataDef genDataDef) : this(genDataDef, null)
 {
 }