本文整理匯總了C#中NAnt.Core.PropertyDictionary.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# PropertyDictionary.Add方法的具體用法?C# PropertyDictionary.Add怎麽用?C# PropertyDictionary.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NAnt.Core.PropertyDictionary
的用法示例。
在下文中一共展示了PropertyDictionary.Add方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Adds_value_to_existing_key_value
public void Adds_value_to_existing_key_value()
{
PropertyDictionary properties = new PropertyDictionary(null);
properties.Add(Key, ExistingValue.ToString());
PropertyDictionaryHelper.AddOrUpdateInt(properties, Key, Value);
Assert.AreEqual(int.Parse(properties[Key], CultureInfo.InvariantCulture), Value + ExistingValue);
}
示例2: Replaces_key_if_key_does_exists
public void Replaces_key_if_key_does_exists()
{
PropertyDictionary properties = new PropertyDictionary(null);
properties.Add(Key, ExistingValue.ToString());
PropertyDictionaryHelper.SetInt(properties, Key, Value);
Assert.IsNotNull(properties[Key]);
}
示例3: Replaces_value_by_key_if_key_does_exists
public void Replaces_value_by_key_if_key_does_exists()
{
PropertyDictionary properties = new PropertyDictionary(null);
properties.Add(Key, ExistingValue.ToString());
PropertyDictionaryHelper.SetInt(properties, Key, Value);
Assert.AreEqual(int.Parse(properties[Key], CultureInfo.InvariantCulture), Value);
}
示例4: SetInt
public static void SetInt(PropertyDictionary instance, string key, int value)
{
Ensure.ArgumentIsNotNull(instance, "instance");
Ensure.ArgumentIsNotNullOrEmptyString(key, "key");
string valueToSet = value.ToString(CultureInfo.InvariantCulture);
if (instance.Contains(key))
{
instance[key] = valueToSet;
}
else
{
instance.Add(key, valueToSet);
}
}
示例5: SetUpProperties
private static void SetUpProperties(ArrayList attributeList, Task task, XmlNode xml,
PropertyDictionary oldPropertyValues)
{
PropertyDictionary projectProperties = task.Project.Properties;
StringBuilder logMessage = new StringBuilder();
foreach (MacroAttribute macroAttribute in attributeList)
{
string attributeName = macroAttribute.name;
XmlAttribute xmlAttribute = xml.Attributes[attributeName];
string value = null;
if (xmlAttribute != null)
{
value = projectProperties.ExpandProperties(xmlAttribute.Value, null);
}
else if (macroAttribute.defaultValue != null)
{
value = macroAttribute.defaultValue;
}
string localPropertyName = macroAttribute.LocalPropertyName;
task.Log(Level.Debug, "Setting property " + localPropertyName + " to " + value);
if (logMessage.Length > 0)
logMessage.Append(", ");
logMessage.Append(localPropertyName);
logMessage.Append(" = '");
logMessage.Append(value);
logMessage.Append("'");
if (projectProperties.Contains(localPropertyName))
{
oldPropertyValues.Add(localPropertyName, projectProperties[localPropertyName]);
projectProperties.Remove(localPropertyName);
}
if (value != null)
projectProperties.Add(localPropertyName, value);
}
task.Log(Level.Info, logMessage.ToString());
}