當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlTextWriter.WriteAttributeStringFormat方法代碼示例

本文整理匯總了C#中System.Xml.XmlTextWriter.WriteAttributeStringFormat方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextWriter.WriteAttributeStringFormat方法的具體用法?C# XmlTextWriter.WriteAttributeStringFormat怎麽用?C# XmlTextWriter.WriteAttributeStringFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlTextWriter的用法示例。


在下文中一共展示了XmlTextWriter.WriteAttributeStringFormat方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateProjectFiles

        /// <summary>
        /// Generates project files for Visual Studio: '.vcxproj' and '.vcxproj.filter'.
        /// </summary>
        /// <param name="project">Parsed project object.</param>
        /// <returns>Path to Visual Studio's '.vcxproj file'.</returns>
        public override sealed string GenerateProjectFiles(ProjectCache project)
        {
            var vcxProjPath = Path.Combine(base.GenerateProjectFiles(project), project.CachedName) + ".vcxproj";

            try
            {
                // For build tools the best was is to load a GUID from project files: this causes exceptions
                // in Visual Studio when reloading of solution, and all opened tabs would be terminated.
                project.AdditionalCache.GUID = QueryGuidFromProject(vcxProjPath);
            }
            catch (Exception)
            {
                project.AdditionalCache.GUID = CreateMsBuildGuid();
            }

            // ==========================================================================================
            // Generating VCXPROJ files.
            // ==========================================================================================
            using (var vcxProj = new XmlTextWriter(vcxProjPath, null) { Formatting = Formatting.Indented, Indentation = 1, IndentChar = '\t' })
            {
                vcxProj.WriteStartDocument();
                vcxProj.WriteComment("Generated by GoddamnBuildSystem. Please, do not edit this file manually.");
                vcxProj./**/WriteStartElement("Project", c_MsBuild2003Namespace);
                vcxProj./**//**/WriteAttributeString("ToolsVersion", c_ToolsVersion);
                vcxProj./**//**/WriteAttributeString("DefaultTargets", "Build");

                // ------------------------------------------------------------------------------------------
                // Defining list of configurations.
                // ------------------------------------------------------------------------------------------
                vcxProj.WriteStartElement("ItemGroup");
                vcxProj./**/WriteAttributeString("Label", "ProjectConfigurations");
                foreach (var platform in TargetInfo.EnumerateAllPlatforms())
                {
                    var platformString = ConvertPlatformToMsBuildPlatform(platform);
                    foreach (var configuration in TargetInfo.EnumerateAllConfigurations())
                    {
                        var configurationName = string.Concat(configuration, platform);
                        vcxProj./**/WriteStartElement("ProjectConfiguration");
                        vcxProj./**//**/WriteAttributeString("Include", configurationName + '|' + platformString);
                        vcxProj./**//**/WriteElementString("Configuration", configurationName);
                        vcxProj./**//**/WriteElementString("Platform", platformString);
                        vcxProj./**/WriteEndElement();
                    }
                }
                vcxProj.WriteEndElement();

                // ------------------------------------------------------------------------------------------
                // Defining list of source files.
                // ------------------------------------------------------------------------------------------
                vcxProj.WriteStartElement("ItemGroup");
                foreach (var projectSource in project.CachedSourceFiles)
                {
                    vcxProj./**/WriteStartElement(ConvertFileTypeToVcxProjElement(projectSource.FileType));
                    vcxProj./**//**/WriteAttributeString("Include", projectSource.FileName);
                    foreach (var platform in TargetInfo.EnumerateAllPlatforms())
                    {
                        var platformString = ConvertPlatformToMsBuildPlatform(platform);
                        foreach (var configuration in TargetInfo.EnumerateAllConfigurations())
                        {
                            if (projectSource.ShouldBeExcluded(platform, configuration))
                            {
                                var configurationName = string.Concat(configuration, platform);
                                vcxProj./**//**/WriteStartElement("ExcludedFromBuild");
                                vcxProj./**//**//**/WriteAttributeStringFormat("Condition", @"'$(Configuration)|$(Platform)'=='{0}|{1}'", configurationName, platformString);
                                vcxProj./**//**//**/WriteString("true");
                                vcxProj./**//**/WriteEndElement();
                            }
                        }
                    }
                    vcxProj./**/WriteEndElement();
                }
                vcxProj.WriteEndElement();

                // ------------------------------------------------------------------------------------------
                // Overriding global project properties.
                // ------------------------------------------------------------------------------------------
                vcxProj.WriteStartElement("PropertyGroup");
                vcxProj./**/WriteElementString("ProjectGuid", project.AdditionalCache.GUID);
                vcxProj./**/WriteElementString("RootNamespace", project.CachedName);
                vcxProj./**/WriteElementString("MinimumVisualStudioVersion", "14.0");
                vcxProj.WriteEndElement();
                foreach (var platform in TargetInfo.EnumerateAllPlatforms())
                {
                    var platformString = ConvertPlatformToMsBuildPlatform(platform);
                    foreach (var configuration in TargetInfo.EnumerateAllConfigurations())
                    {
                        var configurationName = string.Concat(configuration, platform);
                        vcxProj.WriteStartElement("PropertyGroup");
                        vcxProj./**/WriteAttributeStringFormat("Condition", "'$(Configuration)|$(Platform)'=='{0}|{1}'", configurationName, platformString);
                        vcxProj./**/WriteAttributeString("Label", "Globals");
                        if (TargetInfo.IsMicrosoftPlatform(platform))
                        {
                            //vcxProj./**/WriteElementString("AppContainerApplication", "true");
                            //vcxProj./**/WriteElementString("ApplicationType", "Windows Store");
                            //vcxProj./**/WriteElementString("WindowsTargetPlatformVersion", "10.0.10240.0");
//.........這裏部分代碼省略.........
開發者ID:GoddamnIndustries,項目名稱:GoddamnEngine,代碼行數:101,代碼來源:VisualStudioProjectGenerator.cs


注:本文中的System.Xml.XmlTextWriter.WriteAttributeStringFormat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。