示例#1
0
 public Stereotype GetStereotype(string ID)
 {
     if (Stereotypes.ContainsKey(ID))
     {
         return(Stereotypes[ID] as Stereotype);
     }
     else
     {
         System.Data.DataTable t = GetSqlObject("STEREOTYPE", "stereotype", ID);
         Stereotype            S = new Stereotype(ObjectClass.GetObjectClass(t));
         Stereotypes.Add(ID, S);
         return(S);
     }
 }
示例#2
0
 public Relation(System.Data.DataRow r, Entity _AEntity, Entity _BEntity, DersaSqlManager M)
     : this(ObjectClass.GetObjectClass(r), M)
 {
     if (r != null)
     {
         string a_id = r["a"].ToString();
         string b_id = r["b"].ToString();
         // = new SqlManager();
         if (_AEntity != null)
         {
             this.A = _AEntity;
         }
         else
         {
             if (a_id != "")
             {
                 this.A = new Entity(M.GetEntity(a_id), null, M, AddChildrenMode.Never, false);
             }
         }
         if (_BEntity != null)
         {
             this.B = _BEntity;
         }
         else
         {
             if (b_id != "")
             {
                 //throw new Exception(b_id);
                 if (CachedObjects.CachedEntities[r["b"]] != null)
                 {
                     this.B = (Entity)CachedObjects.CachedEntities[r["b"]];
                 }
                 else
                 {
                     this.B = new Entity(M.GetEntity(b_id), null, M, AddChildrenMode.Always, a_id != b_id);
                 }
             }
         }
         string StereotypeID = r["stereotype"].ToString();
         if (StereotypeID != "")
         {
             this.Stereotype = M.GetStereotype(StereotypeID);
         }
         this.Id = (int)r["relation"];
     }
 }
示例#3
0
        public Entity(System.Data.DataTable t, Entity _Parent, DersaSqlManager M, AddChildrenMode AddChildren, bool AddRelations)
            : this(ObjectClass.GetObjectClass(t), M)
        {
            if (t != null && t.Rows.Count > 0)
            {
                // = new DersaSqlManager();
                System.Data.DataRow r = t.Rows[0];
                if (_Parent != null)
                {
                    this.Parent = _Parent;
                }
                else
                {
                    string ParentID = r["parent"].ToString();
                    if (ParentID != "")
                    {
                        if (CachedObjects.CachedEntities[r["parent"]] != null)
                        {
                            this.Parent = (Entity)CachedObjects.CachedEntities[r["parent"]];
                        }
                        else
                        {
                            this.Parent = new Entity(M.GetEntity(ParentID), null, M, AddChildrenMode.NotPackage, false);
                        }
                    }
                }
                string StereotypeID = r["stereotype"].ToString();
                if (StereotypeID != "")
                {
                    this.Stereotype = M.GetStereotype(StereotypeID);
                }
                this.Id = (int)r["entity"];

                if (AddChildren == AddChildrenMode.Always || (AddChildren == AddChildrenMode.NotPackage && this.Stereotype.Name != "Package"))
                {
                    if (this._children == null)
                    {
                        this._children = new EntityChildrenCollection();
                    }
                    if (this._children.Count < 1)
                    {
                        System.Data.DataTable ChildrenTable = M.GetEntityChildren(this.Id.ToString());
                        if (ChildrenTable.Rows.Count > 0)
                        {
                            foreach (System.Data.DataRow cr in ChildrenTable.Rows)
                            {
                                this._children.Add(new Entity(M.GetEntity(cr["entity"].ToString()), this, M, AddChildrenMode.NotPackage, false));
                            }
                        }
                    }
                }
                if (AddRelations)
                {
                    if (this._aRelations == null)
                    {
                        this._aRelations = new ChildrenCollection();
                    }
                    if (this._aRelations.Count < 1)
                    {
                        System.Data.DataTable ARelationsTable = M.GetEntityARelations(this.Id.ToString());
                        if (ARelationsTable.Rows.Count > 0)
                        {
                            foreach (System.Data.DataRow cr in ARelationsTable.Rows)
                            {
                                this._aRelations.Add(new Relation(cr, this, null, M));
                            }
                        }
                    }
                    if (this._bRelations == null)
                    {
                        this._bRelations = new ChildrenCollection();
                    }
                    if (this._bRelations.Count < 1)
                    {
                        System.Data.DataTable BRelationsTable = M.GetEntityBRelations(this.Id.ToString());
                        if (BRelationsTable.Rows.Count > 0)
                        {
                            foreach (System.Data.DataRow cr in BRelationsTable.Rows)
                            {
                                this._bRelations.Add(new Relation(cr, null, this, M));
                            }
                        }
                    }
                }
            }
            CachedObjects.CachedEntities[this.Id] = this;
        }