本文整理汇总了C#中Microsoft.Build.Utilities.CommandLineBuilder.AppendSwitchUnquotedIfNotNull方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineBuilder.AppendSwitchUnquotedIfNotNull方法的具体用法?C# CommandLineBuilder.AppendSwitchUnquotedIfNotNull怎么用?C# CommandLineBuilder.AppendSwitchUnquotedIfNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Utilities.CommandLineBuilder
的用法示例。
在下文中一共展示了CommandLineBuilder.AppendSwitchUnquotedIfNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAppendSwitchUnquotedIfNotNull1
public void TestAppendSwitchUnquotedIfNotNull1 ()
{
clb = new CommandLineBuilder ();
clb.AppendSwitchUnquotedIfNotNull (null, "parameter");
}
示例2: GenerateArgumentBool
private void GenerateArgumentBool(CommandLineBuilder builder, BaseProperty property, string value)
{
if (value == "true")
{
builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPrefix, property.Switch);
}
else if (value == "false" && ((BoolProperty)property).ReverseSwitch != null)
{
builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPrefix, ((BoolProperty)property).ReverseSwitch);
}
}
示例3: GenerateArgumentEnum
private void GenerateArgumentEnum(CommandLineBuilder builder, BaseProperty property, string value)
{
var result = ((EnumProperty)property).AdmissibleValues.Find(x => (x.Name == value));
if (result != null)
{
builder.AppendSwitchUnquotedIfNotNull(m_parsedBuildRule.SwitchPrefix, result.Switch);
}
}
示例4: TestAppendUnquotedSwitchIfNotNull10
public void TestAppendUnquotedSwitchIfNotNull10 ()
{
clb = new CommandLineBuilder ();
clb.AppendSwitchUnquotedIfNotNull ("/switch:", (ITaskItem[]) null, ";");
Assert.AreEqual (String.Empty, clb.ToString (), "A1");
clb.AppendSwitchUnquotedIfNotNull ("/switch:", items, ";");
Assert.AreEqual ("/switch:a;b", clb.ToString (), "A2");
}
示例5: AppendIntegerSwitch
protected void AppendIntegerSwitch(CommandLineBuilder commandLine, string @switch, int value)
{
commandLine.AppendSwitchUnquotedIfNotNull(@switch, value.ToString(NumberFormatInfo.InvariantInfo));
}
示例6: TestAppendSwitchUnquotedIfNotNull4
public void TestAppendSwitchUnquotedIfNotNull4 ()
{
string name = "/switch:";
clb = new CommandLineBuilder ();
clb.AppendSwitchUnquotedIfNotNull (name, (ITaskItem) null);
Assert.AreEqual (String.Empty, clb.ToString (), "A1");
clb.AppendSwitchUnquotedIfNotNull (name, items [0]);
Assert.AreEqual (name + items [0].ItemSpec, clb.ToString (), "A2");
}
示例7: TestAppendSwitchUnquotedIfNotNull8
public void TestAppendSwitchUnquotedIfNotNull8 ()
{
clb = new CommandLineBuilder ();
clb.AppendSwitchUnquotedIfNotNull (null, items, "delimiter");
}
示例8: AppendIntValue
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void AppendIntValue (CommandLineBuilder builder, BaseProperty property, string value)
{
value = value.Trim ();
string switchName = m_parsedBuildRule.SwitchPrefix + property.Switch;
switchName += property.Separator;
builder.AppendSwitchUnquotedIfNotNull (switchName, value);
}
示例9: AppendSwitchWithParameterArrayNoQuotingTaskItem
public void AppendSwitchWithParameterArrayNoQuotingTaskItem()
{
CommandLineBuilder c = new CommandLineBuilder();
c.AppendSwitch("/something");
c.AppendSwitchUnquotedIfNotNull("/switch:", new TaskItem[] { new TaskItem("Mer cury.cs"), null, new TaskItem("Ve nus.cs"), new TaskItem("Ear th.cs") }, ",");
// Managed compilers use this function to append sources files.
Assert.Equal("/something /switch:Mer cury.cs,,Ve nus.cs,Ear th.cs", c.ToString());
}
示例10: AppendStringValue
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void AppendStringValue (CommandLineBuilder builder, BaseProperty property, string subtype, string value)
{
string switchName = property.SwitchPrefix;
if (string.IsNullOrEmpty (property.SwitchPrefix))
{
switchName = m_parsedBuildRule.SwitchPrefix;
}
switchName += property.Switch + property.Separator;
if (subtype == "file" || subtype == "folder")
{
if (!string.IsNullOrWhiteSpace (switchName))
{
builder.AppendSwitchIfNotNull (switchName, value);
}
else
{
builder.AppendTextUnquoted (" " + PathUtils.QuoteIfNeeded (value));
}
}
else if (!string.IsNullOrEmpty (property.Switch))
{
builder.AppendSwitchUnquotedIfNotNull (switchName, value);
}
else if (!string.IsNullOrEmpty (value))
{
builder.AppendTextUnquoted (" " + value);
}
}
示例11: AppendStringListValue
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void AppendStringListValue (CommandLineBuilder builder, BaseProperty property, string subtype, string [] value, string delimiter)
{
string switchName = m_parsedBuildRule.SwitchPrefix + property.Switch;
switchName += property.Separator;
if (subtype == "file" || subtype == "folder")
{
builder.AppendSwitchUnquotedIfNotNull (switchName, value, delimiter);
}
else if (!string.IsNullOrEmpty (property.Switch))
{
builder.AppendSwitchUnquotedIfNotNull (switchName, value, delimiter);
}
else if (value.Length > 0)
{
foreach (string entry in value)
{
builder.AppendTextUnquoted (entry + delimiter);
}
}
}
示例12: EmitStringSwitch
/// <summary>
/// Generates the switches for switches that either have literal strings appended, or have
/// different switches based on what the property is set to.
/// </summary>
/// <remarks>The string switch emits a switch that depends on what the parameter is set to, with and
/// arguments
/// e.g., Optimization = "Full" will emit /Ox, whereas Optimization = "Disabled" will emit /Od</remarks>
/// <param name="clb"></param>
/// <param name="toolSwitch"></param>
private void EmitStringSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
{
String strSwitch = String.Empty;
strSwitch += toolSwitch.SwitchValue + toolSwitch.Separator;
StringBuilder val = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
String str = toolSwitch.Value;
if (!toolSwitch.MultiValues)
{
str.Trim();
if (!str.StartsWith("\""))
{
str = "\"" + str;
if (str.EndsWith("\\") && !str.EndsWith("\\\\"))
str += "\\\"";
else
str += "\"";
}
val.Insert(0, str);
}
if ((strSwitch.Length == 0) && (val.ToString().Length == 0))
return;
clb.AppendSwitchUnquotedIfNotNull(strSwitch, val.ToString());
}
示例13: EmitFileSwitch
/// <summary>
/// Generates the switches that have filenames attached to the end
/// </summary>
/// <remarks>For file switches (e.g., PrecompiledHeaderFile), the toolSwitchName (if it exists) is emitted
/// along with the FileName which may or may not have quotes</remarks>
/// e.g., PrecompiledHeaderFile = "File" will emit /FpFile
/// <param name="clb"></param>
/// <param name="toolSwitch"></param>
private static void EmitFileSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
{
if (!String.IsNullOrEmpty(toolSwitch.Value))
{
String str = toolSwitch.Value;
str.Trim();
if (!str.StartsWith("\""))
{
str = "\"" + str;
if (str.EndsWith("\\") && !str.EndsWith("\\\\"))
str += "\\\"";
else
str += "\"";
}
//we want quotes always, AppendSwitchIfNotNull will add them on as needed bases
clb.AppendSwitchUnquotedIfNotNull(toolSwitch.SwitchValue + toolSwitch.Separator, str);
}
}
示例14: EmitStringSwitch
/// <summary>
/// Generates the switches for switches that either have literal strings appended, or have
/// different switches based on what the property is set to.
/// </summary>
/// <remarks>The string switch emits a switch that depends on what the parameter is set to, with and
/// arguments
/// e.g., Optimization = "Full" will emit /Ox, whereas Optimization = "Disabled" will emit /Od</remarks>
private void EmitStringSwitch(CommandLineBuilder clb, CommandLineToolSwitch commandLineToolSwitch)
{
if (PerformSwitchValueSubstition(clb, commandLineToolSwitch, commandLineToolSwitch.Value))
{
return;
}
String strSwitch = String.Empty;
strSwitch += commandLineToolSwitch.SwitchValue + commandLineToolSwitch.Separator;
String str = commandLineToolSwitch.Value;
if (!commandLineToolSwitch.AllowMultipleValues)
{
str = str.Trim();
if (str.Contains(' '))
{
if (!str.StartsWith("\"", StringComparison.OrdinalIgnoreCase))
{
str = "\"" + str;
if (str.EndsWith(@"\", StringComparison.OrdinalIgnoreCase) && !str.EndsWith(@"\\", StringComparison.OrdinalIgnoreCase))
{
str += "\\\"";
}
else
{
str += "\"";
}
}
}
}
else
{
strSwitch = String.Empty;
str = commandLineToolSwitch.SwitchValue;
string arguments = GatherArguments(commandLineToolSwitch.Name, commandLineToolSwitch.Arguments, commandLineToolSwitch.Separator);
if (!String.IsNullOrEmpty(arguments))
{
str = str + commandLineToolSwitch.Separator + arguments;
}
}
clb.AppendSwitchUnquotedIfNotNull(strSwitch, str);
}
示例15: TestAppendSwitchUnquotedIfNotNull2
public void TestAppendSwitchUnquotedIfNotNull2 ()
{
string name = "/switch:";
string parameter = "parameter";
clb = new CommandLineBuilder ();
clb.AppendSwitchUnquotedIfNotNull (name, (string) null);
Assert.AreEqual (String.Empty, clb.ToString (), "A1");
clb.AppendSwitchUnquotedIfNotNull (name, parameter);
Assert.AreEqual (name + parameter, clb.ToString (), "A2");
}