Exemple #1
0
        private IEnumerable <string> GetSignature(Seed targetSeed)
        {
            var signatures = new HashSet <string>();

            {
                var storeTreeItems = new List <StoreTreeItem>();

                {
                    var storeCategorizeTreeItems = new List <StoreCategorizeTreeItem>();
                    storeCategorizeTreeItems.Add(Settings.Instance.StoreUploadControl_StoreCategorizeTreeItem);
                    storeCategorizeTreeItems.Add(Settings.Instance.StoreDownloadControl_StoreCategorizeTreeItem);

                    for (int i = 0; i < storeCategorizeTreeItems.Count; i++)
                    {
                        storeCategorizeTreeItems.AddRange(storeCategorizeTreeItems[i].Children);
                        storeTreeItems.AddRange(storeCategorizeTreeItems[i].StoreTreeItems);
                    }
                }

                foreach (var storeTreeItem in storeTreeItems)
                {
                    var boxList  = new List <Box>();
                    var seedList = new HashSet <Seed>();

                    boxList.AddRange(storeTreeItem.Boxes);

                    for (int i = 0; i < boxList.Count; i++)
                    {
                        boxList.AddRange(boxList[i].Boxes);
                        seedList.UnionWith(boxList[i].Seeds);
                    }

                    if (seedList.Contains(targetSeed))
                    {
                        signatures.Add(storeTreeItem.Signature);
                    }
                }
            }

            {
                foreach (var signature in Inspect.GetTrustSignatures())
                {
                    Store store;
                    if (!Settings.Instance.Cache_Stores.TryGetValue(signature, out store))
                    {
                        continue;
                    }

                    var boxList  = new List <Box>();
                    var seedList = new HashSet <Seed>();

                    boxList.AddRange(store.Boxes);

                    for (int i = 0; i < boxList.Count; i++)
                    {
                        boxList.AddRange(boxList[i].Boxes);
                        seedList.UnionWith(boxList[i].Seeds);
                    }

                    if (seedList.Contains(targetSeed))
                    {
                        signatures.Add(signature);
                    }
                }
            }

            return(signatures.ToArray());
        }