本文整理汇总了C#中NAnt.Core.PropertyDictionary类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDictionary类的具体用法?C# PropertyDictionary怎么用?C# PropertyDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDictionary类属于NAnt.Core命名空间,在下文中一共展示了PropertyDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConditionalConfigurator
public ConditionalConfigurator(ConditionalElement element, XmlNode elementNode, PropertyDictionary properties, FrameworkInfo targetFramework)
: base(element, elementNode, properties, targetFramework)
{
Type currentType = element.GetType();
PropertyInfo ifdefined = currentType.GetProperty("IfDefined",
BindingFlags.NonPublic | BindingFlags.Instance);
InitializeAttribute(ifdefined);
if (!element.IfDefined) {
_enabled = false;
} else {
PropertyInfo unlessDefined = currentType.GetProperty(
"UnlessDefined",
BindingFlags.NonPublic | BindingFlags.Instance);
InitializeAttribute(unlessDefined);
_enabled = !element.UnlessDefined;
}
if (!_enabled) {
// since we will not be processing other attributes or
// child nodes, clear these collections to avoid
// errors for unrecognized attributes/elements
UnprocessedAttributes.Clear();
UnprocessedChildNodes.Clear();
}
}
示例2: ExpressionEvaluator
/// <summary>
/// Initializes a new instance of the <see cref="ExpressionEvaluator"/> class.
/// </summary>
/// <param name="project">The project.</param>
/// <param name="properties">The projects properties.</param>
/// <param name="state">The state.</param>
/// <param name="visiting">The visiting.</param>
public ExpressionEvaluator(Project project, PropertyDictionary properties, Hashtable state, Stack visiting)
: base(project)
{
_properties = properties;
_state = state;
_visiting = visiting;
}
示例3: Adds_value_by_key_if_key_does_not_exists
public void Adds_value_by_key_if_key_does_not_exists()
{
PropertyDictionary properties = new PropertyDictionary(null);
PropertyDictionaryHelper.AddOrUpdateInt(properties, Key, Value);
Assert.AreEqual(int.Parse(properties[Key], CultureInfo.InvariantCulture), Value);
}
示例4: Adds_key_if_key_does_not_exists
public void Adds_key_if_key_does_not_exists()
{
PropertyDictionary properties = new PropertyDictionary(null);
PropertyDictionaryHelper.AddOrUpdateInt(properties, Key, Value);
Assert.IsNotNull(properties[Key]);
}
示例5: InitializeXml
protected override void InitializeXml(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework)
{
XmlNode = elementNode;
ConditionalConfigurator configurator = new ConditionalConfigurator(
this, elementNode, properties, framework);
configurator.Initialize();
}
示例6: 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);
}
示例7: 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]);
}
示例8: 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);
}
示例9: Test_NullPropertyTest
public void Test_NullPropertyTest()
{
const string xml = "<project><property name='temp.var' value='some.value'/></project>";
Project p = CreateFilebasedProject(xml);
PropertyDictionary d = new PropertyDictionary(p);
TestDelegate assn = delegate() { d["temp.var"] = null; };
Assert.Throws<BuildException>(assn,
"Null values should not be allowed in PropertyDictionary");
}
示例10: AddOrUpdateInt
public static void AddOrUpdateInt(PropertyDictionary instance, string key, int value)
{
Ensure.ArgumentIsNotNull(instance, "instance");
Ensure.ArgumentIsNotNullOrEmptyString(key, "key");
int parsedValue;
if (!int.TryParse(instance[key], out parsedValue))
{
parsedValue = 0;
}
parsedValue += value;
instance[key] = parsedValue.ToString(CultureInfo.InvariantCulture);
}
示例11: RestoreProperties
private static void RestoreProperties(ArrayList attributeList, Task task, PropertyDictionary oldValues)
{
PropertyDictionary projectProperties = task.Project.Properties;
foreach (MacroAttribute macroAttribute in attributeList)
{
string localPropertyName = macroAttribute.LocalPropertyName;
string oldValue = oldValues[localPropertyName];
if (projectProperties.Contains(localPropertyName))
projectProperties.Remove(localPropertyName);
if (oldValue != null)
projectProperties.Add(localPropertyName, oldValue);
}
}
示例12: 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);
}
}
示例13: Execute
public void Execute()
{
task.Log(Level.Verbose, "Running '" + name + "'");
task.Project.Indent();
try
{
PropertyDictionary oldPropertyValues = new PropertyDictionary(null);
if (attributeList != null)
SetUpProperties(attributeList, task, invocationXml, oldPropertyValues);
if (sequential != null)
{
XmlNode invocationTasks = CreateInvocationTasks();
ExecuteInvocationTasks(invocationTasks);
}
RestoreProperties(attributeList, task, oldPropertyValues);
}
finally
{
task.Project.Unindent();
}
}
示例14: CreateChildBuildElement
/// <summary>
/// Creates a child <see cref="Element" /> using property set/get methods.
/// </summary>
/// <param name="propInf">The <see cref="PropertyInfo" /> instance that represents the property of the current class.</param>
/// <param name="getter">A <see cref="MethodInfo" /> representing the get accessor for the property.</param>
/// <param name="setter">A <see cref="MethodInfo" /> representing the set accessor for the property.</param>
/// <param name="xml">The <see cref="XmlNode" /> used to initialize the new <see cref="Element" /> instance.</param>
/// <param name="properties">The collection of property values to use for macro expansion.</param>
/// <param name="framework">The <see cref="FrameworkInfo" /> from which to obtain framework-specific information.</param>
/// <returns>The <see cref="Element" /> child.</returns>
private Element CreateChildBuildElement(PropertyInfo propInf, MethodInfo getter, MethodInfo setter, XmlNode xml, PropertyDictionary properties, FrameworkInfo framework)
{
Element childElement = null;
Type elementType = null;
// if there is a getter, then get the current instance of the object, and use that
if (getter != null) {
try {
childElement = (Element) propInf.GetValue(Element, null);
} catch (InvalidCastException) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1188"),
propInf.Name, Element.GetType().FullName, propInf.PropertyType.FullName,
typeof(Element).FullName), Location);
}
if (childElement == null) {
if (setter == null) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1189"), propInf.Name,
Element.GetType().FullName), Location);
} else {
// fake the getter as null so we process the rest like there is no getter
getter = null;
logger.Info(string.Format(CultureInfo.InvariantCulture,"{0}_get() returned null; will go the route of set method to populate.", propInf.Name));
}
} else {
elementType = childElement.GetType();
}
}
// create a new instance of the object if there is no get method
// or the get object returned null
if (getter == null) {
elementType = setter.GetParameters()[0].ParameterType;
if (elementType.IsAbstract) {
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("String_AbstractType"), elementType.Name, propInf.Name, Name));
}
childElement = (Element) Activator.CreateInstance(elementType, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, null , CultureInfo.InvariantCulture);
}
// initialize the child element
childElement = Element.InitializeBuildElement(Element, xml, childElement, elementType);
// check if we're dealing with a reference to a data type
DataTypeBase dataType = childElement as DataTypeBase;
if (dataType != null && xml.Attributes["refid"] != null) {
// references to data type should be always be set
if (setter == null) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1190"),
propInf.Name, this.GetType().FullName), Location);
}
// re-set the getter (for force the setter to be used)
getter = null;
}
// call the set method if we created the object
if (setter != null && getter == null) {
setter.Invoke(Element, new object[] {childElement});
}
// return the new/used object
return childElement;
}
示例15: Initialize
/// <summary>
/// Performs initialization using the given set of properties.
/// </summary>
internal void Initialize(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework)
{
if (Project == null) {
throw new InvalidOperationException("Element has invalid Project property.");
}
// save position in buildfile for reporting useful error messages.
try {
_location = Project.LocationMap.GetLocation(elementNode);
} catch (ArgumentException ex) {
logger.Warn("Location of Element node could be located.", ex);
}
InitializeXml(elementNode, properties, framework);
// allow inherited classes a chance to do some custom initialization
InitializeElement(elementNode);
Initialize();
}