本文整理匯總了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");
//.........這裏部分代碼省略.........