當前位置: 首頁>>代碼示例>>C#>>正文


C# PropertyDictionary.Add方法代碼示例

本文整理匯總了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);
        }
開發者ID:stephen-czetty,項目名稱:nant-extensions,代碼行數:9,代碼來源:When_properties_are_added_or_updated.cs

示例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]);
        }
開發者ID:stephen-czetty,項目名稱:nant-extensions,代碼行數:9,代碼來源:When_properties_are_set.cs

示例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);
        }
開發者ID:stephen-czetty,項目名稱:nant-extensions,代碼行數:9,代碼來源:When_properties_are_set.cs

示例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);
			}
		}
開發者ID:Orvid,項目名稱:NAntUniversalTasks,代碼行數:15,代碼來源:PropertyDictionaryHelper.cs

示例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());
        }
開發者ID:harib,項目名稱:macrodef,代碼行數:40,代碼來源:MacroDefInvocation.cs


注:本文中的NAnt.Core.PropertyDictionary.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。