Exemplo n.º 1
0
                public static void Remove(AddonCollection collection)
                {
                    ReadOnlyCollection <T> results;

                    if (s_results.TryGetValue(collection, out results))
                    {
                        s_results.Remove(collection);
                    }
                }
Exemplo n.º 2
0
 private static IEnumerable <T> Filter(AddonCollection collection)
 {
     foreach (var item in collection)
     {
         if (item is T result)
         {
             yield return(result);
         }
     }
 }
        private static List <Addon> GetAddonsForInstalledExpansions(AddonCollection addonCollection)
        {
            IEnumerable <Enum> flags     = GetFlags(References.InstalledExpansion);
            List <Addon>       AddonList = new List <Addon>();

            foreach (Enum e in flags)
            {
                AddonList = AddonList.Concat(addonCollection.Addons.Where(c => c.Details.Expansion.HasFlag(e)).ToList()).ToList();
            }
            return(AddonList);
        }
        /// <summary>
        /// Loads Data From File And Saves it to References, then Creates list of addons
        /// </summary>
        public static void LoadAddonData()
        {
            if (!AppData.IsAddonListUpToDate() || !System.IO.File.Exists(Constants.ADDON_LIST_FILE_PATH))
            {
                DownloadData(Constants.ADDON_LIST_FILE_PATH, Constants.ADDON_LIST_DOWNLOAD_URL);
                return;
            }
            string          Data = System.IO.File.ReadAllText(Constants.ADDON_LIST_FILE_PATH);
            AddonCollection ac   = Newtonsoft.Json.JsonConvert.DeserializeObject <AddonCollection>(Data);

            ac.Addons = GetAddonsForInstalledExpansions(ac);
            References.AddonCollection = ac;
            List <System.Windows.UIElement> AddonControlsList = UIManager.CreateAddonList(0);
            //UIManager.AddControlToAddonList(AddonControlsList);
        }
Exemplo n.º 5
0
        private List <Addon> ParseDataToAddon(List <string> FileDataList)
        {
            Addon                  addon            = new Addon();
            List <Addon>           addons           = new List <Addon>();
            List <AddonCollection> addonCollections = new List <AddonCollection>();

            foreach (string FileData in FileDataList)
            {
                AddonCollection addonCollection = Newtonsoft.Json.JsonConvert.DeserializeObject <AddonCollection>(FileData);
                addonCollections.Add(addonCollection);
            }
            List <Addon> addonList = new List <Addon>();

            foreach (AddonCollection addonCollection in addonCollections)
            {
                addonList = addonList.Concat(addonCollection.Addons).ToList();
            }
            return(addonList);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AddonBag"/> class.
 /// </summary>
 protected AddonBag()
 {
     _addons = new AddonCollection(this);
 }
Exemplo n.º 7
0
 public static ReadOnlyCollection <T> GetResult(AddonCollection collection)
 {
     return(s_results.GetValue(collection, x => new ReadOnlyCollection <T>(Filter(x).ToArray())));
 }