本文整理汇总了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());
}