Beispiel #1
0
        private static AutoUpdateManager GetAutoUpdateManager()
        {
            // build up AutoUpdateManager - use DI instead?
            SteamCommunityManager steamCommunityManager =
                new SteamCommunityManager(new WebClientWrapper(), new SteamProfileXmlParser(), new GameXmlParser(),
                                          new AchievementXmlParser());
            AchievementService achievementService =
                new AchievementService(
                    new AchievementManager(new SteamRepository()), steamCommunityManager);
            UserService userService = new UserService(new AchievementManager(new SteamRepository()));

            // verify the log path
            DirectoryInfo logDirectory = new DirectoryInfo("logs");

            if (!logDirectory.Exists)
            {
                logDirectory.Create();
            }

            IAutoUpdateLogger autoUpdateLogger = new AutoUpdateLogger(logDirectory.FullName);

            // only keeps logs for the past 10 days
            autoUpdateLogger.Delete(DateTime.Now.AddDays(-10));
            // the default writer saves output to a file, this will display it in the console as well
            autoUpdateLogger.Attach(Console.Out);

            AutoUpdateManager autoUpdateManager =
                new AutoUpdateManager(achievementService, userService, new FacebookPublisher(),
                                      autoUpdateLogger);

            return(autoUpdateManager);
        }
        private static Publisher CreatePublisher()
        {
            var settings           = Settings.Default;
            var logger             = new AutoUpdateLogger(_logDirectory.FullName);
            var achievementManager = new AchievementManager(new SteamRepository());
            var communityManager   = new SteamCommunityManager(new WebClientWrapper(), new SteamProfileXmlParser(), new GameXmlParser(), new AchievementXmlParser());
            var achievementService = new AchievementService(achievementManager, communityManager);
            var facebookClient     = new FacebookClientService(settings.FacebookAppId, settings.FacebookAppSecret, settings.FacebookCanvasUrl);
            var autoUpdateManager  = new AutoUpdateManager(achievementService, new UserService(achievementManager), facebookClient, logger);

            return(new Publisher(autoUpdateManager));
        }