/// <summary>
        /// Parse only method. Parses and adds all entities found in the given node and adds them to the given
        /// list.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="sqlTypeElements"></param>
        public static void ParseFromXml(XmlNode node, IList sqlTypeElements)
        {
            if (node != null && sqlTypeElements != null)
            {
                foreach (XmlNode sqlTypeNode in node.ChildNodes)
                {
                    if (sqlTypeNode.NodeType.Equals(XmlNodeType.Element))
                    {
                        SqlTypeElement sqlTypeElement = new SqlTypeElement();

                        sqlTypeElement.Name = GetAttributeValue(sqlTypeNode, NAME, sqlTypeElement.Name);
                        sqlTypeElement.Type = GetAttributeValue(sqlTypeNode, TYPE, sqlTypeElement.Type);
                        sqlTypeElement.ReaderMethodFormat = GetAttributeValue(sqlTypeNode, READER_METHOD_FORMAT, sqlTypeElement.ReaderMethodFormat);
                        sqlTypeElement.DeclarationFormat  = GetAttributeValue(sqlTypeNode, DECLARATION_FORMAT, sqlTypeElement.DeclarationFormat);
                        sqlTypeElement.SqlDbType          = GetAttributeValue(sqlTypeNode, SQL_DB_TYPE, sqlTypeElement.SqlDbType);
                        sqlTypeElement.DbType             = GetAttributeValue(sqlTypeNode, DB_TYPE, sqlTypeElement.DbType);
                        sqlTypeElement.Length             = Int32.Parse(GetAttributeValue(sqlTypeNode, LENGTH, sqlTypeElement.Length.ToString()));
                        sqlTypeElement.Scale     = Int32.Parse(GetAttributeValue(sqlTypeNode, SCALE, sqlTypeElement.Scale.ToString()));
                        sqlTypeElement.Precision = Int32.Parse(GetAttributeValue(sqlTypeNode, PRECISION, sqlTypeElement.Precision.ToString()));

                        sqlTypeElements.Add(sqlTypeElement);
                    }
                }
            }
        }
        public static Hashtable ParseFromXml(XmlDocument doc, ParserValidationDelegate vd)
        {
            Hashtable   sqltypes = new Hashtable();
            XmlNodeList elements = doc.DocumentElement.GetElementsByTagName("sqltype");

            foreach (XmlNode node in elements)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                SqlTypeElement sqltype = new SqlTypeElement();
                sqltype.Name      = node.Attributes["name"].Value;
                sqltype.SqlDbType = sqltype.Name.Substring(0, 1).ToUpper() + sqltype.Name.Substring(1);
                if (node.Attributes["type"] != null)
                {
                    sqltype.Type = node.Attributes["type"].Value;
                }
                if (node.Attributes["length"] != null)
                {
                    sqltype.Length = Int32.Parse(node.Attributes["length"].Value);
                }
                if (node.Attributes["scale"] != null)
                {
                    sqltype.Scale = Int32.Parse(node.Attributes["scale"].Value);
                }
                if (node.Attributes["precision"] != null)
                {
                    sqltype.Precision = Int32.Parse(node.Attributes["precision"].Value);
                }
                if (node.Attributes["readermethodformat"] != null)
                {
                    sqltype.ReaderMethodFormat = node.Attributes["readermethodformat"].Value;
                }
                if (node.Attributes["sqldbtype"] != null)
                {
                    sqltype.SqlDbType = node.Attributes["sqldbtype"].Value;
                }
                if (node.Attributes["dbtype"] != null)
                {
                    sqltype.DbType = node.Attributes["dbtype"].Value;
                }
                if (node.Attributes["declarationformat"] != null)
                {
                    sqltype.DeclarationFormat = node.Attributes["declarationformat"].Value;
                }
                if (sqltypes.ContainsKey(sqltype.Name))
                {
                    vd(ParserValidationArgs.NewWarning("Ignoring duplicate definition of sqltype: " + sqltype.Name));
                }
                else
                {
                    sqltypes.Add(sqltype.Name, sqltype);
                }
            }

            return(sqltypes);
        }
        public override void Validate(RootElement root)
        {
            SqlTypeElement sqlType = root.FindSqlType(this.sqlType.Name);

            if (sqlType == null)
            {
                root.AddValidationMessage(ParserValidationMessage.NewError(String.Format("SqlType ({0}) was not defined [column=({1}.{2})]", this.sqlType.Name, this.sqlEntity, this.Name)));
            }
            else
            {
                this.sqlType = sqlType;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Parse only method. Parses and adds all entities found in the given node and adds them to the given
        /// list.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="entityElements"></param>
        public static void ParseFromXml(XmlNode rootNode)
        {
            if (rootNode != null)
            {
                RootElement rootElement = new RootElement();

//		ConfigElement.ParseFromXml(GetChildNodeByName(rootNode, "config"), rootElement.ConfigElements);
                ReportExtractionElement.ParseFromXml(GetChildNodeByName(rootNode, "reportextractions"), rootElement.ReportExtractions);
                EntityElement.ParseFromXml(GetChildNodeByName(rootNode, "entities"), rootElement.EntityElements);
                CollectionElement.ParseFromXml(GetChildNodeByName(rootNode, "collections"), rootElement.CollectionElements);
                EnumElement.ParseFromXml(GetChildNodeByName(rootNode, "enums"), rootElement.EnumElements);
                TypeElement.ParseFromXml(GetChildNodeByName(rootNode, "types"), rootElement.TypeElements);
                SqlTypeElement.ParseFromXml(GetChildNodeByName(rootNode, "sqltypes"), rootElement.SqlTypeElements);
                DatabaseElement.ParseFromXml(GetChildNodeByName(rootNode, "databases"), rootElement.DatabaseElements);
                GeneratorElement.ParseFromXml(GetChildNodeByName(rootNode, "generator"), rootElement.GeneratorElements);
            }
        }