private void RegisterStaticData()
        {
            IStaticDataService staticData = new StaticDataService();

            staticData.Load();
            _services.RegisterSingle <IStaticDataService>(staticData);
        }
 private StaticDataService GetStaticDataService()
 {
     if (staticDataService == null)
     {
         staticDataService = new StaticDataService();
     }
     return(staticDataService);
 }
        public void Setup()
        {
            this.httpClientWrapperMock = new Mock <IHttpClientWrapper>();
            var httpClientFactoryWrapperMock = new Mock <IHttpClientFactoryWrapper>();

            httpClientFactoryWrapperMock.Setup(x => x.CreateClient(Constants.HttpClientNames.PoeTradeApiDataClient))
            .Returns(this.httpClientWrapperMock.Object);

            this.staticDataService = new StaticDataService(httpClientFactoryWrapperMock.Object, new PoeTradeApiJsonSerializer(new JsonSerializerWrapper()));
        }
        public void Constructor_ReadsFromFileCorrectly()
        {
            // Arrange

            var fileSystemService = new FileSystemService();

            var service = new StaticDataService(fileSystemService);

            // Act

            // Assert
        }
Exemple #5
0
        public bool Start()
        {
            var path = ConfigurationService.GetDarklandsPath(ConfigType.DarklandsCompanion);

            if (StaticDataService.SetDarklandsPath(path))
            {
                LiveDataService.ConnectionMonitor += OnConnected;
                LiveDataService.Connect();

                return(true);
            }
            MessageVm.Messages = "Error: Cannot find Darklands from the folder '" + path + "'";

            return(false);
        }
        public void Constructor_CallsFileSystemService()
        {
            // Arrange

            var mockFileSystemService = new Mock <IFileSystemService>();

            mockFileSystemService.Setup(f => f.ReadFileAsString(It.IsAny <string>())).Returns("TestResult").Verifiable();

            var service = new StaticDataService(mockFileSystemService.Object);

            // Act

            // Assert
            mockFileSystemService.Verify();
        }
        public ItemSet(string region, IEnumerable <ItemStats> itemStats)
        {
            EarlyItems    = new List <ItemStats>();
            MidgameItems  = new List <ItemStats>();
            LategameItems = new List <ItemStats>();

            foreach (var stat in itemStats
                     .GroupBy(x => x.ItemId)
                     .Select(group => group.First())
                     .Where(x => x.Wins > Convert.ToInt32(ConfigurationManager.AppSettings["ItemMinimumWinsRequired"]))
                     .OrderByDescending(x => x.WinPercent))
            {
                if (Champion == null)
                {
                    Champion = StaticDataService.GetChampion(region, stat.ChampionId);
                }

                if (Lane == null)
                {
                    Lane = stat.Lane;
                }

                switch (stat.GetTimeSection())
                {
                case ItemStats.Section.Early:
                    EarlyItems.Add(stat);
                    break;

                case ItemStats.Section.Mid:
                    MidgameItems.Add(stat);
                    break;

                default:
                    LategameItems.Add(stat);
                    break;
                }
            }

            // Limit number of items in each section

            var numberOfSectionItems = Convert.ToInt32(ConfigurationManager.AppSettings["ItemsPerSection"]);

            EarlyItems   = EarlyItems.Take(numberOfSectionItems).ToList();
            MidgameItems = MidgameItems.Where(x => StaticDataService.GetItem(region, x.ItemId).IsFinalItem)
                           .Take(numberOfSectionItems).ToList();
            LategameItems = LategameItems.Where(x => StaticDataService.GetItem(region, x.ItemId).IsFinalItem)
                            .Take(numberOfSectionItems).ToList();
        }
Exemple #8
0
        private static void Main(string[] args)
        {
            if (args == null || !Actions.Keys.Contains(args.First().ToLower()))
            {
                Console.WriteLine("Accepted parameters are:");
                Console.WriteLine(string.Join(", ", Actions.Keys));
            }
            else
            {
                StaticDataService.SetDarklandsPath(@"D:\Steam\SteamApps\common\Darklands");
                Actions[args.First()](args);
            }

            Console.WriteLine("Press any key to exit!");
            Console.ReadKey();
        }
        public void Setup()
        {
            this.httpClientWrapperMock = new Mock <IHttpClientWrapper>();
            this.httpClientWrapperMock.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new HttpResponseMessage
            {
                Content = new StringContent("")
            });

            var httpClientFactoryWrapperMock = new Mock <IHttpClientFactoryWrapper>();

            httpClientFactoryWrapperMock.Setup(x => x.CreateClient(Constants.HttpClientNames.PoeTradeApiDataClient))
            .Returns(this.httpClientWrapperMock.Object);

            this.poeTradeApiJsonSerializerMock = new Mock <IPoeTradeApiJsonSerializer>();

            this.staticDataService = new StaticDataService(httpClientFactoryWrapperMock.Object, this.poeTradeApiJsonSerializerMock.Object);
        }
Exemple #10
0
        public MainWindow()
        {
            Loaded += (s, e) =>
            {
                if (!ConfigurationService.HasDarklandsPath(ConfigType.DarklandsSaveGameEditor)
                    &&
                    !StaticDataService.SetDarklandsPath(
                        ConfigurationService.GetDarklandsPath(ConfigType.DarklandsSaveGameEditor)))
                {
                    var dialog = new SelectFolderDialog
                    {
                        RequiredFiles = StaticDataService.RequiredFiles,
                        Owner         = this
                    };

                    if (dialog.ShowDialog() == true)
                    {
                        ConfigurationService.SetDarklandsPath(dialog.SelectedPath);
                        if (!StaticDataService.SetDarklandsPath(dialog.SelectedPath))
                        {
                            Close();
                        }
                    }
                    else
                    {
                        Close();
                    }
                }

                StaticDataService.SetDarklandsPath(
                    ConfigurationService.GetDarklandsPath(ConfigType.DarklandsSaveGameEditor));

                var model = new MainWindowViewModel();
                DataContext = model;
            };

            Closing += (s, e) => { ErrorMonitor.ShutDown(); };
        }
        public MainWindow()
        {
            InitializeComponent();

            Loaded += (s, e) =>
            {
                var model = new MainWindowViewModel();
                DataContext = model;

                if (!ConfigurationService.HasDarklandsPath(ConfigType.DarklandsCompanion)
                    &&
                    !StaticDataService.SetDarklandsPath(
                        ConfigurationService.GetDarklandsPath(ConfigType.DarklandsCompanion)))
                {
                    var dialog = new SelectFolderDialog
                    {
                        RequiredFiles = StaticDataService.RequiredFiles,
                        Owner         = this
                    };

                    if (dialog.ShowDialog() == true)
                    {
                        ConfigurationService.SetDarklandsPath(dialog.SelectedPath);
                    }
                    else
                    {
                        Close();
                    }
                }

                if (!model.Start())
                {
                    Close();
                }
            };
        }
 public void SetPath()
 {
     StaticDataService.SetDarklandsPath(@"D:\Steam\SteamApps\common\Darklands");
 }
 public LocalizationService(StaticDataService resourceService)
 {
     _staticDataService = resourceService;
 }
        public ActionResult Index()
        {
            var champs = StaticDataService.GetAllChampions("na");

            return(View(champs));
        }
Exemple #15
0
        private void UpdateResults()
        {
            var sb = new StringBuilder();

            if (string.IsNullOrEmpty(Filter))
            {
                sb.AppendLine(DefaultText);
            }
            else if (Filter.ToLower().StartsWith("help"))
            {
                sb.AppendLine(_helpText);
            }
            else
            {
                var buffFilter = SaintBuffManager.FindFilter(Filter);
                if (buffFilter == null)
                {
                    return;
                }

                var party = LiveDataService.ReadParty().ToList();

                IEnumerable <int> knownSaintIds = null;
                if (KnownOnly)
                {
                    knownSaintIds = (from c in party
                                     select c.SaintBitmask.SaintIds).SelectMany(s => s).Distinct();
                }

                var matchingSaints = StaticDataService.FilterSaints(buffFilter, knownSaintIds).ToList();
                if (matchingSaints.Any())
                {
                    sb.AppendLine("Known saints with bonus to '" + buffFilter.Name + "': ");
                    sb.AppendLine();

                    foreach (var s in matchingSaints)
                    {
                        var saint = s;

                        sb.AppendFormat("{0}: {1}", saint.ShortName, saint.GetBuff(buffFilter.Name));

                        var knownBy = (from c in party
                                       where c.SaintBitmask.HasSaint(saint.Id)
                                       select c.ShortName).ToList();

                        if (knownBy.Any())
                        {
                            sb.AppendFormat(" ({0})", string.Join(", ", knownBy));
                        }

                        sb.AppendLine();
                    }
                }
                else
                {
                    sb.AppendLine("No one in the party knows saints with buff to '" + buffFilter.Name + "'.");
                }
            }

            if (sb.Length > 0)
            {
                Result = sb.ToString();
            }
        }
Exemple #16
0
 public PlayerServiceExample(StaticDataService staticDataService)
 {
     _staticDataService = staticDataService;
 }
 public static void Init(StaticDataService StaticDataService)
 {
     _staticDataService = StaticDataService;
 }
 public List <Item> GetFinalItems()
 {
     return(Stats.FinalItemIds.Select(itemId => StaticDataService.GetItem("na", itemId)).ToList());
 }
        // GET: Lane
        public ActionResult Index(string id)
        {
            var champ = StaticDataService.GetChampion("na", Convert.ToInt32(id));

            return(View(champ));
        }