Represents a database object and its build script. This class tracks the build state of its database object and presents other build items that are referenced by or from this one.
Esempio n. 1
0
        private ICollection <BuildItem> CreateItems(IDictionary <ScriptFile, ISet <DatabaseObject> > scriptDependencies, ISet <DatabaseObject> existingObjects)
        {
            var buildItems = new Dictionary <DatabaseObject, BuildItem>(scriptDependencies.Count, new DatabaseObjectComparer());
            var buildItemToDependencies = new Dictionary <BuildItem, List <BuildItem> >(scriptDependencies.Count);
            var buildItemToReferencers  = new Dictionary <BuildItem, List <BuildItem> >(scriptDependencies.Count);

            foreach (var s in scriptDependencies)
            {
                var  dependencies = new List <BuildItem>();
                var  referencers  = new List <BuildItem>();
                bool objectExists = existingObjects.Contains(s.Key.ScriptObject);
                var  bi           = new BuildItem(s.Key, dependencies, referencers, objectExists);
                buildItemToDependencies.Add(bi, dependencies);
                buildItemToReferencers.Add(bi, referencers);
                buildItems.Add(bi.DatabaseObject, bi);
            }

            foreach (var item in buildItems)
            {
                var itemDependencies = scriptDependencies[item.Value.Script].Select(x => buildItems[x]);
                buildItemToDependencies[item.Value].AddRange(itemDependencies);
                var itemReferencers = buildItems.Values.Where(x => scriptDependencies[x.Script].Contains(item.Key));
                buildItemToReferencers[item.Value].AddRange(itemReferencers);
            }

            foreach (var item in buildItems.Values)
            {
                if (item.Status == BuildItem.BuildStatusType.ScriptError)
                {
                    DependencyError.SetDependencyErrorStatus(item.Referencers, Enumerable.Repeat(item, 1));
                }

                if (item.BuildAction == BuildItem.BuildActionType.DropAndCreate)
                {
                    SetDropCreateBuildAction(item.Referencers);
                }
            }

            return(buildItems.Values);
        }
        private IEnumerable<BuildItem> CreateItems(IDictionary<ScriptFile, ISet<DatabaseObject>> scriptDependencies, ISet<DatabaseObject> existingObjects)
        {
            var buildItems = new Dictionary<DatabaseObject, BuildItem>(scriptDependencies.Count, new DatabaseObjectComparer());
            var buildItemToDependencies = new Dictionary<BuildItem, List<BuildItem>>(scriptDependencies.Count);
            var buildItemToReferencers = new Dictionary<BuildItem, List<BuildItem>>(scriptDependencies.Count);
            foreach (var s in scriptDependencies)
            {
                var dependencies = new List<BuildItem>();
                var referencers = new List<BuildItem>();
                bool objectExists = existingObjects.Contains(s.Key.ScriptObject);
                var bi = new BuildItem(s.Key, dependencies, referencers, objectExists);
                buildItemToDependencies.Add(bi, dependencies);
                buildItemToReferencers.Add(bi, referencers);
                buildItems.Add(bi.DatabaseObject, bi);
            }

            foreach (var item in buildItems)
            {
                var itemDependencies = scriptDependencies[item.Value.Script].Select(x => buildItems[x]);
                buildItemToDependencies[item.Value].AddRange(itemDependencies);
                var itemReferencers = buildItems.Values.Where(x => scriptDependencies[x.Script].Contains(item.Key));
                buildItemToReferencers[item.Value].AddRange(itemReferencers);
            }

            foreach(var item in buildItems.Values)
            {
                if(item.Status == BuildItem.BuildStatusType.ScriptError)
                {
                    DependencyError.SetDependencyErrorStatus(item.Referencers, Enumerable.Repeat(item, 1));
                }

                if(item.BuildAction == BuildItem.BuildActionType.DropAndCreate)
                {
                    SetDropCreateBuildAction(item.Referencers);
                }
            }

            return buildItems.Values;
        }