本文整理汇总了C#中Microsoft.Build.BuildEngine.BuildPropertyGroup.AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C# BuildPropertyGroup.AddProperty方法的具体用法?C# BuildPropertyGroup.AddProperty怎么用?C# BuildPropertyGroup.AddProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.BuildPropertyGroup
的用法示例。
在下文中一共展示了BuildPropertyGroup.AddProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildProjectFile
public bool BuildProjectFile (string projectFileName,
string[] targetNames,
IDictionary globalProperties,
IDictionary targetOutputs, string toolsVersion)
{
if (String.IsNullOrEmpty (projectFileName)) {
string oldProjectToolsVersion = project.ToolsVersion;
project.ToolsVersion = toolsVersion;
try {
return engine.BuildProject (project, targetNames, targetOutputs,
BuildSettings.DoNotResetPreviouslyBuiltTargets);
} finally {
project.ToolsVersion = oldProjectToolsVersion;
}
} else {
BuildPropertyGroup bpg = new BuildPropertyGroup ();
if (globalProperties != null)
foreach (DictionaryEntry de in globalProperties)
bpg.AddProperty (new BuildProperty (
(string) de.Key, (string) de.Value,
PropertyType.Global));
return engine.BuildProjectFile (projectFileName,
targetNames, bpg, targetOutputs, BuildSettings.DoNotResetPreviouslyBuiltTargets, toolsVersion);
}
}
示例2: Clone
public BuildPropertyGroup Clone (bool deepClone)
{
BuildPropertyGroup bpg = new BuildPropertyGroup (propertyGroup, parentProject, importedProject, read_only);
if (FromXml) {
foreach (BuildProperty bp in properties) {
if (deepClone)
bpg.AddProperty (bp.Clone (true));
else
bpg.AddNewProperty (bp.Name, bp.FinalValue);
}
} else {
foreach (BuildProperty bp in propertiesByName.Values) {
if (deepClone)
bpg.AddProperty (bp.Clone (true));
else
bpg.AddNewProperty (bp.Name, bp.FinalValue);
}
}
return bpg;
}
示例3: MustBeVirtual
/// <summary>
/// This method creates a copy of the BuildPropertyGroup. A shallow clone will reference the same BuildProperty objects as the
/// original. A deep clone will deep clone the BuildProperty objects themselves. If this is a persisted BuildPropertyGroup, only
/// deep clones are allowed, because you can't have the same XML element belonging to two parents.
/// </summary>
/// <owner>RGoel</owner>
/// <param name="deepClone"></param>
/// <returns>The cloned BuildPropertyGroup.</returns>
public BuildPropertyGroup Clone
(
bool deepClone
)
{
BuildPropertyGroup clone;
if (IsVirtual)
{
// This is a virtual BuildPropertyGroup.
MustBeVirtual("NeedVirtualPropertyGroup");
if (deepClone)
{
// Loop through every BuildProperty in our collection, and add those same properties
// to the cloned collection.
// Create a new virtual BuildPropertyGroup.
// Do not set the ParentProject on the new BuildPropertyGroup, because it isn't really
// part of the project
clone = new BuildPropertyGroup(null, propertyTableByName.Count);
foreach (DictionaryEntry propertyEntry in this.propertyTableByName)
{
// If the caller requested a deep clone, then deep clone the BuildProperty object,
// and add the new BuildProperty to the new BuildPropertyGroup.
clone.propertyTableByName.Add(propertyEntry.Key, ((BuildProperty)propertyEntry.Value).Clone(true /* deep clone */));
}
// also clone over any overridden non-output properties
if (this.propertiesOverriddenByOutputProperties != null)
{
clone.propertiesOverriddenByOutputProperties = new CopyOnWriteHashtable(propertiesOverriddenByOutputProperties.Count, StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry propertyEntry in this.propertiesOverriddenByOutputProperties)
{
if (propertyEntry.Value != null)
{
clone.propertiesOverriddenByOutputProperties.Add(propertyEntry.Key, ((BuildProperty)propertyEntry.Value).Clone(true /* deep clone */));
}
else
{
clone.propertiesOverriddenByOutputProperties.Add(propertyEntry.Key, null);
}
}
}
}
else
{
// shallow cloning is easy, we only clone the Hashtables
clone = new BuildPropertyGroup();
clone.propertyTableByName = (CopyOnWriteHashtable)this.propertyTableByName.Clone();
if (this.propertiesOverriddenByOutputProperties != null)
{
clone.propertiesOverriddenByOutputProperties = (CopyOnWriteHashtable)this.propertiesOverriddenByOutputProperties.Clone();
}
}
}
else
{
// This is a persisted <PropertyGroup>.
MustBePersisted("NeedPersistedPropertyGroup", XMakeElements.propertyGroup);
// Only deep clones are permitted when dealing with a persisted <PropertyGroup>.
// This is because a shallow clone would attempt to add the same property
// elements to two different parent <PropertyGroup> elements, and this is
// not allowed.
error.VerifyThrowInvalidOperation(deepClone, "ShallowCloneNotAllowed");
// Create a new persisted <PropertyGroup>. It won't actually get added
// to any XmlDocument, but it will be associated with the same XmlDocument
// as the current BuildPropertyGroup.
clone = new BuildPropertyGroup
(
null, /* Do not set the ParentProject on the cloned BuildPropertyGroup, because it isn't really
part of the project */
ownerDocument,
this.importedFromAnotherProject
);
// Loop through every BuildProperty in our collection, and add those same properties
// to the cloned collection.
foreach (BuildProperty property in this)
{
// If the caller requested a deep clone, then deep clone the BuildProperty object,
// and add the new BuildProperty to the new BuildPropertyGroup. Otherwise, just add
// a reference to the existing BuildProperty object to the new BuildPropertyGroup.
clone.AddProperty(property.Clone(true));
}
clone.Condition = this.Condition;
//.........这里部分代码省略.........