public void SetValue(string value, bool preserveCase = false, bool mergeToMainGroup = false) { AssertCanModify(); MergeToMainGroup = mergeToMainGroup; this.preserverCase = preserveCase; valueType = preserveCase ? MSBuildValueType.Default : MSBuildValueType.DefaultPreserveCase; if (value == null) { value = String.Empty; } if (preserveCase) { var current = GetPropertyValue(); if (current != null) { if (current.Equals(value, preserveCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture)) { return; } } } SetPropertyValue(value); if (ParentProject != null && NotifyChanges) { ParentProject.NotifyChanged(); } }
public void SetValue(FilePath value, bool relativeToProject = true, FilePath relativeToPath = default(FilePath), bool mergeToMainGroup = false) { AssertCanModify(); MergeToMainGroup = mergeToMainGroup; valueType = MSBuildValueType.Path; string baseDir = null; if (relativeToPath != null) { baseDir = relativeToPath; } else if (relativeToProject) { if (ParentProject == null) { // The project has not been set, so we can't calculate the relative path. // Store the full path for now, and set the property type to UnresolvedPath. // When the property gets a value, the relative path will be calculated valueType = MSBuildValueType.UnresolvedPath; SetPropertyValue(value.ToString()); return; } baseDir = ParentProject.BaseDirectory; } // If the path is normalized in the property, keep the value if (!string.IsNullOrEmpty(Value) && new FilePath(MSBuildProjectService.FromMSBuildPath(baseDir, Value)).CanonicalPath == value.CanonicalPath) { return; } SetPropertyValue(MSBuildProjectService.ToMSBuildPath(baseDir, value, false)); }
public void SetValue(object value, bool mergeToMainGroup = false) { AssertCanModify(); if (value is bool) { if (Owner != null && Owner.UppercaseBools) { SetValue((bool)value ? "True" : "False", preserveCase: true, mergeToMainGroup: mergeToMainGroup); } else { SetValue((bool)value ? "true" : "false", preserveCase: true, mergeToMainGroup: mergeToMainGroup); } valueType = MSBuildValueType.Boolean; } else { SetValue(Convert.ToString(value, CultureInfo.InvariantCulture), false, mergeToMainGroup); } }
public void SetValue(string value, bool preserveCase = false, bool mergeToMainGroup = false, MSBuildValueType valueType = null) { AssertCanModify(); // If no value type is specified, use the default if (valueType == null) { valueType = preserveCase ? MSBuildValueType.DefaultPreserveCase : MSBuildValueType.Default; } MergeToMainGroup = mergeToMainGroup; this.valueType = valueType; if (value == null) { value = String.Empty; } SetPropertyValue(value); }
public void SetValue(string name, string value, string defaultValue = null, bool preserveExistingCase = false, bool mergeToMainGroup = false, string condition = null, MSBuildValueType valueType = null) { AssertCanModify(); // If no value type is specified, use the default if (valueType == null) { valueType = preserveExistingCase ? MSBuildValueType.DefaultPreserveCase : MSBuildValueType.Default; } if (value == null && defaultValue == "") { value = ""; } var prop = GetProperty(name, condition); var isDefault = value == defaultValue; if (isDefault && !mergeToMainGroup) { // if the value is default, only remove the property if it was not already the default // to avoid unnecessary project file churn if (prop != null && valueType.Equals(defaultValue ?? "", prop.Value)) { return; } if (!IgnoreDefaultValues) { if (prop != null) { RemoveProperty(prop); } return; } } if (prop == null) { prop = AddProperty(name, condition); } prop.SetValue(value, preserveExistingCase, mergeToMainGroup, valueType); prop.HasDefaultValue = isDefault; }
void IPropertySet.SetValue(string name, string value, string defaultValue, bool preserveExistingCase, bool mergeToMainGroup, string condition, MSBuildValueType valueType) { AssertLinkedToGroup(); LinkedGroup.SetValue(name, value, defaultValue, preserveExistingCase, mergeToMainGroup, condition, valueType); }
void IMetadataProperty.SetValue (string value, bool preserveCase, bool mergeToMainGroup, MSBuildValueType valueType) { if (linkedProperty == null) throw new InvalidOperationException ("Evaluated property can't be modified"); linkedProperty.SetValue (value, preserveCase, mergeToMainGroup, valueType); }
public MergedProperty(string name, MSBuildValueType valueType, bool isDefault) { this.Name = name; IsDefault = isDefault; ValueType = valueType; }
public MergedProperty (string name, MSBuildValueType valueType, bool isDefault) { this.Name = name; IsDefault = isDefault; ValueType = valueType; }
public void SetValue (object value, bool mergeToMainGroup = false) { AssertCanModify (); if (value is bool) { if (Owner != null && Owner.UppercaseBools) SetValue ((bool)value ? "True" : "False", preserveCase: true, mergeToMainGroup: mergeToMainGroup); else SetValue ((bool)value ? "true" : "false", preserveCase: true, mergeToMainGroup: mergeToMainGroup); valueType = MSBuildValueType.Boolean; } else SetValue (Convert.ToString (value, CultureInfo.InvariantCulture), false, mergeToMainGroup); }
public void SetValue (FilePath value, bool relativeToProject = true, FilePath relativeToPath = default(FilePath), bool mergeToMainGroup = false) { AssertCanModify (); MergeToMainGroup = mergeToMainGroup; valueType = MSBuildValueType.Path; string baseDir = null; if (relativeToPath != null) { baseDir = relativeToPath; } else if (relativeToProject) { if (ParentProject == null) { // The project has not been set, so we can't calculate the relative path. // Store the full path for now, and set the property type to UnresolvedPath. // When the property gets a value, the relative path will be calculated valueType = MSBuildValueType.UnresolvedPath; SetPropertyValue (value.ToString ()); return; } baseDir = ParentProject.BaseDirectory; } // If the path is normalized in the property, keep the value if (!string.IsNullOrEmpty (Value) && new FilePath (MSBuildProjectService.FromMSBuildPath (baseDir, Value)).CanonicalPath == value.CanonicalPath) return; SetPropertyValue (MSBuildProjectService.ToMSBuildPath (baseDir, value, false)); }
public void SetValue (string value, bool preserveCase = false, bool mergeToMainGroup = false, MSBuildValueType valueType = null) { AssertCanModify (); // If no value type is specified, use the default if (valueType == null) valueType = preserveCase ? MSBuildValueType.DefaultPreserveCase : MSBuildValueType.Default; MergeToMainGroup = mergeToMainGroup; this.valueType = valueType; if (value == null) value = String.Empty; SetPropertyValue (value); }
void IMetadataProperty.SetValue(string value, bool preserveCase, bool mergeToMainGroup, MSBuildValueType valueType) { if (linkedProperty == null) { throw new InvalidOperationException("Evaluated property can't be modified"); } linkedProperty.SetValue(value, preserveCase, mergeToMainGroup, valueType); }
public void SetValue (string value, bool preserveCase = false, bool mergeToMainGroup = false) { AssertCanModify (); MergeToMainGroup = mergeToMainGroup; this.preserverCase = preserveCase; valueType = preserveCase ? MSBuildValueType.Default : MSBuildValueType.DefaultPreserveCase; if (value == null) value = String.Empty; if (preserveCase) { var current = GetPropertyValue (); if (current != null) { if (current.Equals (value, preserveCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture)) return; } } SetPropertyValue (value); if (ParentProject != null && NotifyChanges) ParentProject.NotifyChanged (); }