using System.Text;
using System.Xml;
+using Microsoft.Build.Framework;
+
namespace Microsoft.Build.BuildEngine {
public class BuildProperty {
Project parentProject;
PropertyType propertyType;
- private BuildProperty ()
+ BuildProperty ()
{
}
: this (propertyName, propertyValue, PropertyType.Normal)
{
if (propertyName == null)
- throw new ArgumentNullException (null,
- "Parameter \"propertyName\" cannot be null.");
+ throw new ArgumentNullException ("propertyName");
if (propertyValue == null)
- throw new ArgumentNullException (null,
- "Parameter \"propertyValue\" cannot be null.");
+ throw new ArgumentNullException ("propertyValue");
}
internal BuildProperty (string propertyName,
this.propertyType = PropertyType.Normal;
this.parentProject = parentProject;
this.name = propertyElement.Name;
- this.value = propertyElement.InnerText;
+ this.value = propertyElement.InnerXml;
this.isImported = false;
}
public static explicit operator string (BuildProperty propertyToCast)
{
if (propertyToCast == null)
- throw new ArgumentNullException ("propertyToCast");
- return propertyToCast.ToString ();
+ return String.Empty;
+ else
+ return propertyToCast.ToString ();
}
public override string ToString ()
internal void Evaluate ()
{
- if (FromXml) {
- OldExpression exp = new OldExpression (parentProject);
- exp.ParseSource (Value);
- finalValue = (string) exp.ConvertTo (typeof (string));
- parentProject.EvaluatedProperties.AddProperty (this);
- }
+ BuildProperty evaluated = new BuildProperty (Name, Value);
+
+ Expression exp = new Expression ();
+ exp.Parse (Value, false, false);
+ evaluated.finalValue = (string) exp.ConvertTo (parentProject, typeof (string));
+
+ parentProject.EvaluatedProperties.AddProperty (evaluated);
+ }
+
+ internal string ConvertToString (Project project)
+ {
+ Expression exp = new Expression ();
+ exp.Parse (Value, true, false);
+
+ return (string) exp.ConvertTo (project, typeof (string));
+ }
+
+ internal ITaskItem[] ConvertToITaskItemArray (Project project)
+ {
+ Expression exp = new Expression ();
+ exp.Parse (Value, true, false);
+
+ return (ITaskItem[]) exp.ConvertTo (project, typeof (ITaskItem[]));
}
- private bool FromXml {
+ internal bool FromXml {
get {
return propertyElement != null;
}
set {
if (FromXml)
propertyElement.SetAttribute ("Condition", value);
+ else
+ throw new InvalidOperationException ("Cannot set a condition on an object not represented by an XML element in the project file.");
}
}
set {
this.@value = value;
if (FromXml) {
- propertyElement.InnerText = value;
+ propertyElement.InnerXml = value;
} else {
finalValue = value;
}
return propertyType;
}
}
+
+ internal XmlElement XmlElement {
+ get { return propertyElement; }
+ }
}
internal enum PropertyType {