Example #1
0
        static void Main(string[] args)
        {
            ObjectFactory.Configure(a =>
            {
                a.For <IAchievementRepository>().Singleton().Use <AppDataXmlCompletedAchievementsRepository>();
            });
            var fullChain = true;

            var cultureToTest = "ru-RU"; // Set to "ru-RU" to enable russian. Set to "nl" for dutch

            // Comment the following line to use operating system default culture.
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureToTest);

            if (!fullChain)
            {
                using (IParser parser = ParserFactory.CreateParser(System.IO.Path.GetFullPath("TestFile.cs")))
                {
                    parser.Parse();

                    // Allows retrieving comments, preprocessor directives, etc. (stuff that isn't part of the syntax)
                    var specials = parser.Lexer.SpecialTracker.RetrieveSpecials();

                    // Retrieves the root node of the result AST
                    var result = parser.CompilationUnit;

                    if (parser.Errors.Count > 0)
                    {
                        MessageBox.Show(parser.Errors.ErrorOutput, "Parse errors");
                    }

                    result.AcceptVisitor(new AchievementVisitor(), null);
                }

                System.Console.Read();
            }
            else
            {
                AchievementContext.AchievementsUnlocked += AchievementContext_AchievementsUnlocked;
                GuiInitializer.Initialize();

                var achievementDescriptorRepository = ObjectFactory.GetInstance <IAchievementRepository>();
                achievementDescriptorRepository.LoadFromAssembly(typeof(AnonymousObjectAchievement).Assembly);
                achievementDescriptorRepository.ResetAchievements();

                DetectionDispatcher.DetectionCompleted += DetectionDispatcher_DetectionCompleted;
                var file = System.IO.Path.GetFullPath("TestFile.cs");
                DetectionDispatcher.Dispatch(new BuildInformation()
                {
                    ActiveFile   = file,
                    ChangedFiles = new string[] { file },
                    CodeFiles    = new string[] { file }
                });

                System.Console.Read();
            }
        }
Example #2
0
        /// <summary>
        /// Called when the VSPackage is loaded by Visual Studio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            //Set a uiculture
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");

            ObjectFactory.Configure(a =>
            {
                a.For <IAchievementRepository>().Singleton().Use <AppDataXmlCompletedAchievementsRepository>();
                a.For <ISettingsRepository>().Singleton().Use <AppDataXmlSettingsRepository>();
            });

            if (MenuService != null)
            {
                var menuCommandID = new CommandID(
                    GuidList.guidCSharpAchiever_Achiever_VSIXCmdSet,
                    (int)PkgCmdIDList.showAchievementIndex);

                var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);

                MenuService.AddCommand(menuItem);
            }

            if (SolutionBuildManager != null)
            {
                var buildTracker = new BuildTracker(DTE);

                SolutionBuildManager.AdviseUpdateSolutionEvents(buildTracker, out updateSolutionEventsCookie);
            }

            AddService <IAchevementLibraryService>(this, true);

            RegisterAchievementAssembly(typeof(NRefactoryAchievement).Assembly);

            GuiInitializer.Initialize();

            AchievementContext.AchievementClicked  += AchievementContext_AchievementClicked;
            DetectionDispatcher.DetectionCompleted += DetectionDispatcher_DetectionCompleted;
        }