public void MapPackagesToLibraryInfo_Unique_Should_Return_One_Result() { AddUniquePackageOption(); PackageList list = new PackageList(); list.Add("log4net", new Package { Metadata = new Metadata { Id = "log4net", License = new License { Text = "MIT", Type = "Open" }, Version = "2.0.8", }, }); list.Add("log4net2", new Package { Metadata = new Metadata { Id = "log4net", License = new License { Text = "MIT", Type = "Open" }, Version = "2.0.8", } }); var packages = new Dictionary <string, PackageList> (); packages.Add("packages", list); var info = _methods.MapPackagesToLibraryInfo(packages); info.Count.Should().Equals(1); }
public Data(ProjectList projectList, PackageList packageList) { this.projects = new Project[projectList.Count]; projectList.Values.CopyTo(this.projects, 0); this.packages = new Package[packageList.Count]; packageList.Values.CopyTo(this.packages, 0); }
private static List <IPackage> GetDependencies(PackageList packages, IPackage pack, bool recursive = true, bool unique = false) { List <IPackage> deps = new List <IPackage> (); foreach (Dependency dep in pack.Dependencies) { IPackage deppack = FindPackage(packages, dep); if (deppack == null) { throw new InvalidDependencyException("Could not find dependency '" + dep.Name + "'", pack, null); } if (IsCircularDependency(dep, deppack)) { throw new InvalidDependencyException("Circular dependency detected.", pack, deppack); } if (recursive) { deps.AddRange(GetDependencies(packages, deppack, recursive, unique)); } if (!unique || (unique && !deps.Contains(deppack))) { deps.Add(deppack); } } return(deps); }
internal static void RegisterLoadedAction(this PackageList self, Action action) { Action <IPage> act = _ => action(); PageManagerInstance.onListRebuild -= act; PageManagerInstance.onListRebuild += act; }
public void Setup(VisualElement root) { packageList = root.Q <PackageList>(); packageDetails = root.Q <PackageDetails>(); Debug.Log(kHeader, $"[Setup] {packageList}, {packageDetails},"); #if UNITY_2019_3_OR_NEWER packageList.onPackageListLoaded -= UpdateGitPackageVersions; packageList.onPackageListLoaded += UpdateGitPackageVersions; // PackageDatabase.instance.onPackagesChanged += (added, removed, _, updated) => // { // // Removed or updated. // if (removed.Concat(updated).Any(x => x?.installedVersion?.packageInfo?.source == PackageSource.Git)) // { // EditorApplication.delayCall += UpdatePackageCollection; // } // // Installed with git // if (added.Concat(updated).Any(x => x?.installedVersion?.packageInfo?.source == PackageSource.Git)) // { // EditorApplication.delayCall += UpdateGitPackages; // } // }; #else packageList.OnLoaded -= UpdateGitPackageVersions; packageList.OnLoaded += UpdateGitPackageVersions; #endif AvailableVersions.OnChanged += UpdateGitPackageVersions; UpdateGitPackageVersions(); UpdateAvailableVersionsForGitPackages(); }
public void PackageListUniqueInstanceTest() { PackageList plA = PackageList.Instance(); PackageList plB = PackageList.Instance(); Assert.AreSame(plA, plB); }
private Dictionary <string, ProviderShipRateQuote> GetAllServiceQuotes(Warehouse origin, CommerceBuilder.Users.Address destination, BasketItemCollection contents) { string cacheKey = StringHelper.CalculateMD5Hash(Misc.GetClassId(this.GetType()) + "_" + origin.WarehouseId.ToString() + "_" + destination.AddressId.ToString() + "_" + contents.GenerateContentHash()); HttpContext context = HttpContext.Current; if ((context != null) && (context.Items.Contains(cacheKey))) { return((Dictionary <string, ProviderShipRateQuote>)context.Items[cacheKey]); } //VERIFY WE HAVE A DESTINATION COUNTRY if (string.IsNullOrEmpty(destination.CountryCode)) { return(null); } PackageList plist = PreparePackages(origin, destination, contents); if (plist == null || plist.Count == 0) { return(null); } Dictionary <string, ProviderShipRateQuote> allQuotes; allQuotes = GetProviderQuotes(origin, destination, plist); if (context != null) { context.Items.Add(cacheKey, allQuotes); } return(allQuotes); }
public void TestFindAllPackagesWithMultipleVersionsAndListLatestVersion() { var dnsList = new PackageList(directoryNames); //foreach(var g in dnsList) //{ // Console.WriteLine(g.Key); // foreach(var v in g) // { // Console.WriteLine("{0} {1} {2} {3}", // v.PackageName, v.Version, v.Language??"", v.Chip??""); // } //} Console.WriteLine($"Count: {dnsList.FullList.Count()}"); Console.WriteLine($"Keep Count: {dnsList.LatestVersions.Count()}"); Console.WriteLine($"Delete Count: {dnsList.OldVersions.Count()}"); foreach (var d in dnsList.OldVersions) { Console.WriteLine(d.ParentPath + d.PackageName + " " + d.Version + " " + d.Chip); } }
public IPackage GetPackage(string pkgname) { // only read needed package, not all (if not already done) if (this.packages != null) { IPackage pkg = this.packages.FindByName(pkgname); if (pkg != null || this.allpackagesread) { return(pkg); } } DirectoryInfo pkgdir = new DirectoryInfo(Path.Combine(this.PackageDir.FullName, pkgname)); if (!pkgdir.Exists) { return(null); } IPackage newpkg = this.ReadPackageDir(pkgdir); if (newpkg == null) { return(null); } if (this.packages == null) { this.packages = new PackageList(); } this.packages.Add(newpkg); return(newpkg); }
/// <summary> /// Display all packages available /// </summary> private void ShowPackages() { lbTitle.Text = "Packages list"; using (PackageList p = Package.GetAll()) { p.Sort("Sort"); #region No result if (p.Count == 0) { mainMsgLbl.Text = "No package found"; mainMsgLbl.Visible = true; UITools.HideToolBarButton(mainToolBar, "Delete"); UITools.HideToolBarSeparator(mainToolBar, "SepDelete"); packagesGrid.Visible = false; } #endregion #region Results else { packagesGrid.DataSource = p; mainMsgLbl.Visible = false; packagesGrid.Bands[0].ColHeadersVisible = Infragistics.WebUI.UltraWebGrid.ShowMarginInfo.Yes; packagesGrid.DataBind(); packagesGrid.Visible = true; EnableIntelligentSortForPackages(ref packagesGrid, Convert.ToInt32(txtSortColPos.Value)); packagesGrid.DisplayLayout.AllowSortingDefault = AllowSorting.No; UITools.ShowToolBarButton(mainToolBar, "Delete"); UITools.ShowToolBarSeparator(mainToolBar, "SepDelete"); } #endregion } }
public static void SelectVersions(PackageList packages) { Dictionary <string, List <PackageVersion> > neededversions = new Dictionary <string, List <PackageVersion> >(); foreach (IPackage pack in packages) { foreach (Dependency dep in pack.Dependencies) { if (!neededversions.ContainsKey(dep.PackageName)) { neededversions.Add(dep.PackageName, new List <PackageVersion>()); } neededversions[dep.PackageName].Add(dep.Version); } } foreach (string pkgname in neededversions.Keys) { IPackage pkg = packages[pkgname]; try { PackageVersion pkgversion = GetHighestMatchingVersion(pkg.Versions, neededversions[pkgname]); pkg.SelectedVersion = pkgversion; } catch (InvalidDependencyException ex) { throw new InvalidDependencyException("No Version of Package " + pkg.Name + " found which satisfies all Dependencies.", ex, pkg); } } }
public static void EnableFeatures(PackageList packages, bool includeoptional = false) { foreach (IPackage p in packages) { foreach (Dependency d in p.Dependencies) { if (d.IsOptional && !includeoptional) { continue; } IPackage depp = FindPackage(packages, d); if (depp == null) { throw new InvalidDependencyException("Could not find dependency '" + d.Name + "'", p, null); } if (!string.IsNullOrEmpty(d.FeatureName)) { Feature feat = depp.Features.FindByName(d.FeatureName); if (feat == null) { throw new Exception("Feature not found in features."); } feat.Enabled = true; } } } }
private void AddInfo() { DBScanInfo db = new DBScanInfo(); PackageList.Add(Package); Package = ""; string AllPackage = ""; foreach (string s in PackageList) { AllPackage += s; } db.InsertUploadInfo(this.Year.ToString(), this.Login, AllPackage, this.IDZ, PDF, PIN); try { db.InsertPackage(PackageList, this.PIN, this.Year); } catch (Exception ex) { MessageBox.Show(ex.Message); } db.BuildAndInsertHyperLink(this.PIN, this.Year.ToString()); fp.Close(); this.Enabled = true; MessageBox.Show("Привязка успешно завершена!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
public override ShipRateQuote GetShipRateQuote(Warehouse origin, CommerceBuilder.Users.Address destination, BasketItemCollection contents, string serviceCode) { //VERIFY WE HAVE A DESTINATION COUNTRY if (string.IsNullOrEmpty(destination.CountryCode)) { return(null); } //VERIFY THAT ORIGIN COUNTRY IS AU if (string.IsNullOrEmpty(origin.CountryCode) || !origin.CountryCode.Equals("AU")) { return(null); } if (destination.CountryCode.Equals("AU")) { //if destination is also AU only domestic services are applicable if (!IsDomesticService(serviceCode)) { return(null); } } else { //only international services are available if (IsDomesticService(serviceCode)) { return(null); } } PackageList plist = PreparePackages(origin, contents); if (plist == null || plist.Count == 0) { return(null); } ProviderShipRateQuote providerQuote = null; ProviderShipRateQuote tempQuote; foreach (Package item in plist) { tempQuote = GetProviderQuote(origin, destination, item, serviceCode); if (providerQuote == null) { providerQuote = tempQuote; } else { providerQuote.AddPackageQoute(tempQuote); } } if (providerQuote != null && providerQuote.PackageCount < plist.Count) { return(null); } return(providerQuote); }
public static List <IPackage> OrderByDependencies(PackageList packages) { List <IPackage> orderedpackages = new List <IPackage>(); foreach (IPackage pack in packages) { if (orderedpackages.Contains(pack)) { continue; } List <IPackage> deps = GetDependencies(packages, pack); foreach (IPackage p in deps) { if (!orderedpackages.Contains(p)) { orderedpackages.Add(p); } } if (!orderedpackages.Contains(pack)) { orderedpackages.Add(pack); } } return(orderedpackages); }
/// <summary> /// Binds the lists. /// </summary> private void BindLists() { // bind shipment packages if (PackageList.Items.Count <= 1) { ShippingMethodDto shippingDto = ShippingManager.GetShippingPackages(); if (shippingDto.Package != null) { foreach (ShippingMethodDto.PackageRow row in shippingDto.Package.Rows) { PackageList.Items.Add(new ListItem(row.Name, row.PackageId.ToString())); } } PackageList.DataBind(); } // bind warehouses if (WarehouseList.Items.Count <= 1) { WarehouseDto dto = WarehouseManager.GetWarehouseDto(); if (dto.Warehouse != null) { foreach (WarehouseDto.WarehouseRow row in dto.Warehouse.Rows) { WarehouseList.Items.Add(new ListItem(row.Name, row.WarehouseId.ToString())); } } WarehouseList.DataBind(); } // bind merchants if (MerchantList.Items.Count <= 1) { CatalogEntryDto merchants = CatalogContext.Current.GetMerchantsDto(); if (merchants.Merchant != null) { foreach (CatalogEntryDto.MerchantRow row in merchants.Merchant.Rows) { MerchantList.Items.Add(new ListItem(row.Name, row.MerchantId.ToString())); } } MerchantList.DataBind(); } // bind tax categories if (TaxList.Items.Count <= 1) { CatalogTaxDto taxes = CatalogTaxManager.GetTaxCategories(); if (taxes.TaxCategory != null) { foreach (CatalogTaxDto.TaxCategoryRow row in taxes.TaxCategory.Rows) { TaxList.Items.Add(new ListItem(row.Name, row.TaxCategoryId.ToString())); } } TaxList.DataBind(); } }
public static void UpdatePackage() { string packageName = LastArgument(); PackageRepo pr = PackageList.Instance().GetLatestPackage(packageName); UpliftManager.Instance().UpdatePackage(pr); }
private void PackageList_SelectionChanged(object sender, SelectionChangedEventArgs e) { PackageList.UpdateLayout(); if (PackageList.SelectedItem != null) { PackageList.ScrollIntoView(PackageList.SelectedItem); } }
public static void AddDependencePackages(PackageList packages) { foreach (IPackage pack in packages) { List <IPackage> deps = GetDependencies(packages, pack, false, true); pack.Packages.AddRange(deps); } }
public void SendARequestToControlCenterForPackageDelivery() { WarehouseRequest wr = new WarehouseRequest(); wr.CreateARequestForPackageDelivery(this, packageList[0]); Controlcenter.AddAWarehouseRequestToTheList(wr); PackagesAwaitingForDronePickup.Add(packageList[0]); PackageList.Remove(packageList[0]); }
public PackageList GetPackages() { if (this.packages == null || !this.allpackagesread) { this.packages = this.ReadRepositoryDir(this.PackageDir); this.allpackagesread = true; } return(this.packages); }
private PackageRepo[] IdentifyInstallable(DependencyDefinition[] definitions) { PackageRepo[] result = new PackageRepo[definitions.Length]; for (int i = 0; i < definitions.Length; i++) { result[i] = PackageList.Instance().FindPackageAndRepository(definitions[i]); } return(result); }
public PackageList GetPackages() { PackageList plist = new PackageList(); foreach (IPackageRepository rep in this.Repositories) { plist.AddRange(rep.GetPackages()); } return(plist); }
/// <summary> /// Tries to create packages from the specified logfiles; walking dependencies if needed. /// </summary> /// <param name="args">The args.</param> /// <param name="newPackages">The new packages.</param> /// <returns></returns> public static bool TryCreatePackages(PackageArgs args, out PackageList newPackages) { if (args == null) { throw new ArgumentNullException("args"); } PackageState state = new PackageState(args); state.LoadExternalOrigins(); state.CreateBuildOrigins(); state.AddRequirements(); state.CalculateDependencies(); newPackages = new PackageList(); List <TBLogFile> filesToRun = new List <TBLogFile>(state.Logs); while (filesToRun.Count > 0) { int n = 0; for (int i = 0; i < filesToRun.Count; i++) { TBLogFile file = filesToRun[i]; if (state.CanPackage(file)) { filesToRun.RemoveAt(i--); string target = QQnPath.Combine(args.OutputDir, file.Project.Name + ".tpZip"); FileInfo targetInfo = new FileInfo(target); TPack pack; if (targetInfo.Exists && targetInfo.LastWriteTime > file.GetLastWriteTime()) { pack = TPack.OpenFrom(target, VerificationMode.None); state.SetOriginPack(file, pack.Pack); } else { pack = TPack.Create(target, state.CreateDefinition(file)); } newPackages.Add(target, pack); n++; } } if (n == 0) { break; // Can't package anything } } return(true); }
void Btn_PackageDown_Click(object sender, RoutedEventArgs e) { int i = PackageList.SelectedIndex; string f = (PackageList.Items[i] as ListViewItem).Content as string; PackageList.Items.RemoveAt(i); PackageList.Items.Insert(i + 1, makeListItem(f)); PackageList.SelectedIndex = i + 1; PackageList.Focus(); saveConfiguration(); }
public void OrderByDependencies() { PackageList packages = this.GetPackages(); List <IPackage> orderedpacks = DependencyResolver.OrderByDependencies(packages); Assert.AreEqual(4, orderedpacks.Count()); Assert.AreEqual("package1", orderedpacks[0].Name); Assert.AreEqual("package2", orderedpacks[1].Name); Assert.AreEqual("package4", orderedpacks[2].Name); Assert.AreEqual("package3", orderedpacks[3].Name); }
public void Setup(VisualElement root) { packageList = root.Q <PackageList>(); packageDetails = root.Q <PackageDetails>(); Debug.Log(kHeader, $"[Setup] {packageList}, {packageDetails},"); packageList.RegisterLoadedAction(UpdateGitPackageVersions); AvailableVersions.OnChanged += UpdateGitPackageVersions; UpdateGitPackageVersions(); UpdateAvailableVersionsForGitPackages(); }
private Dictionary <string, ProviderShipRateQuote> GetAllServiceQuotes(Warehouse origin, Address destination, BasketItemCollection contents) { string cacheKey = StringHelper.CalculateMD5Hash(Misc.GetClassId(this.GetType()) + "_" + origin.WarehouseId.ToString() + "_" + destination.AddressId.ToString() + "_" + contents.GenerateContentHash()); HttpContext context = HttpContext.Current; if ((context != null) && (context.Items.Contains(cacheKey))) { return((Dictionary <string, ProviderShipRateQuote>)context.Items[cacheKey]); } //VERIFY WE HAVE A DESTINATION COUNTRY if (string.IsNullOrEmpty(destination.CountryCode)) { return(null); } PackageList plist = PreparePackages(origin, destination, contents); if (plist == null || plist.Count == 0) { return(null); } Dictionary <string, ProviderShipRateQuote> allQuotes = new Dictionary <string, ProviderShipRateQuote>(); List <ProviderShipRateQuote> providerQuotes; ProviderShipRateQuote tempQuote; foreach (Package item in plist) { providerQuotes = GetProviderQuotes(origin, destination, item); foreach (ProviderShipRateQuote quote in providerQuotes) { if (allQuotes.ContainsKey(quote.ServiceCode)) { tempQuote = allQuotes[quote.ServiceCode]; tempQuote.AddPackageQoute(quote); } else { allQuotes.Add(quote.ServiceCode, quote); } } } RemoveInEffectiveQuotes(allQuotes, plist.Count); if (context != null) { context.Items.Add(cacheKey, allQuotes); } return(allQuotes); }
/// <summary> /// 添加发票信息 /// </summary> /// <param name="one">发票信息实体</param> /// <returns></returns> private bool InsertOne(string pkgNo, InvoiceModel one = null) { if (!String.IsNullOrEmpty(pkgNo)) { var pkg = PackageList.SingleOrDefault(f => f.PkgNumber == pkgNo); if (pkg == null) { pkgIndex = 1; PackageList.Add(new PackageModel { PkgNumber = pkgNo, InvoiceList = new List <InvoiceModel>() }); return(true); } else { pkgIndex = pkg.InvoiceList.Count + 1; } return(true); } if (one == null) { return(true); } if (invoiceList.Count > 0) { var exist = invoiceList.Where(f => f.Number == one.Number); if (exist.Count() != 0) { if (MessageBox.Show(string.Format("发票号码:{0} 已存在,是否重复添加?", one.Number), "扫描提示", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No) { return(false); } } } if (isAllowInsert) { //invoiceList.Where(f => f.PkgNumber == one.PkgNumber && f.PkgIndex >= one.PkgIndex).ToList(); invoiceList.Insert(insertIndex, one); IsAllowInsert = false; } else { invoiceList.Add(one); } IsNeedSave = true; return(true); }
private DependencyGraph GenerateGraph(DependencyDefinition[] dependencies) { DependencyGraph graph = new DependencyGraph(); PackageList packageList = PackageList.Instance(); foreach (DependencyDefinition dependency in dependencies) { DependencyNode current; graph.LoadDependencies(dependency, packageList, CheckConflict, out current); } return(graph); }
static void Main(string[] args) { var packages = new PackageList(); var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var packagesPath = Path.Combine(baseDirectory, "Packages"); if(!Directory.Exists(packagesPath)) { Directory.CreateDirectory(packagesPath); } else { Directory.Delete(packagesPath, true); } foreach(var packageModel in packages) { var path = Path.Combine(packagesPath, packageModel.Id); Directory.CreateDirectory(path); RenderManifest(packageModel, path); if(packageModel.Content.Count > 0) { var contentPath = Path.Combine(path, "content"); Directory.CreateDirectory(contentPath); foreach(var source in packageModel.Content) { var fileName = Path.GetFileName(source); var sourceFileName = ResolveRelativePath(baseDirectory, source); var destFileName = Path.Combine(contentPath, fileName); File.Copy(sourceFileName, destFileName); } } var nugetPath = ResolveRelativePath(baseDirectory, "../../../../nuget/nuget.exe"); var localNuget = Path.Combine(path, "nuget.exe"); File.Copy(nugetPath, localNuget); var proc = new Process { StartInfo = new ProcessStartInfo(localNuget) { WorkingDirectory = path, Arguments = "pack " + packageModel.Id + ".nuspec" } }; proc.Start(); } }
void Start() { string patha = Application.dataPath + "/" + "Test.xml"; Package pack = new Package(); pack.Name = "Test"; ZinBundle[] bundles = new ZinBundle[2]; bundles[0] = new ZinBundle(FileType.Picture, "Picture.unity3d"); bundles[1] = new ZinBundle(FileType.PageMain, "PageMain.unity3d"); pack.Bundles = bundles; pack.PriceID = "2,000"; pack.ID = "dd"; pack.IsBuy = true; pack.IsDownload = true; pack.Point = 11; pack.Price = "111"; pack.No = "001"; Package pack2 = new Package(); pack2.Name = "Test2"; pack.Bundles = bundles; pack2.PriceID = "2,000"; pack.ID = "aa"; pack.IsBuy = false; pack.IsDownload = false; pack.Point = 11; pack.Price = "1121"; pack.No = "002"; PackageList packList = new PackageList(); packList.packages = new Package[] { pack, pack2 }; if (ZinSerializerForXML.Serialization<PackageList>(packList, patha)) { Debug.Log("save package List: " + patha); } else { Debug.LogError("Save Error: " + patha); } }
/// <summary> /// xml 불러오기 /// </summary> /// <param name="path"></param> /// <returns></returns> IEnumerator LoadXML (string path) { using (WWW www = new WWW (path)) { yield return www; if (www.isDone) { xml = www.text; packList = (PackageList)ZinSerializerForXML.Deserialization<PackageList> (xml); if (packList != null) { Debug.Log ("LoadXML Compleate: " + path); SetLoadXml (true); } else { Debug.LogError ("LoadXML Error: " + path); SetLoadXml (false); } // StartCoroutine(LoadPreviewImage()); // SetStatus(); } else { Debug.LogError ("XML Not Found:" + path); Debug.LogError (www.error); } www.Dispose (); } }
void Start () { itemClick = GetComponentInParent<ItemClick> (); packageList = PackageListManager.Instance.packList; }