示例#1
0
 public bool RemoveVpackage(VPackage vpackage)
 {
     if (vpackage != null)
     {
         throw new ArgumentException();
     }
     return(Vpackages.Remove(vpackage));
 }
示例#2
0
 public void AddVpackage(VPackage vpackage)
 {
     if (vpackage != null)
     {
         throw new ArgumentException();
     }
     Vpackages.Add(vpackage);
 }
示例#3
0
        // Add dependencies of the given VPackage in the JSON object
        private void AddDependency(VPackage vPackage, string ParentId)
        {
            string id          = "0";
            string newParentId = ParentId;

            foreach (string framework in vPackage.Dependencies.Keys)
            {
                id = _graph["nodes"].Count.ToString();
                //Add the framework to the graph
                if (vPackage.Dependencies[framework].Count() != 0 && framework != "Unsupported,Version=v0.0")
                {
                    _graph["nodes"].Add(VPackageToDictionary(framework, id, "platform", vPackage.Version.ToString(), null));
                    _graph["links"].Add(CreateLink(ParentId, id));
                    newParentId = id;
                }

                // Adding of all the package in the framework. Ignore present package
                foreach (VPackage newVPackage in vPackage.Dependencies[framework])
                {
                    id = _graph["nodes"].Count.ToString();
                    bool   found   = false;
                    string idFound = "0";

                    // Search if the package is already in the graph
                    foreach (Dictionary <string, string> node in _graph["nodes"])
                    {
                        string version = newVPackage.Version.Major + "." + newVPackage.Version.Minor + "." + newVPackage.Version.Revision;
                        if (node["name"] == newVPackage.PackageId && node["version"] == version)
                        {
                            found   = true;
                            idFound = node["id"];
                        }
                    }

                    if (!found)
                    {
                        string version = newVPackage.Version.Major + "." + newVPackage.Version.Minor + "." + newVPackage.Version.Revision;
                        _graph["nodes"].Add(VPackageToDictionary(newVPackage.PackageId, id, null, version, newVPackage.LastVersion));
                        _graph["links"].Add(CreateLink(newParentId, id));
                        AddDependency(newVPackage, id);
                    }
                    else
                    {
                        _graph["links"].Add(CreateLink(newParentId, idFound));
                    }
                }
            }
        }
示例#4
0
        // Convert the given VPackage in a JSON object with all the informations needed
        public Dictionary <string, object> ConvertGraphData(VPackage vPackage)
        {
            _graph = new Dictionary <string, List <Dictionary <string, string> > >();
            _graph.Add("nodes", new List <Dictionary <string, string> >());
            _graph.Add("links", new List <Dictionary <string, string> >());

            _info = new Dictionary <string, object>();
            _info.Add("graph", _graph);
            _info.Add("versionConflict", new List <Dictionary <string, object> >());
            _info.Add("toUpdate", new List <Dictionary <string, string> >());

            string version = vPackage.Version.Major + "." + vPackage.Version.Minor + "." + vPackage.Version.Revision;

            _graph["nodes"].Add(VPackageToDictionary(vPackage.PackageId, _graph["nodes"].Count.ToString(), "source", version, vPackage.LastVersion));
            AddDependency(vPackage, "0");

            // Add the warnings on nodes withs version conflict
            foreach (Dictionary <string, string> currentNode in _graph["nodes"])
            {
                foreach (Dictionary <string, string> otherNode in _graph["nodes"])
                {
                    if (currentNode["name"] == otherNode["name"] &&
                        currentNode["id"] != otherNode["id"] &&
                        currentNode.ContainsKey("version") &&
                        currentNode["version"] != otherNode["version"])
                    {
                        if ((currentNode.ContainsKey("entity") && currentNode["entity"] != "platform") || !currentNode.ContainsKey("entity"))
                        {
                            if (!currentNode.Keys.Contains("warning") && !otherNode.Keys.Contains("warning"))
                            {
                                currentNode.Add("warning", "versionConflict");
                                otherNode.Add("warning", "versionConflict");
                            }
                            else
                            {
                                currentNode["warning"] = "versionConflict";
                                otherNode["warning"]   = "versionConflict";
                            }

                            foreach (Dictionary <string, string> link in _graph["links"])
                            {
                                if ((currentNode["id"] == link["target"] || otherNode["id"] == link["target"]) && (!HasConflictAsParent(currentNode["id"]) || !HasConflictAsParent(otherNode["id"])))
                                {
                                    if (link.ContainsKey("warning"))
                                    {
                                        link["warning"] = "versionConflict";
                                    }
                                    else
                                    {
                                        link.Add("warning", "versionConflict");
                                    }
                                }
                            }

                            // Adding all version conflicts in the list of issues
                            List <Dictionary <string, object> > versionConflicts = (List <Dictionary <string, object> >)_info["versionConflict"];
                            bool contains = false;
                            foreach (Dictionary <string, object> conflict in versionConflicts)
                            {
                                if ((string)conflict["name"] == currentNode["name"])
                                {
                                    contains = true;
                                }
                            }
                            if (!contains)
                            {
                                versionConflicts.Add(new Dictionary <string, object>());
                                versionConflicts[versionConflicts.Count - 1].Add("name", currentNode["name"]);
                                versionConflicts[versionConflicts.Count - 1].Add("origine", new Dictionary <string, List <string> >());
                                if (!((Dictionary <string, List <string> >)versionConflicts[versionConflicts.Count - 1]["origine"]).ContainsKey(currentNode["version"]))
                                {
                                    ((Dictionary <string, List <string> >)versionConflicts[versionConflicts.Count - 1]["origine"]).Add(currentNode["version"], getDirectParents(currentNode["id"], false));
                                }
                                if (!((Dictionary <string, List <string> >)versionConflicts[versionConflicts.Count - 1]["origine"]).ContainsKey(otherNode["version"]))
                                {
                                    ((Dictionary <string, List <string> >)versionConflicts[versionConflicts.Count - 1]["origine"]).Add(otherNode["version"], getDirectParents(otherNode["id"], false));
                                }
                            }
                        }
                    }
                }
            }
            return(_info);
        }
示例#5
0
 public Dependencies(VPackage vpackage)
     : this(vpackage, null)
 {
 }
示例#6
0
 public Dependencies(VPackage vpackage, Dictionary <Framework, IEnumerable <VPackage> > dicDependencies)
 {
     Vpackage        = vpackage;
     DicDependencies = dicDependencies;
 }