public static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoViewModel, Package l)
        {
            var vm = new PublishPackageViewModel(dynamoViewModel)
            {
                Group       = l.Group,
                Description = l.Description,
                Keywords    = l.Keywords != null?String.Join(" ", l.Keywords) : "",
                                  CustomNodeDefinitions =
                                      l.LoadedCustomNodes.Select(
                                          x => dynamoViewModel.Model.CustomNodeManager.GetFunctionDefinition(x.Guid))
                                      .ToList(),
                                  Name    = l.Name,
                                  Package = l
            };

            // add additional files
            l.EnumerateAdditionalFiles();
            foreach (var file in l.AdditionalFiles)
            {
                vm.AdditionalFiles.Add(file.Model.FullName);
            }

            // load assemblies into reflection only context
            foreach (var file in l.EnumerateAssemblyFiles())
            {
                Assembly assem;
                var      result = PackageLoader.TryReflectionOnlyLoadFrom(file, out assem);
                if (result)
                {
                    vm.Assemblies.Add(assem);
                }
                else
                {
                    // if it's not a .NET assembly, we load it as an additional file
                    vm.AdditionalFiles.Add(file);
                }
            }

            if (l.VersionName == null)
            {
                return(vm);
            }

            var parts = l.VersionName.Split('.');

            if (parts.Count() != 3)
            {
                return(vm);
            }

            vm.MajorVersion = parts[0];
            vm.MinorVersion = parts[1];
            vm.BuildVersion = parts[2];
            return(vm);
        }
Beispiel #2
0
        public static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoViewModel, Package l)
        {
            var vm = new PublishPackageViewModel(dynamoViewModel)
            {
                Group       = l.Group,
                Description = l.Description,
                Keywords    = l.Keywords != null?String.Join(" ", l.Keywords) : "",
                                  CustomNodeDefinitions =
                                      l.LoadedCustomNodes.Select(
                                          x => dynamoViewModel.Model.CustomNodeManager.GetFunctionDefinition(x.Guid))
                                      .ToList(),
                                  Assemblies = l.LoadedAssemblies.ToList(),
                                  Name       = l.Name,
                                  Package    = l
            };

            // add additional files
            l.EnumerateAdditionalFiles();
            foreach (var file in l.AdditionalFiles)
            {
                vm.AdditionalFiles.Add(file.Model.FullName);
            }

            // add unloaded assemblies, that are not yet loaded
            var unloadedAssemblies =
                l.EnumerateAssemblyFiles()
                .Where(x => !l.LoadedAssemblies.Select(a => a.Location).Contains(x));

            foreach (var file in unloadedAssemblies)
            {
                vm.Assemblies.Add(Assembly.ReflectionOnlyLoadFrom(file));
            }

            if (l.VersionName == null)
            {
                return(vm);
            }

            var parts = l.VersionName.Split('.');

            if (parts.Count() != 3)
            {
                return(vm);
            }

            vm.MajorVersion = parts[0];
            vm.MinorVersion = parts[1];
            vm.BuildVersion = parts[2];
            return(vm);
        }
        public static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoViewModel, Package l)
        {
            var vm = new PublishPackageViewModel(dynamoViewModel)
            {
                Group = l.Group,
                Description = l.Description,
                Keywords = l.Keywords != null ? String.Join(" ", l.Keywords) : "",
                CustomNodeDefinitions =
                    l.LoadedCustomNodes.Select(
                        x => dynamoViewModel.Model.CustomNodeManager.GetFunctionDefinition(x.Guid))
                        .ToList(),
                Name = l.Name,
                Package = l
            };

            // add additional files
            l.EnumerateAdditionalFiles();
            foreach ( var file in l.AdditionalFiles)
            {
                vm.AdditionalFiles.Add(file.Model.FullName);
            }

            // load assemblies into reflection only context
            foreach (var file in l.EnumerateAssemblyFiles())
            {
                Assembly assem;
                var result = PackageLoader.TryReflectionOnlyLoadFrom(file, out assem);
                if (result)
                {
                    vm.Assemblies.Add(assem);
                }
                else
                {
                    // if it's not a .NET assembly, we load it as an additional file
                    vm.AdditionalFiles.Add(file);
                }
            }

            if (l.VersionName == null) return vm;

            var parts = l.VersionName.Split('.');
            if (parts.Count() != 3) return vm;

            vm.MajorVersion = parts[0];
            vm.MinorVersion = parts[1];
            vm.BuildVersion = parts[2];
            return vm;

        }