当前位置: 首页>>代码示例>>C#>>正文


C# IVisualStudioService.GetProjectServiceBySuffix方法代码示例

本文整理汇总了C#中IVisualStudioService.GetProjectServiceBySuffix方法的典型用法代码示例。如果您正苦于以下问题:C# IVisualStudioService.GetProjectServiceBySuffix方法的具体用法?C# IVisualStudioService.GetProjectServiceBySuffix怎么用?C# IVisualStudioService.GetProjectServiceBySuffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVisualStudioService的用法示例。


在下文中一共展示了IVisualStudioService.GetProjectServiceBySuffix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNugetCommandStrings

        /// <summary>
        /// Gets the nuget command strings.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="usePreRelease">if set to <c>true</c> [use pre release].</param>
        /// <returns>The Nuget Command strings.</returns>
        internal static string GetNugetCommandStrings(
            this Plugin instance,
            IVisualStudioService visualStudioService,
            ISettingsService settingsService,
            bool usePreRelease)
        {
            string commands = string.Empty;

            foreach (string platform in instance.Platforms)
            {
                IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(platform);

                if (projectService != null)
                {
                    foreach (NugetCommand nugetCommand in instance.NugetCommands)
                    {
                        if (IsCommandRequired(nugetCommand, platform))
                        {
                            string pluginNugetCommand = nugetCommand.Command;

                            //// check to see if we are going to use local nuget

                            if (settingsService.UseLocalNuget &&
                                settingsService.LocalNugetName != string.Empty)
                            {
                                pluginNugetCommand = pluginNugetCommand.Replace(
                                    "-ProjectName",
                                    " -Source " + settingsService.LocalNugetName + " -ProjectName");
                            }

                            if (usePreRelease)
                            {
                                pluginNugetCommand += Settings.NugetIncludePreRelease;
                            }

                            if (instance.OverwriteFiles)
                            {
                                commands += Settings.NugetInstallPackageOverwriteFiles.Replace("%s", pluginNugetCommand) + " " + projectService.Name + Environment.NewLine;
                            }
                            else
                            {
                                commands += Settings.NugetInstallPackage.Replace("%s", pluginNugetCommand) + " " + projectService.Name + Environment.NewLine;
                            }
                        }
                    }
                }
            }

            return commands;
        }
开发者ID:asudbury,项目名称:NinjaCoderForMvvmCross,代码行数:58,代码来源:PluginExtensions.cs

示例2: GetNugetCommandMessages

        /// <summary>
        /// Gets the nuget command messages.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <returns></returns>
        internal static string GetNugetCommandMessages(
            this Plugin instance,
            IVisualStudioService visualStudioService)
        {
            string commands = string.Empty;

            foreach (string platform in instance.Platforms)
            {
                IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(platform);

                if (projectService != null)
                {
                    foreach (string nugetCommand in instance.NugetCommands)
                    {
                        commands += nugetCommand + " nuget package added to " + projectService.Name + " project." + Environment.NewLine;
                    }
                }
            }

            return commands;
        }
开发者ID:RobGibbens,项目名称:NinjaCoderForMvvmCross,代码行数:27,代码来源:PluginExtensions.cs

示例3: GetNugetCommandStrings

        /// <summary>
        /// Gets the nuget command strings.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="usePreRelease">if set to <c>true</c> [use pre release].</param>
        /// <returns></returns>
        internal static string GetNugetCommandStrings(
            this Plugin instance,
            IVisualStudioService visualStudioService,
            bool usePreRelease)
        {
            string commands = string.Empty;

            foreach (string platform in instance.Platforms)
            {
                IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(platform);

                if (projectService != null)
                {
                    foreach (string nugetCommand in instance.NugetCommands)
                    {
                        string pluginNugetCommand = nugetCommand;

                        if (usePreRelease)
                        {
                            pluginNugetCommand += Settings.NugetIncludePreRelease;
                        }

                        if (instance.OverwriteFiles)
                        {
                            commands += Settings.NugetInstallPackageOverwriteFiles .Replace("%s", pluginNugetCommand) + " " + projectService.Name + Environment.NewLine;
                        }

                        else
                        {
                            commands += Settings.NugetInstallPackage.Replace("%s", pluginNugetCommand) + " " + projectService.Name + Environment.NewLine;
                        }
                    }
                }
            }

            return commands;
        }
开发者ID:RobGibbens,项目名称:NinjaCoderForMvvmCross,代码行数:44,代码来源:PluginExtensions.cs

示例4: ApplyCodeSnippet

        /// <summary>
        /// Applies the code snippet.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="codeSnippet">The code snippet.</param>
        /// <returns>The messages.</returns>
        internal IEnumerable<string> ApplyCodeSnippet(
            IVisualStudioService visualStudioService, 
            CodeSnippet codeSnippet)
        {
            TraceService.WriteLine("CodeConfigService::ApplyCodeSnippet");

            List<string> messages = new List<string>();

            //// find the project
            IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(codeSnippet.Project);

            //// find the class
            IProjectItemService projectItemService = projectService?.GetProjectItem(codeSnippet.Class + ".cs");

            //// find the method.
            CodeFunction codeFunction = projectItemService?.GetFirstClass().GetFunction(codeSnippet.Method);

            string code = codeFunction?.GetCode();

            if (code?.Contains(codeSnippet.Code.Trim()) == false)
            {
                codeFunction.InsertCode(codeSnippet.Code, true);

                string message = string.Format(
                    "Code added to project {0} class {1} method {2}.",
                    projectService.Name,
                    codeSnippet.Class,
                    codeSnippet.Method);

                messages.Add(message);
            }

            return messages;
        }
开发者ID:asudbury,项目名称:NinjaCoderForMvvmCross,代码行数:40,代码来源:CodeConfigService.cs

示例5: GetNugetCommands

        /// <summary>
        /// Gets the nuget commands.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="templates">The templates.</param>
        /// <param name="verboseOutput">if set to <c>true</c> [verbose output].</param>
        /// <param name="debug">if set to <c>true</c> [debug].</param>
        /// <param name="usePreRelease">if set to <c>true</c> [use pre release].</param>
        /// <returns>The nuget commands.</returns>
        public string GetNugetCommands(
            IVisualStudioService visualStudioService,
            IEnumerable<ProjectTemplateInfo> templates,
            bool verboseOutput,
            bool debug,
            bool usePreRelease)
        {
            TraceService.WriteLine("NugetService::ExecuteNugetCommands");

            string nugetCommandsString = string.Empty;

            string verboseOption = this.GetVerboseOption(verboseOutput);

            string debugOption = this.GetDebugOption(debug);

            string preReleaseOption = this.GetPreReleaseOption(usePreRelease);

            foreach (ProjectTemplateInfo projectTemplateInfo in templates
                .Where(x => x.NugetCommands != null))
            {
                //// we need to work out if the project was successfully added to the solution
                //// in cases where the project is not supported (SDK not installed) it will
                //// not have been added (and therefore no nuget commands to run)

                IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(projectTemplateInfo.ProjectSuffix);

                if (projectService != null)
                {
                    foreach (string nugetCommand in projectTemplateInfo.NugetCommands)
                    {
                        nugetCommandsString += string.Format(
                            "{0} {1} {2} {3} {4}",
                            nugetCommand,
                            verboseOption,
                            debugOption,
                            preReleaseOption,
                            Environment.NewLine);
                    }
                }
            }

            TraceService.WriteLine("commands=" + nugetCommandsString);

            return nugetCommandsString;
        }
开发者ID:rmarinho,项目名称:NinjaCoderForMvvmCross,代码行数:54,代码来源:NugetService.cs

示例6: GetNugetCommands

        /// <summary>
        /// Gets the nuget commands.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="templates">The templates.</param>
        /// <param name="verboseOutput">if set to <c>true</c> [verbose output].</param>
        /// <param name="debug">if set to <c>true</c> [debug].</param>
        /// <returns>The nuget commands.</returns>
        public string GetNugetCommands(
            IVisualStudioService visualStudioService,
            IEnumerable<ProjectTemplateInfo> templates,
            bool verboseOutput,
            bool debug)
        {
            TraceService.WriteLine("NugetService::ExecuteNugetCommands");

            string nugetCommands = string.Empty;

            string verboseOption = string.Empty;

            if (verboseOutput)
            {
                verboseOption = "-verbose";
            }

            string debugOption = string.Empty;

            if (debug)
            {
                debugOption = "-debug";
            }

            foreach (ProjectTemplateInfo projectTemplateInfo in templates)
            {
                if (projectTemplateInfo.NugetCommands != null)
                {
                    //// we need to work out if the project was sucessfully added to the solution
                    //// in cases where the project is not supported (SDK not installed) it will
                    //// not have been added (and therefore no nuget commands to run)

                    IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(projectTemplateInfo.ProjectSuffix);

                    if (projectService != null)
                    {
                        foreach (string nugetCommand in projectTemplateInfo.NugetCommands)
                        {
                            nugetCommands += string.Format(
                                "{0} {1} {2} {3}",
                                nugetCommand,
                                verboseOption,
                                debugOption,
                                Environment.NewLine);
                        }
                    }
                }
            }

            return nugetCommands;
        }
开发者ID:nanohex,项目名称:NinjaCoderForMvvmCross,代码行数:59,代码来源:NugetService.cs

示例7: ApplyCodeDependencies

        /// <summary>
        /// Applies the code dependencies.
        /// </summary>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="codeConfig">The code config.</param>
        internal void ApplyCodeDependencies(
            IVisualStudioService visualStudioService,
            CodeConfig codeConfig)
        {
            TraceService.WriteLine("ServicesService::ApplyCodeDependencies");

            //// apply any code dependencies
            if (codeConfig.CodeDependencies != null)
            {
                foreach (CodeSnippet codeSnippet in codeConfig.CodeDependencies)
                {
                    //// find the project
                    IProjectService projectService = visualStudioService.GetProjectServiceBySuffix(codeSnippet.Project);

                    if (projectService != null)
                    {
                        //// find the class
                        IProjectItemService projectItemService = projectService.GetProjectItem(codeSnippet.Class + ".cs");

                        if (projectItemService != null)
                        {
                            //// find the method.
                            CodeFunction codeFunction = projectItemService.GetFirstClass().GetFunction(codeSnippet.Method);

                            if (codeFunction != null)
                            {
                                string code  = codeFunction.GetCode();

                                if (code.Contains(codeSnippet.Code.Trim()) == false)
                                {
                                    codeFunction.InsertCode(codeSnippet.Code, true);

                                    string message = string.Format(
                                        "Code added to project {0} class {1} method {2}.",
                                        projectService.Name,
                                        codeSnippet.Class,
                                        codeSnippet.Method);

                                    this.Messages.Add(message);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:nanohex,项目名称:NinjaCoderForMvvmCross,代码行数:51,代码来源:ServicesService.cs


注:本文中的IVisualStudioService.GetProjectServiceBySuffix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。