Ejemplo n.º 1
0
            public static ComponentTree WithChildren(ComponentTree tree, IImmutableList <ComponentTree> children)
            {
                tree._children = children;

                foreach (var child in children)
                {
                    child._parent = tree;
                }

                return(tree);
            }
Ejemplo n.º 2
0
        public void AttachTo(ComponentTree componentTree)
        {
            _attachedComponentTree = componentTree;

            foreach (var component in componentTree.Components)
            {
                component.Invalidate();
                component.Metadata.ViewportChanged += OnViewportChanged;
            }

            componentTree.ComponentAdded   += OnComponentAdded;
            componentTree.ComponentRemoved += OnComponentRemoved;
        }
Ejemplo n.º 3
0
        private static async Task <ComponentTree> GetTreeAt(DirectoryInfo directory, ProjectSettings settings)
        {
            var components = new List <IComponent>();

            var tree = new ComponentTree(directory);

            foreach (var componentType in ComponentTypes)
            {
                components.AddRange(await componentType.FindAt(tree, settings));
            }

            return(ComponentTree.WithComponents(tree, components.ToImmutableList()));
        }
Ejemplo n.º 4
0
        private static async Task <ComponentTree> BuildTreeFrom(
            ProjectSettings settings,
            string path,
            IgnoreList ignoreList)
        {
            var directory = new DirectoryInfo(settings.GetRootedPath(path));

            var componentTree = await GetTreeAt(directory, settings);

            var children = (await directory
                            .GetDirectories()
                            .Where(x => !ignoreList.IsIgnored(new DirectoryInfo(settings.GetRelativePath(x.FullName))))
                            .Select(childDirectory => BuildTreeFrom(settings, childDirectory.FullName, ignoreList))
                            .WhenAll())
                           .ToImmutableList();

            return(ComponentTree.WithChildren(componentTree, children));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns artifact info for packages in a packages.config that match the given set of properties.
        /// </summary>
        /// <param name="configPath">Path to packages.config</param>
        /// <param name="properties">Property values to filter on</param>
        /// <returns>Artifacts matching the property filters.</returns>
        public static IEnumerable <NuGetArtifactInfo> GetArtifactInfo(string configPath, IEnumerable <string> propertyKeys)
        {
            if (configPath == null)
            {
                throw new ArgumentNullException("configPath");
            }

            if (propertyKeys == null)
            {
                throw new ArgumentNullException("propertyKeys");
            }

            FileInfo file = new FileInfo(configPath);

            if (!file.Exists)
            {
                throw new FileNotFoundException(configPath);
            }

            List <NuGetArtifactInfo> results = new List <NuGetArtifactInfo>();

            using (FileStream stream = file.OpenRead())
            {
                ConfigReader configReader = new ConfigReader(stream);

                foreach (PackageIdentity package in configReader.GetPackages())
                {
                    // TODO: find the real path
                    string   packageName = package.Id + "." + package.Version.ToString();
                    FileInfo nupkgPath   = new FileInfo(Path.Combine(file.Directory.Parent.FullName, "packages", packageName, packageName + ".nupkg"));

                    if (!nupkgPath.Exists)
                    {
                        throw new FileNotFoundException(nupkgPath.FullName);
                    }

                    NuGetPackageId id = new NuGetPackageId(package.Id, package.Version, nupkgPath.Directory.FullName);

                    ZipFileSystem zip = new ZipFileSystem(nupkgPath.OpenRead());

                    using (PackageReader packageReader = new PackageReader(zip))
                    {
                        ComponentTree tree = null;

                        // TODO: add a better check for this
                        if (packageReader.GetPackedManifest() == null)
                        {
                            using (LegacyPackageReader legacyReader = new LegacyPackageReader(zip))
                            {
                                throw new NotImplementedException();
                                //var packed = PackedManifestCreator.FromLegacy(legacyReader);
                                //tree = packed.ComponentTree;
                            }
                        }
                        else
                        {
                            tree = packageReader.GetComponentTree();
                        }

                        List <NuGetArtifactGroup> groups = new List <NuGetArtifactGroup>();

                        // TODO: use propertyKeys
                        // TODO: get full paths
                        foreach (var path in tree.GetPaths())
                        {
                            var props = path.Properties.Select(p => (KeyValueTreeProperty)p).Select(p => new KeyValuePair <string, string>(p.Key, p.Value));
                            var items = path.Items.Select(i => (NuGetTreeItem)i).Select(i => new NuGetArtifact(i.Type, i.Data.Where(p => p.Key == "path").Select(p => p.Value).Single()));

                            groups.Add(new NuGetArtifactGroup(props, items));
                        }

                        NuGetArtifactInfo info = new NuGetArtifactInfo(id, groups.ToArray());
                        results.Add(info);
                    }
                }
            }

            return(results);
        }
Ejemplo n.º 6
0
        private void Tree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode CurrentNode = e.Node;

            string sqlFliter = string.Empty;

            if (e.Node.Name.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                sqlFliter = " 1=1 ";
            }
            else
            {
                if (e.Node.Nodes.Count > 0)
                {
                    return;
                }

                string sCondition = CurrentNode.Name;

                string[] arrCondition = null;
                if (sCondition.Contains(","))
                {
                    arrCondition = sCondition.Split(',');
                }
                else
                {
                    arrCondition = new string[] { sCondition }
                };

                string[] arrValue = new string[arrCondition.Length];
                for (int i = 0; i < arrCondition.Length; i++)
                {
                    string sValue = CurrentNode.Text;
                    arrValue[arrCondition.Length - 1 - i] = sValue;

                    if (CurrentNode.Parent != null)
                    {
                        CurrentNode = CurrentNode.Parent;
                    }
                }

                sqlFliter = GetWhereString(arrCondition, arrValue);

                string GetWhereString(string[] ArrKey, string[] ArrValues)
                {
                    List <string> listwhere = new List <string>();

                    for (int i = 0; i < ArrKey.Length; i++)
                    {
                        listwhere.Add($"{ArrKey[i]}='{ArrValues[i]}'");
                    }
                    return(string.Join(" and ", listwhere));
                }
            }

            ComponentTree Tree = CurrentNode.TreeView as ComponentTree;

            DataTable dt = Tree.DataGrid.DataSource as DataTable;

            string Sql = dt.Namespace;

            int iindex = Sql.LastIndexOf("where", StringComparison.OrdinalIgnoreCase);

            if (iindex < 0)
            {
                Sql = Sql + "\r\n where " + sqlFliter;
            }
            else
            {
                Sql = Sql.Substring(0, iindex).TrimEnd() + "\r\n where " + sqlFliter;
            }
            dt.Namespace = Sql;

            RefreshClick(Tree.DataGrid.ToolBar, null);
        }
Ejemplo n.º 7
0
 public void BindingTreeNodeOnClick(ComponentTree Tree)
 {
     Tree.AfterSelect += Tree_AfterSelect;
 }
Ejemplo n.º 8
0
            public static ComponentTree WithComponents(ComponentTree tree, IImmutableList <IComponent> components)
            {
                tree._components = tree._components.AddRange(components);

                return(tree);
            }