Ejemplo n.º 1
0
        public void RegistDb(ConnectionType conn)
        {
            #region remove all exsited types

            var deletingTypes = new List <string>();

            foreach (var key in this.workEngine.Types.Keys)
            {
                if (key.StartsWith("db." + conn.Name + "."))
                {
                    deletingTypes.Add(key);
                }
            }

            foreach (var key in deletingTypes)
            {
                this.workEngine.Types.Remove(key);
            }
            #endregion

            //var tables = conn.Tables;
            //for(var i = 0 ; i < tables.
            foreach (TableType table in conn.Tables)
            {
                var type = new TypeInfoBase();
                type.Name     = table.Name;
                type.FullName = "db." + conn.Name + "." + type.Name;

                string error = null;

                foreach (var field in table.ColumnSet.Columns)
                {
                    var property = new PropertyInfoBase();
                    if (!string.IsNullOrWhiteSpace(field.Description))
                    {
                        var attr = new AttributeInfo();
                        attr.Name = "Comments";
                        attr.Parameters.Add(field.Description);

                        property.Attributes.Add(attr);
                    }

                    property.Name    = field.Name;
                    property.Nullabe = field.AllowDBNull;
                    property.Type    = field.SystemType;
                    var types = this.ParseType(field.SystemType, null, out error);
                    if (types != null && types.Count == 1)
                    {
                        property.TypeInfo = types[0];
                    }

                    type.PropertyInfos.Add(property);
                }
                this.workEngine.Types.Add(type.FullName, type);
            }
        }
Ejemplo n.º 2
0
            private void InitSystemTypes()
            {
                var t     = new TypeInfoBase();
                var t_net = typeof(int);

                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("int", t);
                this.Types.Add("Int32", t);
                this.Types.Add("System.Int32", t);

                t             = new TypeInfoBase();
                t_net         = typeof(float);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("float", t);
                this.Types.Add("Float", t);
                this.Types.Add("System.Float", t);

                t             = new TypeInfoBase();
                t_net         = typeof(Double);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("double", t);
                this.Types.Add("Double", t);
                this.Types.Add("System.Double", t);

                t             = new TypeInfoBase();
                t_net         = typeof(Decimal);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("decimal", t);
                this.Types.Add("Decimal", t);
                this.Types.Add("System.Decimal", t);

                t             = new TypeInfoBase();
                t_net         = typeof(DateTime);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("DateTime", t);
                this.Types.Add("System.DateTime", t);

                t             = new TypeInfoBase();
                t_net         = typeof(char);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("char", t);
                this.Types.Add("Char", t);
                this.Types.Add("System.Char", t);

                t             = new TypeInfoBase();
                t_net         = typeof(string);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("string", t);
                this.Types.Add("String", t);
                this.Types.Add("System.String", t);

                t             = new TypeInfoBase();
                t_net         = typeof(bool);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("bool", t);
                this.Types.Add("Boolean", t);
                this.Types.Add("System.Boolean", t);

                t             = new TypeInfoBase();
                t_net         = typeof(Guid);
                t.FullName    = t_net.FullName;
                t.IsPrimitive = t_net.IsPrimitive;

                this.Types.Add("guid", t);
                this.Types.Add("Guid", t);
                this.Types.Add("System.Guid", t);
            }