Esempio n. 1
0
        public void DataNavigationTest()
        {
            var f = new GenDataDef();

            f.AddSubClass("", "Parent");
            f.AddClassInstanceProperty(f.GetClassId("Parent"), "Name");
            f.AddSubClass("Parent", "Class", "Definition");

            var d = new GenData(f);

            CreateGenObject(d, d.Root, "Parent", "Minimal");
            ((SubClassReference)d.Context[1].GenObject.SubClass[0]).Reference = "Minimal";
            CreateGenObject(d, d.Root, "Parent", "Basic");
            ((SubClassReference)d.Context[1].GenObject.SubClass[0]).Reference = "Basic";
            CreateGenObject(d, d.Root, "Parent", "Definition");
            ((SubClassReference)d.Context[1].GenObject.SubClass[0]).Reference = "Definition";
            //d.Cache.Merge();

            //var minimal = d.Cache["definition", "Minimal"];
            //var basic = d.Cache["definition", "Basic"];
            //var newDefinition = d.Cache["definition", "Definition"];

            var d1 = d.DuplicateContext();

            Navigate(d1, 0);
            Navigate(d1, 0);
        }
Esempio n. 2
0
        private static void ParseDefSubClass(ScanReader reader, GenDataDef f, string className)
        {
            reader.ScanWhile(ScanReader.WhiteSpace);
            var sub = reader.ScanWhile(ScanReader.AlphaNumeric);

            if (reader.CheckChar('['))
            {
                reader.SkipChar();
                reader.ScanWhile(ScanReader.WhiteSpace);
                var field = reader.ScanWhile(ScanReader.Identifier);
                Contract.Assert(field.Equals("Reference", StringComparison.InvariantCultureIgnoreCase), "Data definition reference expected: " + field);
                reader.ScanWhile(ScanReader.WhiteSpace);
                Contract.Assert(reader.CheckChar('='), "Data definition [Reference=definition] expected: " + field);
                reader.SkipChar();
                reader.ScanWhile(ScanReader.WhiteSpace);
                var value = reader.CheckChar('\'')
                                ? reader.ScanQuotedString()
                                : reader.ScanWhile(ScanReader.Identifier);
                f.AddSubClass(className, sub, value);
                reader.ScanWhile(ScanReader.WhiteSpace);
                Contract.Assert(reader.CheckChar(']'), "Data definition ] expected");
                reader.SkipChar();
            }
            else
            {
                f.AddSubClass(className, sub);
            }
            reader.ScanWhile(ScanReader.WhiteSpace);
        }
Esempio n. 3
0
        public static GenDataDef GetDefinition()
        {
            var f = new GenDataDef();

            f.DefinitionName = "GeneratorEditor";
            f.AddSubClass("", "GenSettings");
            f.AddSubClass("GenSettings", "FileGroup");
            f.AddSubClass("GenSettings", "BaseFile");
            f.AddSubClass("BaseFile", "Profile");
            f.Classes[1].AddInstanceProperty("HomeDir");
            f.Classes[2].AddInstanceProperty("Name");
            f.Classes[2].AddInstanceProperty("FileName");
            f.Classes[2].AddInstanceProperty("FilePath");
            f.Classes[2].AddInstanceProperty("BaseFileName");
            f.Classes[2].AddInstanceProperty("Profile");
            f.Classes[2].AddInstanceProperty("GeneratedFile");
            f.Classes[3].AddInstanceProperty("Name");
            f.Classes[3].AddInstanceProperty("FileName");
            f.Classes[3].AddInstanceProperty("FilePath");
            f.Classes[3].AddInstanceProperty("Title");
            f.Classes[3].AddInstanceProperty("FileExtension");
            f.Classes[4].AddInstanceProperty("Name");
            f.Classes[4].AddInstanceProperty("FileName");
            f.Classes[4].AddInstanceProperty("FilePath");
            f.Classes[4].AddInstanceProperty("Title");
            return(f);
        }
Esempio n. 4
0
        public static GenDataDef GetDefinition()
        {
            var f = new GenDataDef();

            f.DefinitionName = "ProfileDefinition";
            f.AddSubClass("", "ProfileRoot");
            f.AddSubClass("ProfileRoot", "FragmentBody");
            f.AddSubClass("FragmentBody", "Fragment");
            f.AddInheritor("Fragment", "Null");
            f.AddInheritor("Fragment", "Text");
            f.AddInheritor("Fragment", "Placeholder");
            f.AddInheritor("Fragment", "ContainerFragment");
            f.AddInheritor("ContainerFragment", "Profile");
            f.AddInheritor("ContainerFragment", "Segment");
            f.AddInheritor("ContainerFragment", "Block");
            f.AddInheritor("ContainerFragment", "Lookup");
            f.AddInheritor("ContainerFragment", "Condition");
            f.AddInheritor("ContainerFragment", "Function");
            f.AddInheritor("ContainerFragment", "TextBlock");
            f.AddInheritor("ContainerFragment", "Annotation");
            f.Classes[1].AddInstanceProperty("Name");
            f.Classes[1].AddInstanceProperty("Title");
            f.Classes[2].AddInstanceProperty("Name");
            f.Classes[3].AddInstanceProperty("Name");
            f.Classes[4].AddInstanceProperty("Name");
            f.Classes[4].AddInstanceProperty("TextValue");
            f.Classes[5].AddInstanceProperty("Name");
            f.Classes[5].AddInstanceProperty("Class");
            f.Classes[5].AddInstanceProperty("Property");
            f.Classes[6].AddInstanceProperty("Name");
            f.Classes[6].AddInstanceProperty("Primary");
            f.Classes[6].AddInstanceProperty("Secondary");
            f.Classes[7].AddInstanceProperty("Name");
            f.Classes[8].AddInstanceProperty("Name");
            f.Classes[8].AddInstanceProperty("Class");
            f.Classes[8].AddInstanceProperty("Cardinality");
            f.Classes[9].AddInstanceProperty("Name");
            f.Classes[10].AddInstanceProperty("Name");
            f.Classes[10].AddInstanceProperty("NoMatch");
            f.Classes[10].AddInstanceProperty("Class1");
            f.Classes[10].AddInstanceProperty("Property1");
            f.Classes[10].AddInstanceProperty("Class2");
            f.Classes[10].AddInstanceProperty("Property2");
            f.Classes[11].AddInstanceProperty("Name");
            f.Classes[11].AddInstanceProperty("Class1");
            f.Classes[11].AddInstanceProperty("Property1");
            f.Classes[11].AddInstanceProperty("Comparison");
            f.Classes[11].AddInstanceProperty("Class2");
            f.Classes[11].AddInstanceProperty("Property2");
            f.Classes[11].AddInstanceProperty("Lit");
            f.Classes[11].AddInstanceProperty("UseLit");
            f.Classes[12].AddInstanceProperty("Name");
            f.Classes[12].AddInstanceProperty("FunctionName");
            f.Classes[13].AddInstanceProperty("Name");
            f.Classes[14].AddInstanceProperty("Name");
            return(f);
        }
Esempio n. 5
0
        protected static GenDataDef SetUpParentChildReferenceDef(string parentClassName, string childClassName,
                                                                 string childDefName, GenDataDef defChild)
        {
            var def = new GenDataDef {
                DefinitionName = parentClassName
            };

            def.Cache.Internal(childDefName, defChild);
            def.AddSubClass("", parentClassName);
            def.AddClassInstanceProperty(1, "Name");
            def.AddSubClass(parentClassName, childClassName, childDefName);
            return(def);
        }
Esempio n. 6
0
        public static GenDataDef GetDefinition()
        {
            var f = new GenDataDef();

            f.DefinitionName = "CodesDefinition";
            f.AddSubClass("", "CodesTable");
            f.AddSubClass("CodesTable", "Code");
            f.Classes[1].AddInstanceProperty("Name");
            f.Classes[1].AddInstanceProperty("Title");
            f.Classes[2].AddInstanceProperty("Name");
            f.Classes[2].AddInstanceProperty("Description");
            f.Classes[2].AddInstanceProperty("Value");
            return(f);
        }
Esempio n. 7
0
        protected static void SetUpChildDef(string parentClassName, string childClassName, GenDataDef def)
        {
            def.AddSubClass(parentClassName, childClassName);
            var childClassId = def.GetClassId(childClassName);

            def.AddClassInstanceProperty(childClassId, "Name");
        }
Esempio n. 8
0
        public static GenDataDef GetDefinition()
        {
            var f = new GenDataDef();

            f.DefinitionName = "Minimal";
            f.AddSubClass("", "Class");
            f.AddSubClass("Class", "SubClass");
            f.AddSubClass("Class", "Property");
            f.Classes[1].AddInstanceProperty("Name");
            f.Classes[1].AddInstanceProperty("Inheritance");
            f.Classes[2].AddInstanceProperty("Name");
            f.Classes[2].AddInstanceProperty("Reference");
            f.Classes[2].AddInstanceProperty("Relationship");
            f.Classes[3].AddInstanceProperty("Name");
            return(f);
        }
Esempio n. 9
0
        protected static GenDataDef SetUpParentChildDef(string parentClassName, string childClassName)
        {
            var def = new GenDataDef {
                DefinitionName = parentClassName
            };

            def.AddSubClass("", parentClassName);
            def.AddClassInstanceProperty(1, "Name");
            SetUpChildDef(parentClassName, childClassName, def);
            return(def);
        }
Esempio n. 10
0
        public static GenDataDef GetDefinition()
        {
            var f = new GenDataDef();

            f.DefinitionName = "Definition";
            f.AddSubClass("", "Class");
            f.AddSubClass("Class", "SubClass");
            f.AddSubClass("Class", "Property");
            f.Classes[1].AddInstanceProperty("Name");
            f.Classes[1].AddInstanceProperty("Title");
            f.Classes[1].AddInstanceProperty("Inheritance");
            f.Classes[2].AddInstanceProperty("Name");
            f.Classes[2].AddInstanceProperty("Reference");
            f.Classes[2].AddInstanceProperty("Relationship");
            f.Classes[3].AddInstanceProperty("Name");
            f.Classes[3].AddInstanceProperty("Title");
            f.Classes[3].AddInstanceProperty("DataType");
            f.Classes[3].AddInstanceProperty("Default");
            f.Classes[3].AddInstanceProperty("LookupType");
            f.Classes[3].AddInstanceProperty("LookupDependence");
            f.Classes[3].AddInstanceProperty("LookupTable");
            return(f);
        }
Esempio n. 11
0
        public static GenDataDef GetDefinition()
        {
            var f = new GenDataDef();

            f.DefinitionName = "DatabaseDefinition";
            f.AddSubClass("", "Database");
            f.AddSubClass("Database", "Schema");
            f.AddSubClass("Schema", "Object");
            f.AddInheritor("Object", "Table");
            f.AddInheritor("Object", "View");
            f.AddInheritor("Object", "Procedure");
            f.AddInheritor("Object", "Function");
            f.AddSubClass("Object", "Column");
            f.AddSubClass("Object", "Index");
            f.AddSubClass("Object", "ForeignKey");
            f.AddSubClass("Object", "Parameter");
            f.AddSubClass("Column", "Default");
            f.AddSubClass("Index", "KeyColumn");
            f.AddSubClass("Index", "DataColumn");
            f.AddSubClass("ForeignKey", "ForeignKeyColumn");
            f.Classes[1].AddInstanceProperty("Name");
            f.Classes[2].AddInstanceProperty("Name");
            f.Classes[2].AddInstanceProperty("SchemaName");
            f.Classes[3].AddInstanceProperty("Name");
            f.Classes[4].AddInstanceProperty("Name");
            f.Classes[4].AddInstanceProperty("TableName");
            f.Classes[5].AddInstanceProperty("Name");
            f.Classes[5].AddInstanceProperty("ViewName");
            f.Classes[6].AddInstanceProperty("Name");
            f.Classes[6].AddInstanceProperty("ProcedureName");
            f.Classes[7].AddInstanceProperty("Name");
            f.Classes[7].AddInstanceProperty("FunctionName");
            f.Classes[8].AddInstanceProperty("Name");
            f.Classes[8].AddInstanceProperty("ColumnName");
            f.Classes[8].AddInstanceProperty("NativeDataType");
            f.Classes[8].AddInstanceProperty("ODBCDataType");
            f.Classes[8].AddInstanceProperty("Length");
            f.Classes[8].AddInstanceProperty("Precision");
            f.Classes[8].AddInstanceProperty("Scale");
            f.Classes[8].AddInstanceProperty("IsNullable");
            f.Classes[8].AddInstanceProperty("IsKey");
            f.Classes[8].AddInstanceProperty("IsIdentity");
            f.Classes[9].AddInstanceProperty("Name");
            f.Classes[9].AddInstanceProperty("Value");
            f.Classes[10].AddInstanceProperty("Name");
            f.Classes[10].AddInstanceProperty("IsPrimaryKey");
            f.Classes[10].AddInstanceProperty("IsUnique");
            f.Classes[10].AddInstanceProperty("IsClusterKey");
            f.Classes[11].AddInstanceProperty("Name");
            f.Classes[11].AddInstanceProperty("Order");
            f.Classes[12].AddInstanceProperty("Name");
            f.Classes[13].AddInstanceProperty("Name");
            f.Classes[13].AddInstanceProperty("ReferenceSchema");
            f.Classes[13].AddInstanceProperty("ReferenceTable");
            f.Classes[13].AddInstanceProperty("DeleteAction");
            f.Classes[13].AddInstanceProperty("UpdateAction");
            f.Classes[14].AddInstanceProperty("Name");
            f.Classes[14].AddInstanceProperty("RelatedColumn");
            f.Classes[15].AddInstanceProperty("Name");
            f.Classes[15].AddInstanceProperty("ParameterName");
            f.Classes[15].AddInstanceProperty("NativeDataType");
            f.Classes[15].AddInstanceProperty("ODBCDataType");
            f.Classes[15].AddInstanceProperty("Length");
            f.Classes[15].AddInstanceProperty("Precision");
            f.Classes[15].AddInstanceProperty("Scale");
            f.Classes[15].AddInstanceProperty("IsNullable");
            f.Classes[15].AddInstanceProperty("Direction");
            return(f);
        }
Esempio n. 12
0
        public void ConsecutiveDataLoadTest()
        {
            var f = new GenDataDef();

            f.AddSubClass("", "Parent");
            f.AddClassInstanceProperty(f.GetClassId("Parent"), "Name");
            f.AddSubClass("Parent", "Class", "Definition");

            var d       = new GenData(f);
            var minimal = LoadGenData("Minimal");

            minimal.Last(1);
            Assert.AreEqual("Property", minimal.Context[1].GenObject.Attributes[0]);
            Assert.AreEqual(1, minimal.Context[3].Count);
            var basic = LoadGenData("Basic");

            basic.Last(1);
            Assert.AreEqual("Property", basic.Context[1].GenObject.Attributes[0]);
            Assert.AreEqual(2, basic.Context[3].Count);
            var definition = LoadGenData("Definition");

            definition.Last(1);
            Assert.AreEqual("Property", definition.Context[1].GenObject.Attributes[0]);
            Assert.AreEqual(7, definition.Context[3].Count);
            Assert.AreSame(minimal, d.Cache.Internal("definition", "Minimal", minimal));
            Assert.AreSame(basic, d.Cache.Internal("definition", "Basic", basic));
            var newDefinition = d.Cache.Internal("definition", "Definition", definition);

            Assert.AreNotSame(definition, newDefinition);
            Assert.AreSame(minimal, d.Cache.Internal("definition", "Minimal", minimal));
            Assert.AreSame(basic, d.Cache.Internal("definition", "Basic", basic));
            Assert.AreSame(newDefinition, d.Cache.Internal("definition", "Definition", definition));
            Assert.AreSame(minimal, d.Cache["Minimal"]);
            Assert.AreSame(basic, d.Cache["Basic"]);
            Assert.AreSame(newDefinition, d.Cache["Definition"]);
            d.Cache.Merge();

            CreateGenObject(d, d.Root, "Parent", "Minimal");
            ((SubClassReference)d.Context[1].GenObject.SubClass[0]).Reference = "Minimal";
            CreateGenObject(d, d.Root, "Parent", "Basic");
            ((SubClassReference)d.Context[1].GenObject.SubClass[0]).Reference = "Basic";
            CreateGenObject(d, d.Root, "Parent", "Definition");
            ((SubClassReference)d.Context[1].GenObject.SubClass[0]).Reference = "Definition";

            d.First(1);
            Assert.AreEqual("Minimal", d.Context[2].Reference);
            Assert.AreSame(minimal.GenDataBase, d.Context[2].GenObject.GenDataBase);
            d.Last(2);
            Assert.AreEqual("Property", d.Context[2].GenObject.Attributes[0]);
            Assert.AreEqual(1, d.Context[4].Count);
            d.Next(1);
            Assert.AreEqual("Basic", d.Context[2].Reference);
            Assert.AreSame(basic.GenDataBase, d.Context[2].GenObject.GenDataBase);
            d.Last(2);
            Assert.AreEqual("Property", d.Context[2].GenObject.Attributes[0]);
            Assert.AreEqual(2, d.Context[4].Count);
            d.Next(1);
            Assert.AreEqual("Definition", d.Context[2].Reference);
            Assert.AreSame(newDefinition.GenDataBase, d.Context[2].GenObject.GenDataBase);
            d.Last(2);
            Assert.AreEqual("Property", d.Context[2].GenObject.Attributes[0]);
            Assert.AreEqual(7, d.Context[4].Count);
            d.First(0);
        }
Esempio n. 13
0
        private static GenDataDef ExtractDef(ScanReader reader)
        {
            var f         = new GenDataDef();
            var classId   = -1;
            var className = "";
            var token     = reader.ScanWhile(ScanReader.Identifier);

            while (token != "")
            {
                switch (token)
                {
                case "Definition":
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    if (reader.CheckChar('='))
                    {
                        reader.SkipChar();
                    }
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    f.DefinitionName = reader.ScanWhile(ScanReader.QualifiedIdentifier);
                    break;

                case "Class":
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    if (reader.CheckChar('='))
                    {
                        reader.SkipChar();
                    }
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    className = reader.ScanWhile(ScanReader.Identifier);
                    classId   = f.AddClass(className);
                    if (f.Classes.Count == 2)
                    {
                        f.AddSubClass("", className);
                    }
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    if (reader.CheckChar('['))
                    {
                        do
                        {
                            reader.SkipChar();
                            reader.ScanWhile(ScanReader.WhiteSpace);
                            var inheritorClassName = reader.ScanWhile(ScanReader.Identifier);
                            f.AddInheritor(className, inheritorClassName);
                            reader.ScanWhile(ScanReader.WhiteSpace);
                        } while (reader.CheckChar(','));
                        Contract.Assert(reader.CheckChar(']'), "Definition Error for class " + className + ": ] expected");
                        reader.SkipChar();
                    }
                    break;

                case "Field":
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    if (reader.CheckChar('='))
                    {
                        reader.SkipChar();
                    }
                    if (reader.CheckChar('{'))
                    {
                        do
                        {
                            reader.SkipChar();
                            reader.ScanWhile(ScanReader.WhiteSpace);
                            var field = reader.ScanWhile(ScanReader.Identifier);
                            f.AddClassInstanceProperty(classId, field);
                            reader.ScanWhile(ScanReader.WhiteSpace);
                        } while (reader.CheckChar(','));
                        Contract.Assert(reader.CheckChar('}'), "Definition Error for class " + className + " fields list: } expected");
                        reader.SkipChar();
                    }
                    else
                    {
                        reader.ScanWhile(ScanReader.WhiteSpace);
                        var field = reader.ScanWhile(ScanReader.Identifier);
                        f.AddClassInstanceProperty(classId, field);
                    }
                    break;

                case "SubClass":
                    reader.ScanWhile(ScanReader.WhiteSpace);
                    if (reader.CheckChar('='))
                    {
                        reader.SkipChar();
                    }
                    if (reader.CheckChar('{'))
                    {
                        while (!reader.CheckChar('}'))
                        {
                            reader.SkipChar();
                            ParseDefSubClass(reader, f, className);
                        }
                        reader.SkipChar();
                    }
                    else
                    {
                        ParseDefSubClass(reader, f, className);
                        reader.ScanWhile(ScanReader.WhiteSpace);
                    }
                    break;
                }
                reader.ScanWhile(ScanReader.WhiteSpace);
                token = reader.ScanWhile(ScanReader.Identifier);
            }
            return(f);
        }