Esempio n. 1
0
        private static void Compile(ISolution solution)
        {
            var workspaceServices = (IHaveWorkspaceServices)solution;
            var projectDependencyService = workspaceServices.WorkspaceServices.GetService<IProjectDependencyService>();

            foreach (var projectId in projectDependencyService.GetDependencyGraph(solution).GetTopologicallySortedProjects())
            {
                var currentDomain = AppDomain.CurrentDomain;
                var assemblyName = new AssemblyName();
                assemblyName.Name = "Most." + solution.GetProject(projectId).AssemblyName;

                var assemblyBuilder = currentDomain.DefineDynamicAssembly
                               (assemblyName, AssemblyBuilderAccess.RunAndSave);

                var moduleBuilder = assemblyBuilder.
                                                DefineDynamicModule(assemblyName.Name);
                var types = moduleBuilder.GetTypes();
                types.Aggregate((ts, t) =>
                {
                    var tb = t as TypeBuilder;
                    return tb.CreateType();
                });
                solution.GetProject(projectId).GetCompilation().Emit(moduleBuilder);
                assemblyBuilder.Save(assemblyName.Name);
            }
        }
Esempio n. 2
0
        private static void Compile(ISolution solution)
        {
            var workspaceServices        = (IHaveWorkspaceServices)solution;
            var projectDependencyService = workspaceServices.WorkspaceServices.GetService <IProjectDependencyService>();

            foreach (var projectId in projectDependencyService.GetDependencyGraph(solution).GetTopologicallySortedProjects())
            {
                var currentDomain = AppDomain.CurrentDomain;
                var assemblyName  = new AssemblyName();
                assemblyName.Name = "Most." + solution.GetProject(projectId).AssemblyName;

                var assemblyBuilder = currentDomain.DefineDynamicAssembly
                                          (assemblyName, AssemblyBuilderAccess.RunAndSave);

                var moduleBuilder = assemblyBuilder.
                                    DefineDynamicModule(assemblyName.Name);
                var types = moduleBuilder.GetTypes();
                types.Aggregate((ts, t) =>
                {
                    var tb = t as TypeBuilder;
                    return(tb.CreateType());
                });
                solution.GetProject(projectId).GetCompilation().Emit(moduleBuilder);
                assemblyBuilder.Save(assemblyName.Name);
            }
        }
Esempio n. 3
0
        private IProject CreateSubmissionProject(ISolution solution)
        {
            var name      = "Submission#" + _documentNumber++;
            var projectId = ProjectId.CreateNewId(solution.Id, name);

            var version            = VersionStamp.Create();
            var compilationOptions = _compilationOptions.WithScriptClassName(name);

            var projectInfo = new ProjectInfo(
                projectId,
                version,
                name,
                name,
                LanguageNames.CSharp,
                compilationOptions: compilationOptions,
                parseOptions: _parseOptions,
                metadataReferences: _references,
                isSubmission: true);

            solution = solution.AddProject(projectInfo);

            if (_previousProjectId != null)
            {
                solution = solution.AddProjectReference(projectId, _previousProjectId);
            }

            return(solution.GetProject(projectId));
        }
Esempio n. 4
0
        private IProject CreateSubmissionProject(ISolution solution)
        {
            string    name = "Submission#" + _documentNumber++;
            ProjectId id   = ProjectId.CreateNewId(solution.Id, name);

            solution =
                solution.AddProject(new ProjectInfo(id, VersionStamp.Create(), name, name, LanguageNames.CSharp, null,
                                                    _compilationOptions.WithScriptClassName(name), _parseOptions, null,
                                                    null, _references, null, true));
            if (_previousProjectId != null)
            {
                solution = solution.AddProjectReference(id, _previousProjectId);
            }
            return(solution.GetProject(id));
        }
Esempio n. 5
0
        private void Projects_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (null == Projects.SelectedValue)
                {
                    return;
                }

                var projectName = Projects.SelectedValue.ToString();

                if (String.IsNullOrEmpty(projectName))
                {
                    return;
                }

                Schemas.ItemsSource = null;
                Tables.ItemsSource  = null;

                _currentProject = _solution.GetProject(projectName);

                if (string.IsNullOrEmpty(_currentProject.GetScript(ScriptType.PreDeploy)) &&
                    string.IsNullOrEmpty(_currentProject.GetScript(ScriptType.PostDeploy)))
                {
                    MessageBox.Show(
                        "The project needs a post deploy script - add one anywhere in the project and refresh", "MergeUi");
                    return;
                }

                LastBuildTime.Text  = string.Format("Last Dacpac Build Time: {0}", _currentProject.GetLastBuildTime());
                Schemas.ItemsSource = _currentProject.GetSchemas();
            }
            catch (Exception ex)
            {
                Dispatcher.Invoke(() => { LastStatusMessage.Text = "Error see output window "; });

                OutputWindowMessage.WriteMessage("Error reading project: {0}", ex.Message);
            }
        }
Esempio n. 6
0
        private IProject CreateSubmissionProject(ISolution solution)
        {
            var name = "Submission#" + _documentNumber++;
            var projectId = ProjectId.CreateNewId(solution.Id, name);

            var version = VersionStamp.Create();
            var compilationOptions = _compilationOptions.WithScriptClassName(name);

            var projectInfo = new ProjectInfo(
                projectId,
                version,
                name,
                name,
                LanguageNames.CSharp,
                compilationOptions: compilationOptions,
                parseOptions: _parseOptions,
                metadataReferences: _references,
                isSubmission: true);

            solution = solution.AddProject(projectInfo);

            if (_previousProjectId != null)
            {
                solution = solution.AddProjectReference(projectId, _previousProjectId);
            }

            return solution.GetProject(projectId);
        }
        /// <summary>Executes action. Called after Update, that set <c>ActionPresentation</c>.Enabled to true.</summary>
        /// <param name="solution">The solution.</param>
        /// <param name="context">The context.</param>
        private void Execute(ISolution solution, IDataContext context)
        {
            this.solution = solution;
              this.currentFile = GetCurrentFile(this.solution, context);

              var items = new List<SimpleMenuItem>();

              var files = FavoriteFilesSettings.Instance.FavoriteFiles;

              var index = 0;

              foreach (var favoriteFilePath in files)
              {
            var path = favoriteFilePath;

            if (string.IsNullOrEmpty(favoriteFilePath.ProjectName))
            {
              var item = DescribeFavoriteFile(favoriteFilePath, index);

              item.Clicked += delegate { this.MenuItemClicked(path); };

              items.Add(item);

              index++;

              continue;
            }

            var project = solution.GetProject(favoriteFilePath.ProjectName);

            if (project != null)
            {
              var item = DescribeFavoriteFile(favoriteFilePath, index);

              item.Clicked += delegate { this.MenuItemClicked(path); };

              items.Add(item);

              index++;

              continue;
            }
              }

              if (items.Count > 0)
              {
            items.Add(SimpleMenuItem.CreateSeparator());
              }

              items.Add(this.DescribeAddMenuItem());
              items.Add(this.DescribeOrganizeMenuItem());

              var menu = new JetPopupMenu();

              menu.Caption.Value = WindowlessControl.Create("Favorite Files");
              menu.SetItems(items.ToArray());
              menu.KeyboardAcceleration.SetValue(KeyboardAccelerationFlags.Mnemonics);

              menu.Show();
        }