Beispiel #1
0
 public FormatOptions(
     string workspaceFilePath,
     WorkspaceType workspaceType,
     bool noRestore,
     LogLevel logLevel,
     FixCategory fixCategory,
     DiagnosticSeverity codeStyleSeverity,
     DiagnosticSeverity analyzerSeverity,
     ImmutableHashSet <string> diagnostics,
     bool saveFormattedFiles,
     bool changesAreErrors,
     SourceFileMatcher fileMatcher,
     string?reportPath,
     bool includeGeneratedFiles)
 {
     WorkspaceFilePath     = workspaceFilePath;
     WorkspaceType         = workspaceType;
     NoRestore             = noRestore;
     LogLevel              = logLevel;
     FixCategory           = fixCategory;
     CodeStyleSeverity     = codeStyleSeverity;
     AnalyzerSeverity      = analyzerSeverity;
     Diagnostics           = diagnostics;
     SaveFormattedFiles    = saveFormattedFiles;
     ChangesAreErrors      = changesAreErrors;
     FileMatcher           = fileMatcher;
     ReportPath            = reportPath;
     IncludeGeneratedFiles = includeGeneratedFiles;
 }
        public static async Task <Workspace?> LoadAsync(
            string solutionOrProjectPath,
            WorkspaceType workspaceType,
            bool createBinaryLog,
            bool logWorkspaceWarnings,
            ILogger logger,
            CancellationToken cancellationToken)
        {
            var properties = new Dictionary <string, string>(StringComparer.Ordinal)
            {
                // This property ensures that XAML files will be compiled in the current AppDomain
                // rather than a separate one. Any tasks isolated in AppDomains or tasks that create
                // AppDomains will likely not work due to https://github.com/Microsoft/MSBuildLocator/issues/16.
                { "AlwaysCompileMarkupFilesInSeparateDomain", bool.FalseString },
            };

            MSBuildWorkspace workspace;

            await s_guard.WaitAsync();

            try
            {
                workspace = MSBuildWorkspace.Create(properties);

                Build.Framework.ILogger?binlog = null;
                if (createBinaryLog)
                {
                    binlog = new Build.Logging.BinaryLogger()
                    {
                        Parameters = Path.Combine(Environment.CurrentDirectory, "formatDiagnosticLog.binlog"),
                        Verbosity  = Build.Framework.LoggerVerbosity.Diagnostic,
                    };
                }

                if (workspaceType == WorkspaceType.Solution)
                {
                    await workspace.OpenSolutionAsync(solutionOrProjectPath, msbuildLogger : binlog, cancellationToken : cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    try
                    {
                        await workspace.OpenProjectAsync(solutionOrProjectPath, msbuildLogger : binlog, cancellationToken : cancellationToken).ConfigureAwait(false);
                    }
                    catch (InvalidOperationException)
                    {
                        logger.LogError(Resources.Could_not_format_0_Format_currently_supports_only_CSharp_and_Visual_Basic_projects, solutionOrProjectPath);
                        workspace.Dispose();
                        return(null);
                    }
                }
            }
            finally
            {
                s_guard.Release();
            }

            LogWorkspaceDiagnostics(logger, logWorkspaceWarnings, workspace.Diagnostics);

            return(workspace);
Beispiel #3
0
 public void Deconstruct(
     out string workspaceFilePath,
     out WorkspaceType workspaceType,
     out bool noRestore,
     out LogLevel logLevel,
     out FixCategory fixCategory,
     out DiagnosticSeverity codeStyleSeverity,
     out DiagnosticSeverity analyzerSeverity,
     out ImmutableHashSet <string> diagnostics,
     out bool saveFormattedFiles,
     out bool changesAreErrors,
     out SourceFileMatcher fileMatcher,
     out string?reportPath,
     out bool includeGeneratedFiles)
 {
     workspaceFilePath     = WorkspaceFilePath;
     workspaceType         = WorkspaceType;
     noRestore             = NoRestore;
     logLevel              = LogLevel;
     fixCategory           = FixCategory;
     codeStyleSeverity     = CodeStyleSeverity;
     analyzerSeverity      = AnalyzerSeverity;
     diagnostics           = Diagnostics;
     saveFormattedFiles    = SaveFormattedFiles;
     changesAreErrors      = ChangesAreErrors;
     fileMatcher           = FileMatcher;
     reportPath            = ReportPath;
     includeGeneratedFiles = IncludeGeneratedFiles;
 }
Beispiel #4
0
        /// <summary>
        /// Find a match based on a list of workspace items
        /// </summary>
        /// <param name="pItems"></param>
        /// <param name="pType"></param>
        /// <param name="pPath"></param>
        /// <returns></returns>
        public static WorkspaceItem FindMatch(List <WorkspaceItem> pItems, WorkspaceType pType, string pPath)
        {
            switch (pType)
            {
            case WorkspaceType.Final:
                var r1 = pItems.Where(w =>
                                      (
                                          w.Final != null &&
                                          w.Final.Path.Equals(pPath)
                                      ) ||
                                      (
                                          w.Project != null &&
                                          w.Project.TargetPath.Equals(pPath)
                                      )
                                      ).FirstOrDefault();
                if (r1 != null)
                {
                    return(r1);
                }
                return(pItems.Where(w =>
                                    (
                                        w.Final != null &&
                                        w.Final.Path.StartsWith(pPath)
                                    ) ||
                                    (
                                        w.Project != null &&
                                        w.Project.TargetPath.StartsWith(pPath)
                                    )
                                    ).FirstOrDefault());

            case WorkspaceType.New:
                return(pItems.Where(w =>
                                    (
                                        w.New != null &&
                                        w.New.Path.Equals(pPath)
                                    ) ||
                                    (
                                        w.Project != null &&
                                        w.Project.SourcePath.Equals(pPath)
                                    )
                                    ).FirstOrDefault());

            case WorkspaceType.Project:
                return(pItems.Where(w =>
                                    (
                                        w.Project != null &&
                                        w.Project.FullPath.Equals(pPath)
                                    ) ||
                                    (
                                        w.New != null &&
                                        Path.GetFileName(w.New.Path).Equals(Path.ChangeExtension(Path.GetFileName(pPath), ".mp4"))
                                    ) ||
                                    (
                                        w.Final != null &&
                                        Path.GetFileName(w.Final.Path).Equals(new MLT.MLTProject(pPath, new Video.VideoInfoProvider()).TargetName)
                                    )
                                    ).FirstOrDefault());
            }
            return(null);
        }
Beispiel #5
0
        public virtual bool NewWorkspace(WorkspaceType type)
        {
            Debug.Log("making a new, untitled workspace..." + name);

            WorkspaceBase newWorkspace = null;

            switch (type)
            {
            case WorkspaceType.PresentationEdit:
                newWorkspace = Instantiate(WorkspacePresentationPrefab, transform) as WorkspaceBase;
                break;

            case WorkspaceType.StageEdit:
                newWorkspace = Instantiate(WorkspaceStagePrefab, transform) as WorkspaceBase;
                break;
            }

            if (newWorkspace != null)
            {
                TrackNewWorkspace(newWorkspace);
                SwitchWorkspace(newWorkspace);
                return(true);
            }

            return(false);
        }
Beispiel #6
0
 public FormatOptions(
     string workspaceFilePath,
     WorkspaceType workspaceType,
     LogLevel logLevel,
     bool fixCodeStyle,
     DiagnosticSeverity codeStyleSeverity,
     bool fixAnalyzers,
     DiagnosticSeverity analyerSeverity,
     bool saveFormattedFiles,
     bool changesAreErrors,
     Matcher fileMatcher,
     string?reportPath,
     bool includeGeneratedFiles)
 {
     WorkspaceFilePath     = workspaceFilePath;
     WorkspaceType         = workspaceType;
     LogLevel              = logLevel;
     FixCodeStyle          = fixCodeStyle;
     CodeStyleSeverity     = codeStyleSeverity;
     FixAnalyzers          = fixAnalyzers;
     AnalyzerSeverity      = analyerSeverity;
     SaveFormattedFiles    = saveFormattedFiles;
     ChangesAreErrors      = changesAreErrors;
     FileMatcher           = fileMatcher;
     ReportPath            = reportPath;
     IncludeGeneratedFiles = includeGeneratedFiles;
 }
Beispiel #7
0
        /// <summary>
        /// 创建StatusStrip
        /// </summary>
        private static StatusStrip CreateStatusStrip(WorkspaceType workspaceType)
        {
            StatusStrip outStatusStrip = new StatusStrip();

            switch (workspaceType)
            {
            case WorkspaceType.Default:
                ToolStripStatusLabel label = new ToolStripStatusLabel("就绪");
                outStatusStrip.Items.Add(label);
                break;

            case WorkspaceType.Content:
                break;

            case WorkspaceType.Page:
                break;

            case WorkspaceType.HelpPage:
                break;

            default:
                throw new Exception("未知参数:" + workspaceType);
            }

            return(outStatusStrip);
        }
Beispiel #8
0
 public void Deconstruct(
     out string workspaceFilePath,
     out WorkspaceType workspaceType,
     out LogLevel logLevel,
     out bool fixCodeStyle,
     out DiagnosticSeverity codeStyleSeverity,
     out bool fixAnalyzers,
     out DiagnosticSeverity analyerSeverity,
     out bool saveFormattedFiles,
     out bool changesAreErrors,
     out Matcher fileMatcher,
     out string?reportPath,
     out bool includeGeneratedFiles)
 {
     workspaceFilePath     = WorkspaceFilePath;
     workspaceType         = WorkspaceType;
     logLevel              = LogLevel;
     fixCodeStyle          = FixCodeStyle;
     codeStyleSeverity     = CodeStyleSeverity;
     fixAnalyzers          = FixAnalyzers;
     analyerSeverity       = AnalyzerSeverity;
     saveFormattedFiles    = SaveFormattedFiles;
     changesAreErrors      = ChangesAreErrors;
     fileMatcher           = FileMatcher;
     reportPath            = ReportPath;
     includeGeneratedFiles = IncludeGeneratedFiles;
 }
Beispiel #9
0
 /// <summary>
 /// Apply changes on the WorkspaceContainer, the update event handler will get trigger if anything was changed
 /// </summary>
 /// <param name="pType"></param>
 /// <param name="pEvents"></param>
 private void Monitor_Updated(WorkspaceType pType, List <FSEventInfo> pEvents)
 {
     try {
         Updater.Apply(Container, VideoInfoProvider, pType, pEvents);
     } catch (Exception) {
         ReloadRequired?.Invoke(this, new EventArgs());
     }
 }
Beispiel #10
0
        //

        public WorkspaceImpl(HostServices hostServices, WorkspaceType workspaceType)          //bool isCSharpScript )
            : base(hostServices, WorkspaceKind.Host)
        {
            this.workspaceType = workspaceType;
            //this.isCSharpScript = isCSharpScript;

            DiagnosticProvider.Enable(this, DiagnosticProvider.Options.Semantic);
        }
Beispiel #11
0
 private static Task <Workspace?> OpenMSBuildWorkspaceAsync(
     string solutionOrProjectPath,
     WorkspaceType workspaceType,
     bool createBinaryLog,
     bool logWorkspaceWarnings,
     ILogger logger,
     CancellationToken cancellationToken)
 {
     return(MSBuildWorkspaceLoader.LoadAsync(solutionOrProjectPath, workspaceType, createBinaryLog, logWorkspaceWarnings, logger, cancellationToken));
 }
Beispiel #12
0
        public void Create(String name, WorkspaceType type, String fileName, String directoryPath)
        {
            this._name          = name;
            this._type          = type;
            this._fileName      = fileName;
            this._directoryPath = directoryPath;

            this._file      = new FileInfo(this._fileName);
            this._directory = new DirectoryInfo(this._directoryPath);
        }
Beispiel #13
0
        private void createTab(string selectedPath, WorkspaceType workspaceType, GameConsole gameConsole)
        {
            TabPage tabPage = new TabPage();

            workspaceTabs.TabPages.Add(tabPage);
            switch (workspaceType)
            {
            case WorkspaceType.SBFRESManager:
                BFRESManager bfresManager = new BFRESManager();
                bfresManager.Parent = tabPage;
                bfresManager.Size   = tabPage.Size;
                if (Directory.Exists(selectedPath))
                {
                    bfresManager.BaseProjectPath = selectedPath;
                }
                else
                {
                    if (MessageBox.Show(@"Could not find """ + selectedPath + @""" please specify a new directory", "Missing Directory",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        FolderSelectDialog dialog = new FolderSelectDialog();
                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            bfresManager.BaseProjectPath = dialog.SelectedPath;
                        }
                    }
                }

                switch (gameConsole)
                {
                case GameConsole.WiiU:
                    tabPage.Text = "BFRES Manager (Wii U)";
                    bfresManager.NintendoSwitchMode = false;
                    break;

                case GameConsole.Switch:
                    tabPage.Text = "BFRES Manager (Switch)";
                    bfresManager.NintendoSwitchMode = true;
                    break;
                }
                break;

            case WorkspaceType.CEMURulesGenerator:
                CEMURulesGenerator cemuRulesGenerator = new CEMURulesGenerator();
                cemuRulesGenerator.Parent = tabPage;
                cemuRulesGenerator.Size   = tabPage.Size;
                tabPage.Text = "CEMU Rules Generator";
                break;
            }
            workspacePaths.Add(selectedPath);
            workspaces.Add(workspaceType);
            workspaceConsoles.Add(gameConsole);
        }
Beispiel #14
0
        private static async Task <Workspace?> OpenMSBuildWorkspaceAsync(
            string solutionOrProjectPath,
            WorkspaceType workspaceType,
            bool logWorkspaceWarnings,
            ILogger logger,
            CancellationToken cancellationToken,
            bool createBinaryLog = false)
        {
            var properties = new Dictionary <string, string>(StringComparer.Ordinal)
            {
                // This property ensures that XAML files will be compiled in the current AppDomain
                // rather than a separate one. Any tasks isolated in AppDomains or tasks that create
                // AppDomains will likely not work due to https://github.com/Microsoft/MSBuildLocator/issues/16.
                { "AlwaysCompileMarkupFilesInSeparateDomain", bool.FalseString },
                // This flag is used at restore time to avoid imports from packages changing the inputs to restore,
                // without this it is possible to get different results between the first and second restore.
                { "ExcludeRestorePackageImports", bool.TrueString },
            };

            var workspace = MSBuildWorkspace.Create(properties);

            Build.Framework.ILogger?binlog = null;
            if (createBinaryLog)
            {
                binlog = new BinaryLogger()
                {
                    Parameters = Path.Combine(Environment.CurrentDirectory, "formatDiagnosticLog.binlog"),
                    Verbosity  = Build.Framework.LoggerVerbosity.Diagnostic,
                };
            }

            if (workspaceType == WorkspaceType.Solution)
            {
                await workspace.OpenSolutionAsync(solutionOrProjectPath, msbuildLogger : binlog, cancellationToken : cancellationToken).ConfigureAwait(false);
            }
            else
            {
                try
                {
                    await workspace.OpenProjectAsync(solutionOrProjectPath, msbuildLogger : binlog, cancellationToken : cancellationToken).ConfigureAwait(false);
                }
                catch (InvalidOperationException)
                {
                    logger.LogError(Resources.Could_not_format_0_Format_currently_supports_only_CSharp_and_Visual_Basic_projects, solutionOrProjectPath);
                    workspace.Dispose();
                    return(null);
                }
            }

            LogWorkspaceDiagnostics(logger, logWorkspaceWarnings, workspace.Diagnostics);

            return(workspace);
        }
Beispiel #15
0
        /// <summary>
        /// 创建菜单系统MenuStrip
        /// </summary>
        static private MenuStrip CreateMenuStrip(WorkspaceType workspaceType)
        {
            MenuStrip outMenuStrip = new MenuStrip();

            outMenuStrip.LayoutStyle = ToolStripLayoutStyle.Flow;
            switch (workspaceType)
            {
            case WorkspaceType.Default:
                foreach (ToolStripMenuItem item in _peakMenuItem.Values)
                {
                    outMenuStrip.Items.Add(item);
                }
                //outMenuStrip.Items.AddRange(new ToolStripItem[] {
                //    _peakMenuItem["file"],
                //    _peakMenuItem["edit"],
                //    _peakMenuItem["view"],
                //    _peakMenuItem["site"],
                //    _peakMenuItem["page"],
                //    _peakMenuItem["tmplt"],
                //    _peakMenuItem["report"],
                //    _peakMenuItem["window"],
                //    _peakMenuItem["user"],
                //    _peakMenuItem["community"],
                //    _peakMenuItem["help"]});
                //outMenuStrip.MdiWindowListItem = _peakMenuItem["window"];
                break;

            case WorkspaceType.Content:
                break;

            case WorkspaceType.Page:
                break;

            case WorkspaceType.HelpPage:
                break;

            default:
                throw new Exception("未知参数:" + workspaceType);
            }

            ///处理“窗口”菜单
            //ToolStripMenuItem windowMenuItem = _peakMenuItem["window"];
            //windowMenuItem.DropDownOpening += new EventHandler(windowMenuItem_DropDownOpening);

            _mainForm.Controls.Add(outMenuStrip);
            outMenuStrip.ImageList = ResourceService.MainImageList;

            return(outMenuStrip);
        }
Beispiel #16
0
        /// <summary>
        /// 改变当前状态栏MenuStrip
        /// </summary>
        private static void ChangeStatusBar(WorkspaceType workspaceType)
        {
            StatusStrip newStatusStrip;

            if (!_allStatusStrip.TryGetValue(workspaceType, out newStatusStrip))
            {
                newStatusStrip = CreateStatusStrip(workspaceType);
                _mainForm.Controls.Add(newStatusStrip);
                _allStatusStrip.Add(workspaceType, newStatusStrip);
            }

            HideAll();
            newStatusStrip.Show();
            _currentStatusStrip = newStatusStrip;
        }
Beispiel #17
0
 /// <summary>
 /// 改变当前菜单系统MenuStrip
 /// </summary>
 static private void ChangeTopMenu(WorkspaceType workspaceType)
 {
     //由于打算一直显示所有菜单,所以这里将不改变----为防需求发生变化,暂不删除
     #region
     workspaceType = WorkspaceType.Default;
     //改变为当前工作区的相关菜单
     MenuStrip newMenuStrip;
     if (!_allMenuStrip.TryGetValue(workspaceType, out newMenuStrip))
     {
         newMenuStrip = CreateMenuStrip(workspaceType);
         _allMenuStrip.Add(workspaceType, newMenuStrip);
     }
     _mainForm.TopMenu = newMenuStrip;
     #endregion
 }
Beispiel #18
0
 public void Deconstruct(
     out string workspaceFilePath,
     out WorkspaceType workspaceType,
     out LogLevel logLevel,
     out bool saveFormattedFiles,
     out bool changesAreErrors,
     out ImmutableHashSet <string> filesToFormat)
 {
     workspaceFilePath  = WorkspaceFilePath;
     workspaceType      = WorkspaceType;
     logLevel           = LogLevel;
     saveFormattedFiles = SaveFormattedFiles;
     changesAreErrors   = ChangesAreErrors;
     filesToFormat      = FilesToFormat;
 }
Beispiel #19
0
 public FormatOptions(
     string workspaceFilePath,
     WorkspaceType workspaceType,
     LogLevel logLevel,
     bool saveFormattedFiles,
     bool changesAreErrors,
     ImmutableHashSet <string> filesToFormat)
 {
     WorkspaceFilePath  = workspaceFilePath;
     WorkspaceType      = workspaceType;
     LogLevel           = logLevel;
     SaveFormattedFiles = saveFormattedFiles;
     ChangesAreErrors   = changesAreErrors;
     FilesToFormat      = filesToFormat;
 }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkspaceList" /> class.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="name">name.</param>
 /// <param name="type">type.</param>
 /// <param name="siteUrl">siteUrl.</param>
 /// <param name="groupEmail">groupEmail.</param>
 /// <param name="primaryContact">primaryContact.</param>
 /// <param name="primaryContactEmail">primaryContactEmail.</param>
 /// <param name="phase">phase.</param>
 /// <param name="isCurrentRenewer">isCurrentRenewer.</param>
 /// <param name="createdTime">createdTime.</param>
 /// <param name="status">status.</param>
 /// <param name="autoImportProfileId">autoImportProfileId.</param>
 /// <param name="pendingAction">pendingAction.</param>
 public WorkspaceList(Guid id = default(Guid), string name = default(string), WorkspaceType type = default(WorkspaceType), string siteUrl = default(string), string groupEmail = default(string), string primaryContact = default(string), string primaryContactEmail = default(string), AutoImportPhase phase = default(AutoImportPhase), bool isCurrentRenewer = default(bool), DateTime createdTime = default(DateTime), SiteStatus status = default(SiteStatus), Guid autoImportProfileId = default(Guid), int pendingAction = default(int))
 {
     this.Id                  = id;
     this.Name                = name;
     this.Type                = type;
     this.SiteUrl             = siteUrl;
     this.GroupEmail          = groupEmail;
     this.PrimaryContact      = primaryContact;
     this.PrimaryContactEmail = primaryContactEmail;
     this.Phase               = phase;
     this.IsCurrentRenewer    = isCurrentRenewer;
     this.CreatedTime         = createdTime;
     this.Status              = status;
     this.AutoImportProfileId = autoImportProfileId;
     this.PendingAction       = pendingAction;
 }
        public void ActiveWorkspace(WorkspaceType type)
        {
            DeactiveWorkspaces();

            Workspace workspace = workspaces[(int)type];

            workspace.context.Visibility       = Visibility.Visible;
            workspace.button.IsActiveWorkspace = true;

            for (int i = 0; i < commonTabs.Length; ++i)
            {
                AttachTab(commonTabs[i], workspace);
            }

            WorkspaceActived?.Invoke(workspace);
        }
Beispiel #22
0
        private void Navigate(WorkspaceType workspaceType)
        {
            if (Workspace != null)
            {
                Workspace.IsClosing = true;
            }

            if (workspaces.ContainsKey(workspaceType))
            {
                Workspace           = workspaces[workspaceType];
                Workspace.IsClosing = false;
                return;
            }

            WorkspaceViewModel workspace = null;

            switch (workspaceType)
            {
            case WorkspaceType.Run:
                workspace = new RunViewModel();
                break;

            case WorkspaceType.Notes:
                workspace = new NotesViewModel();
                break;

            case WorkspaceType.Profiles:
                workspace = new ProfilesViewModel();
                break;

            case WorkspaceType.Settings:
                workspace = new SettingsViewModel();
                break;

            case WorkspaceType.Help:
                workspace = new HelpViewModel();
                break;
            }

            if (workspace == null)
            {
                return;
            }

            workspaces.Add(workspaceType, workspace);
            Workspace = workspace;
        }
Beispiel #23
0
        static void ChangeToolbar(WorkspaceType workspaceType)
        {
            foreach (MyToolStrip strip in _toolStripList.Values)
            {
                bool isShow = false;

                if (workspaceType == WorkspaceType.Default)
                {
                    isShow = (strip.DefaultWorkspaceType == WorkspaceType.All);
                }
                else
                {
                    isShow = ((strip.DefaultWorkspaceType & workspaceType) == workspaceType);
                }
                strip.Visible = isShow;
            }
        }
Beispiel #24
0
 public void Deconstruct(
     out string workspaceFilePath,
     out WorkspaceType workspaceType,
     out LogLevel logLevel,
     out bool saveFormattedFiles,
     out bool changesAreErrors,
     out Matcher fileMatcher,
     out string reportPath)
 {
     workspaceFilePath  = WorkspaceFilePath;
     workspaceType      = WorkspaceType;
     logLevel           = LogLevel;
     saveFormattedFiles = SaveFormattedFiles;
     changesAreErrors   = ChangesAreErrors;
     fileMatcher        = FileMatcher;
     reportPath         = ReportPath;
 }
Beispiel #25
0
 public FormatOptions(
     string workspaceFilePath,
     WorkspaceType workspaceType,
     LogLevel logLevel,
     bool saveFormattedFiles,
     bool changesAreErrors,
     Matcher fileMatcher,
     string reportPath)
 {
     WorkspaceFilePath  = workspaceFilePath;
     WorkspaceType      = workspaceType;
     LogLevel           = logLevel;
     SaveFormattedFiles = saveFormattedFiles;
     ChangesAreErrors   = changesAreErrors;
     FileMatcher        = fileMatcher;
     ReportPath         = reportPath;
 }
Beispiel #26
0
        private static async Task <Workspace> OpenWorkspaceAsync(
            string workspacePath,
            WorkspaceType workspaceType,
            ImmutableHashSet <string> filesToFormat,
            bool logWorkspaceWarnings,
            ILogger logger,
            CancellationToken cancellationToken)
        {
            if (workspaceType == WorkspaceType.Folder)
            {
                var folderWorkspace = FolderWorkspace.Create();
                await folderWorkspace.OpenFolder(workspacePath, filesToFormat, cancellationToken);

                return(folderWorkspace);
            }

            return(await OpenMSBuildWorkspaceAsync(workspacePath, workspaceType, logWorkspaceWarnings, logger, cancellationToken));
        }
Beispiel #27
0
        private void createNewWorkspace(WorkspaceType workspaceType, GameConsole gameConsole)
        {
            switch (workspaceType)
            {
            case WorkspaceType.SBFRESManager:
                MessageBox.Show("Pick a directory for the new workspace");
                FolderSelectDialog folderBrowserDialog = new FolderSelectDialog();
                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    createTab(folderBrowserDialog.SelectedPath, workspaceType, gameConsole);
                }
                break;

            case WorkspaceType.CEMURulesGenerator:
                createTab("", workspaceType, gameConsole);
                break;
            }
        }
Beispiel #28
0
        private static async Task <Workspace?> OpenMSBuildWorkspaceAsync(
            string solutionOrProjectPath,
            WorkspaceType workspaceType,
            bool noRestore,
            bool requiresSemantics,
            string?binaryLogPath,
            bool logWorkspaceWarnings,
            ILogger logger,
            CancellationToken cancellationToken)
        {
            if (requiresSemantics &&
                !noRestore &&
                await DotNetHelper.PerformRestoreAsync(solutionOrProjectPath, logger) != 0)
            {
                throw new Exception("Restore operation failed.");
            }

            return(await MSBuildWorkspaceLoader.LoadAsync(solutionOrProjectPath, workspaceType, binaryLogPath, logWorkspaceWarnings, logger, cancellationToken));
        }
Beispiel #29
0
 public void Deconstruct(
     out string workspaceFilePath,
     out WorkspaceType workspaceType,
     out LogLevel logLevel,
     out bool saveFormattedFiles,
     out bool changesAreErrors,
     out ImmutableHashSet <string> pathsToInclude,
     out ImmutableHashSet <string> pathsToExclude,
     out string reportPath)
 {
     workspaceFilePath  = WorkspaceFilePath;
     workspaceType      = WorkspaceType;
     logLevel           = LogLevel;
     saveFormattedFiles = SaveFormattedFiles;
     changesAreErrors   = ChangesAreErrors;
     pathsToInclude     = PathsToInclude;
     pathsToExclude     = PathsToExclude;
     reportPath         = ReportPath;
 }
Beispiel #30
0
 public FormatOptions(
     string workspaceFilePath,
     WorkspaceType workspaceType,
     LogLevel logLevel,
     bool saveFormattedFiles,
     bool changesAreErrors,
     ImmutableHashSet <string> pathsToInclude,
     ImmutableHashSet <string> pathsToExclude,
     string reportPath)
 {
     WorkspaceFilePath  = workspaceFilePath;
     WorkspaceType      = workspaceType;
     LogLevel           = logLevel;
     SaveFormattedFiles = saveFormattedFiles;
     ChangesAreErrors   = changesAreErrors;
     PathsToInclude     = pathsToInclude;
     PathsToExclude     = pathsToExclude;
     ReportPath         = reportPath;
 }
		public Workspace CreateWorkspace(string name, string user, string password, WorkspaceType type)
		{
			return new Workspace(dbe.CreateWorkspace(name, user, password, type));
		}
 /// <summary>
 ///Update label expressions and definition queries when switching between databases
 /// </summary>
 /// <param name="table"></param>
 /// <param name="wsType"></param>
 public static void UpdateSQLForTable(IStandaloneTable table, WorkspaceType wsType)
 {
     // string methodName = MethodInfo.GetCurrentMethod().Name;
     try
     {
         if (table != null && wsType != WorkspaceType.None)
         {
             switch (wsType)
             {
                 case WorkspaceType.FileGDB:
                     if (table is ITableDefinition)
                     {
                         ITableDefinition tableDefinition = table as ITableDefinition;
                         if (tableDefinition != null && string.IsNullOrEmpty(tableDefinition.DefinitionExpression) == false)
                         {
                             tableDefinition.DefinitionExpression = tableDefinition.DefinitionExpression.Replace("[", "\"");
                             tableDefinition.DefinitionExpression = tableDefinition.DefinitionExpression.Replace("]", "\"");
                         }
                     }
                     break;
             }
         }
         // else
         //  _logger.LogFormat("{0}: Null Table or workspace type is not supported.", methodName, LogLevel.enumLogLevelWarn);
     }
     catch (Exception ex)
     {
         //_logger.LogException(ex);
     }
 }
 /// <summary>
 /// Update label expressions and definition queries when switching between databases
 /// </summary>
 /// <param name="map"></param>
 /// <param name="newWorkspace"></param>
 public static void UpdateSQLForLayer(IFeatureLayer featLayer, WorkspaceType wsType)
 {
     //string methodName = MethodInfo.GetCurrentMethod().Name;
     try
     {
         if (featLayer != null && wsType != WorkspaceType.None)
         {
             switch (wsType)
             {
                 case WorkspaceType.FileGDB:
                     if (featLayer is IFeatureLayerDefinition)
                     {
                         IFeatureLayerDefinition flDefinition = featLayer as IFeatureLayerDefinition;
                         if (flDefinition != null && string.IsNullOrEmpty(flDefinition.DefinitionExpression) == false)
                         {
                             flDefinition.DefinitionExpression = flDefinition.DefinitionExpression.Replace("[", "\"");
                             flDefinition.DefinitionExpression = flDefinition.DefinitionExpression.Replace("]", "\"");
                             flDefinition.DefinitionExpression = flDefinition.DefinitionExpression.Replace("*", "%");
                             flDefinition.DefinitionExpression = flDefinition.DefinitionExpression.Replace("Shape.STLength()", "Shape_Length");
                         }
                     }
                     if (featLayer is IGeoFeatureLayer)
                     {
                         IGeoFeatureLayer geoFeatLyr = featLayer as IGeoFeatureLayer;
                         if (geoFeatLyr != null)
                         {
                             IAnnotateLayerPropertiesCollection annotateLayerPropsColl = geoFeatLyr.AnnotationProperties;
                             if (annotateLayerPropsColl != null && annotateLayerPropsColl.Count > 0)
                             {
                                 for (int i = 0; i < annotateLayerPropsColl.Count; i++)
                                 {
                                     IAnnotateLayerProperties annotateLayerPropetries; IElementCollection placedElements; IElementCollection unplacedElements;
                                     annotateLayerPropsColl.QueryItem(i, out annotateLayerPropetries, out placedElements, out unplacedElements);
                                     if (annotateLayerPropetries != null)
                                     {
                                         ILabelEngineLayerProperties lblEngineLyrProp = null;
                                         if (string.IsNullOrEmpty(annotateLayerPropetries.WhereClause) == false)
                                         {
                                             annotateLayerPropetries.WhereClause = annotateLayerPropetries.WhereClause.Replace("[", "\"");
                                             annotateLayerPropetries.WhereClause = annotateLayerPropetries.WhereClause.Replace("]", "\"");
                                             annotateLayerPropetries.WhereClause = annotateLayerPropetries.WhereClause.Replace("*", "%");
                                             annotateLayerPropetries.WhereClause = annotateLayerPropetries.WhereClause.Replace("Shape.STLength()", "Shape_Length");
                                         }
                                         if (annotateLayerPropetries is ILabelEngineLayerProperties)
                                         {
                                             lblEngineLyrProp = annotateLayerPropetries as ILabelEngineLayerProperties;
                                             if (lblEngineLyrProp != null && string.IsNullOrEmpty(lblEngineLyrProp.Expression) == false)
                                                 lblEngineLyrProp.Expression = lblEngineLyrProp.Expression.Replace("Shape.STLength()", "Shape_Length");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     break;
                 case WorkspaceType.SDE:
                     if (featLayer is IFeatureLayerDefinition)
                     {
                         IFeatureLayerDefinition flDefinition = featLayer as IFeatureLayerDefinition;
                         if (flDefinition != null && string.IsNullOrEmpty(flDefinition.DefinitionExpression) == false)
                         {
                             if (flDefinition.DefinitionExpression.IndexOf("\"Shape_Length\"") != -1)
                                 flDefinition.DefinitionExpression = flDefinition.DefinitionExpression.Replace("\"Shape_Length\"", "Shape.STLength()");
                             else if (flDefinition.DefinitionExpression.IndexOf("Shape_Length") != -1)
                                 flDefinition.DefinitionExpression = flDefinition.DefinitionExpression.Replace("Shape_Length", "Shape.STLength()");
                         }
                     }
                     if (featLayer is IGeoFeatureLayer)
                     {
                         IGeoFeatureLayer geoFeatLyr = featLayer as IGeoFeatureLayer;
                         if (geoFeatLyr != null)
                         {
                             IAnnotateLayerPropertiesCollection annotateLayerPropsColl = geoFeatLyr.AnnotationProperties;
                             if (annotateLayerPropsColl != null && annotateLayerPropsColl.Count > 0)
                             {
                                 for (int i = 0; i < annotateLayerPropsColl.Count; i++)
                                 {
                                     IAnnotateLayerProperties annotateLayerPropetries; IElementCollection placedElements; IElementCollection unplacedElements;
                                     annotateLayerPropsColl.QueryItem(i, out annotateLayerPropetries, out placedElements, out unplacedElements);
                                     if (annotateLayerPropetries != null)
                                     {
                                         ILabelEngineLayerProperties lblEngineLyrProp = null;
                                         if (string.IsNullOrEmpty(annotateLayerPropetries.WhereClause) == false)
                                         {
                                             if (annotateLayerPropetries.WhereClause.IndexOf("\"Shape_Length\"") != -1)
                                                 annotateLayerPropetries.WhereClause = annotateLayerPropetries.WhereClause.Replace("\"Shape_Length\"", "Shape.STLength()");
                                             else if (annotateLayerPropetries.WhereClause.IndexOf("Shape_Length") != -1)
                                                 annotateLayerPropetries.WhereClause = annotateLayerPropetries.WhereClause.Replace("Shape_Length", "Shape.STLength()");
                                         }
                                         if (annotateLayerPropetries is ILabelEngineLayerProperties)
                                         {
                                             lblEngineLyrProp = annotateLayerPropetries as ILabelEngineLayerProperties;
                                             if (lblEngineLyrProp != null)
                                             {
                                                 if (lblEngineLyrProp.Expression.IndexOf("Shape_Length") != -1)
                                                     lblEngineLyrProp.Expression = lblEngineLyrProp.Expression.Replace("Shape_Length", "Shape.STLength()");
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     break;
             }
         }
         // else
         //  _logger.LogFormat("{0}: Null FeatureLayer or workspace type is not supported.", methodName, LogLevel.enumLogLevelWarn);
     }
     catch (Exception ex)
     {
         //_logger.LogException(ex);
     }
 }