Exemplo n.º 1
0
 public LoadedAssembly Open(string assemblyUri, bool isAutoLoaded = false)
 {
     if (assemblyUri.StartsWith("nupkg://", StringComparison.OrdinalIgnoreCase))
     {
         string fileName      = assemblyUri.Substring("nupkg://".Length);
         int    separator     = fileName.LastIndexOf(';');
         string componentName = null;
         if (separator > -1)
         {
             componentName = fileName.Substring(separator + 1);
             fileName      = fileName.Substring(0, separator);
             LoadedNugetPackage package = new LoadedNugetPackage(fileName);
             var entry = package.Entries.FirstOrDefault(e => e.Name == componentName);
             if (entry != null)
             {
                 return(OpenAssembly(assemblyUri, entry.Stream, true));
             }
         }
         return(null);
     }
     else
     {
         return(OpenAssembly(assemblyUri, isAutoLoaded));
     }
 }
 public NugetPackageBrowserDialog(LoadedNugetPackage package)
 {
     InitializeComponent();
     this.Package = package;
     this.Package.PropertyChanged += Package_PropertyChanged;
     DataContext = this;
 }
        public NugetPackageBrowserDialog(LoadedNugetPackage package)
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            this.Package = package;
            this.Package.PropertyChanged += Package_PropertyChanged;
            DataContext = this;
        }
Exemplo n.º 4
0
        void LoadAssemblies(IEnumerable <string> fileNames, List <LoadedAssembly> loadedAssemblies = null, bool focusNode = true)
        {
            SharpTreeNode lastNode = null;

            foreach (string file in fileNames)
            {
                switch (Path.GetExtension(file))
                {
                case ".nupkg":
                    LoadedNugetPackage package = new LoadedNugetPackage(file);
                    var selectionDialog        = new NugetPackageBrowserDialog(package);
                    selectionDialog.Owner = this;
                    if (selectionDialog.ShowDialog() != true)
                    {
                        break;
                    }
                    foreach (var entry in selectionDialog.SelectedItems)
                    {
                        var nugetAsm = assemblyList.OpenAssembly("nupkg://" + file + ";" + entry.Name, entry.Stream, true);
                        if (nugetAsm != null)
                        {
                            if (loadedAssemblies != null)
                            {
                                loadedAssemblies.Add(nugetAsm);
                            }
                            else
                            {
                                var node = assemblyListTreeNode.FindAssemblyNode(nugetAsm);
                                if (node != null && focusNode)
                                {
                                    treeView.SelectedItems.Add(node);
                                    lastNode = node;
                                }
                            }
                        }
                    }
                    break;

                default:
                    var asm = assemblyList.OpenAssembly(file);
                    if (asm != null)
                    {
                        if (loadedAssemblies != null)
                        {
                            loadedAssemblies.Add(asm);
                        }
                        else
                        {
                            var node = assemblyListTreeNode.FindAssemblyNode(asm);
                            if (node != null && focusNode)
                            {
                                treeView.SelectedItems.Add(node);
                                lastNode = node;
                            }
                        }
                    }
                    break;
                }

                if (lastNode != null && focusNode)
                {
                    treeView.FocusNode(lastNode);
                }
            }
        }