public Foo() { _numbers = new List<int>(); string s = _numbers[10].ToString(10); string s2 = _numbers.GetEnumerator().Current.ToString(10); string s3 = _numbers.Reduce<int>(delegate(int accumulated, int item) { return accumulated + item; }, 0).ToString(10); string s4 = _func(10).EncodeUriComponent(); Func<int, string> f2 = _func; f2(11).Trim(); Dictionary<string, int> d = new Dictionary<string, int>(); string s5 = jQuery.ExtendDictionary<string, int>(d, d)["abc"].ToString(10); int keys = d.Count; bool b = d.ContainsKey("abc"); d.Remove("abc"); foreach (KeyValuePair<string, int> de in d) { } jQuery.AjaxRequest<string>("http://example.com").Success(delegate(string html) { Window.Alert(html); }); string json = ""; Foo f = Json.ParseData<Foo>(json).Setup().Run().Cleanup(); string name = Document.GetElementById("nameTB").As<InputElement>().Value; }
public bool AreAllStringsLongerThan5(List<string> input) { return input.Reduce( true, (acc, str) => (str.Length >= 5) && acc); }
protected bool? AskRemoveDependency( IPackage package, IList<IPackageRepository> localRepositories, IList<FrameworkName> targetFrameworks) { Debug.Assert(localRepositories.Count == targetFrameworks.Count); var allOperations = new List<PackageOperation>(); for (int i = 0; i < localRepositories.Count; i++) { var uninstallWalker = new UninstallWalker( localRepositories[i], new DependentsWalker(localRepositories[i], targetFrameworks[i]), targetFrameworks[i], logger: NullLogger.Instance, removeDependencies: true, forceRemove: false) { ThrowOnConflicts = false }; var operations = uninstallWalker.ResolveOperations(package); allOperations.AddRange(operations); } allOperations = allOperations.Reduce().ToList(); var uninstallPackageNames = (from o in allOperations where o.Action == PackageAction.Uninstall && !PackageEqualityComparer.IdAndVersion.Equals(o.Package, package) select o.Package) .Distinct(PackageEqualityComparer.IdAndVersion) .Select(p => p.ToString()) .ToList(); bool? removeDependencies = false; if (uninstallPackageNames.Count > 0) { // show each dependency package on one line String packageNames = String.Join(Environment.NewLine, uninstallPackageNames); String message = String.Format(CultureInfo.CurrentCulture, Resources.Dialog_RemoveDependencyMessage, package) + Environment.NewLine + Environment.NewLine + packageNames; removeDependencies = _userNotifierServices.ShowRemoveDependenciesWindow(message); } return removeDependencies; }
protected bool CheckPSScriptAndShowLicenseAgreement( PackageItem item, IList<Project> projects, IVsPackageManager packageManager, out IList<PackageOperation> operations) { ShowProgressWindow(); // combine the operations of all selected project var allOperations = new List<PackageOperation>(); foreach (Project project in projects) { IProjectManager projectManager = packageManager.GetProjectManager(project); IList<PackageOperation> projectOperations; CheckInstallPSScripts( item.PackageIdentity, projectManager.LocalRepository, packageManager.SourceRepository, project.GetTargetFrameworkName(), IncludePrerelease, out projectOperations); allOperations.AddRange(projectOperations); } // reduce the operations before checking for license agreements operations = allOperations.Reduce(); return ShowLicenseAgreement(packageManager, operations); }
protected bool ShowLicenseAgreement( IPackage package, IVsPackageManager packageManager, IEnumerable<Project> projects, out IList<PackageOperation> operations) { var allOperations = new List<PackageOperation>(); foreach (Project project in projects) { var walker = new InstallWalker( packageManager.GetProjectManager(project).LocalRepository, packageManager.SourceRepository, project.GetTargetFrameworkName(), this, ignoreDependencies: false, allowPrereleaseVersions: IncludePrerelease, dependencyVersion: packageManager.DependencyVersion); allOperations.AddRange(walker.ResolveOperations(package)); } operations = allOperations.Reduce(); return ShowLicenseAgreement(packageManager, operations); }
protected bool ShowLicenseAgreementForAllPackages(IVsPackageManager activePackageManager, out List<PackageOperation> allOperations) { allOperations = new List<PackageOperation>(); var installWalker = new InstallWalker( LocalRepository, activePackageManager.SourceRepository, _project.GetTargetFrameworkName(), logger: this, ignoreDependencies: false, allowPrereleaseVersions: IncludePrerelease); var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease); foreach (var package in allPackages) { if (allOperations.FindIndex( operation => operation.Action == PackageAction.Install && operation.Package.Id == package.Id && operation.Package.Version == package.Version) == -1) { var operations = installWalker.ResolveOperations(package); allOperations.AddRange(operations); } } allOperations = (List<PackageOperation>)allOperations.Reduce(); return ShowLicenseAgreement(activePackageManager, allOperations); }
protected bool? AskRemoveDependencyAndCheckUninstallPSScript( IPackage package, IList<IPackageRepository> localRepositories, IList<FrameworkName> targetFrameworks) { Debug.Assert(localRepositories.Count == targetFrameworks.Count); var allOperations = new List<PackageOperation>(); for (int i = 0; i < localRepositories.Count; i++) { var uninstallWalker = new UninstallWalker( localRepositories[i], new DependentsWalker(localRepositories[i], targetFrameworks[i]), targetFrameworks[i], logger: NullLogger.Instance, removeDependencies: true, forceRemove: false) { ThrowOnConflicts = false }; var operations = uninstallWalker.ResolveOperations(package); allOperations.AddRange(operations); } allOperations = allOperations.Reduce().ToList(); var uninstallPackageNames = (from o in allOperations where o.Action == PackageAction.Uninstall && !PackageEqualityComparer.IdAndVersion.Equals(o.Package, package) select o.Package) .Distinct(PackageEqualityComparer.IdAndVersion) .Select(p => p.ToString()) .ToList(); bool? removeDependencies = false; if (uninstallPackageNames.Count > 0) { // show each dependency package on one line String packageNames = String.Join(Environment.NewLine, uninstallPackageNames); String message = String.Format(CultureInfo.CurrentCulture, Resources.Dialog_RemoveDependencyMessage, package) + Environment.NewLine + Environment.NewLine + packageNames; removeDependencies = _userNotifierServices.ShowRemoveDependenciesWindow(message); } if (removeDependencies == null) { return removeDependencies; } bool hasScriptPackages; if (removeDependencies == true) { // if user wants to remove dependencies, we need to check all of them for PS scripts var scriptPackages = from o in allOperations where o.Package.HasPowerShellScript() select o.Package; hasScriptPackages = scriptPackages.Any(); } else { // otherwise, just check the to-be-uninstalled package hasScriptPackages = package.HasPowerShellScript(new string[] { PowerShellScripts.Uninstall }); } if (hasScriptPackages) { if (!RegistryHelper.CheckIfPowerShell2Installed()) { throw new InvalidOperationException(Resources.Dialog_PackageHasPSScript); } } return removeDependencies; }
private bool InstallPackageIntoProjects(IList<Project> allProjects, HashSet<string> selectedProjectsSet, IPackage package) { var allOperations = new List<PackageOperation>(); foreach (Project project in allProjects) { if (selectedProjectsSet.Contains(project.UniqueName)) { IList<PackageOperation> operations; CheckInstallPSScripts( package, PackageManager.GetProjectManager(project).LocalRepository, PackageManager.SourceRepository, targetFramework: project.GetTargetFrameworkName(), includePrerelease: true, operations: out operations); allOperations.AddRange(operations); } } bool accepted = ShowLicenseAgreement(PackageManager, allOperations.Reduce()); if (!accepted) { return false; } // now install the packages that are checked // Bug 1357: It's crucial that we perform all installs before uninstalls // to avoid the package file being deleted before an install. foreach (Project project in allProjects) { if (selectedProjectsSet.Contains(project.UniqueName)) { try { // if the project is checked, install package into it InstallPackageToProject(project, package, includePrerelease: true); } catch (Exception ex) { AddFailedProject(project, ex); } } } return true; }
protected bool ShowLicenseAgreementForAllPackages(IVsPackageManager activePackageManager) { var allOperations = new List<PackageOperation>(); var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease).ToList(); foreach (var package in allPackages) { var installWalker = new InstallWalker( LocalRepository, activePackageManager.SourceRepository, _project.GetTargetFrameworkName(), logger: this, ignoreDependencies: false, allowPrereleaseVersions: IncludePrerelease); var operations = installWalker.ResolveOperations(package); allOperations.AddRange(operations); } return ShowLicenseAgreement(activePackageManager, allOperations.Reduce()); }
//implementar aquí métodos de ejercicios 1, 2 y 3 public void ej1(int formato) { List<int> duraciones = new List<int>(canciones.Filter(x => x.FormatoID == formato).Select(x => x.Duracion)); int media = duraciones.Reduce((x,y) => x + y) / canciones.Filter(x => x.FormatoID == formato).Count(); Console.WriteLine(duraciones.Map(x => (x-media)*(x-media)).Sum()); }