void UnloadProjectSystem()
 {
     if (applicationLifetime != null) {
         applicationLifetime.Stopping ();
         applicationLifetime.Dispose ();
         applicationLifetime = null;
         projectSystem.Dispose ();
         projectSystem = null;
         context = null;
     }
 }
        internal void LoadAspNetProjectSystem(Solution solution)
        {
            UnloadProjectSystem ();

            applicationLifetime = new MonoDevelopApplicationLifetime ();
            context = new DnxContext ();
            var factory = new AspNet5ProjectSystemFactory ();
            projectSystem = factory.CreateProjectSystem (solution, applicationLifetime, context);
            projectSystem.Initalize ();
        }
        void LoadDnxProjectSystem(Solution solution)
        {
            UnloadProjectSystem ();

            applicationLifetime = new MonoDevelopApplicationLifetime ();
            context = new DnxContext ();
            var factory = new DnxProjectSystemFactory ();
            projectSystem = factory.CreateProjectSystem (solution, applicationLifetime, context);
            projectSystem.Initalize ();

            if (context.RuntimePath == null) {
                string error = GetRuntimeError (projectSystem);
                throw new ApplicationException (error);
            }
        }
 void UnloadProjectSystem()
 {
     initializeError = String.Empty;
     if (applicationLifetime != null) {
         applicationLifetime.Stopping ();
         applicationLifetime.Dispose ();
         applicationLifetime = null;
         if (projectSystem != null) {
             projectSystem.Dispose ();
             projectSystem = null;
         }
         context = null;
     }
 }
 static string GetRuntimeError(DnxProjectSystem projectSystem)
 {
     if (projectSystem.DnxPaths != null &&
         projectSystem.DnxPaths.RuntimePath != null &&
         projectSystem.DnxPaths.RuntimePath.Error != null) {
         return projectSystem.DnxPaths.RuntimePath.Error.Text;
     }
     return "Unable to find DNX runtime.";
 }