private static bool DepInList(DependencyItem dep, List <ISpecificObjectStructure> objs)
 {
     foreach (var obj in objs)
     {
         if (obj.ObjectType == dep.ObjectType && obj.ObjectName == dep.Name)
         {
             return(true);
         }
     }
     return(false);
 }
        public static DependencyItem[] GetDependsOnSelected(this IDatabaseStructure db, DependencyItem selected, bool processReferences)
        {
            var res = new List <DependencyItem>();

            if (selected != null)
            {
                foreach (var spec in db.GetAllSpecificObjects())
                {
                    if (spec.DependsOn != null && spec.DependsOn.Contains(selected))
                    {
                        res.Add(new DependencyItem
                        {
                            Name       = spec.ObjectName,
                            ObjectType = spec.ObjectType,
                        });
                    }
                }
                if (processReferences && selected.ObjectType == "table")
                {
                    var tbl = db.FindTable(selected.Name);
                    if (tbl != null)
                    {
                        foreach (var fk in tbl.GetReferencedFrom())
                        {
                            res.Add(new DependencyItem
                            {
                                Name       = fk.Table.FullName,
                                ObjectType = "table",
                            });
                        }
                    }
                }
            }
            return(res.ToArray());
        }
Esempio n. 3
0
 public bool Match(DependencyItem obj)
 {
     return(Components.Count >= 1 && String.Compare(Components[Components.Count - 1], obj.Name.Name, true) == 0);
 }
        public static DependencyItem[] GetSelectedDependsOn(this IDatabaseStructure db, DependencyItem selected, bool processReferences)
        {
            var res = new List <DependencyItem>();

            if (selected != null)
            {
                var obj = db.FindSpecificObject(selected.ObjectType, selected.Name);
                if (obj != null && obj.DependsOn != null)
                {
                    res.AddRange(obj.DependsOn);
                }
                if (processReferences && selected.ObjectType == "table")
                {
                    var tbl = db.FindTable(selected.Name);
                    if (tbl != null)
                    {
                        foreach (var fk in tbl.GetConstraints <IForeignKey>())
                        {
                            res.Add(new DependencyItem
                            {
                                Name       = fk.PrimaryKeyTable,
                                ObjectType = "table",
                            });
                        }
                    }
                }
            }
            return(res.ToArray());
        }
Esempio n. 5
0
 public DependencyItem(DependencyItem src)
 {
     Name       = src.Name;
     ObjectType = src.ObjectType;
 }