/// <summary> /// adds a new tagged value to the element with the given name and value /// if a tagged value with that name already exists the value of the existing tagged value is updated./ /// </summary> /// <param name="name">the name of the tagged value to add</param> /// <param name="tagValue">the value of the tagged value</param> /// <param name = "comment">the comment to add to the tagged value</param> /// <param name = "addDuplicate"></param> /// <returns>the added (or updated) tagged value</returns> public virtual TaggedValue addTaggedValue(string name, string tagValue, string comment = null, bool addDuplicate = false) { TaggedValue newTaggedValue = null; if (!addDuplicate) { //we don't wan't any duplicates so we get the existing one newTaggedValue = this.getTaggedValue(name); } else { //we allow "duplicate" tagged values, but only if the value is different. newTaggedValue = this.taggedValues.FirstOrDefault(x => x.name.Equals(name, StringComparison.InvariantCultureIgnoreCase) && ((TaggedValue)x).eaStringValue.Equals(tagValue, StringComparison.InvariantCultureIgnoreCase)) as TaggedValue; } if (newTaggedValue == null) { //no existing tagged value found, or we need to create duplicates newTaggedValue = (TaggedValue)this.EAModel.factory.createNewTaggedValue(this, name); //add it to the local list of tagged values if (_taggedValues != null) { _taggedValues.Add(newTaggedValue); } } newTaggedValue.tagValue = tagValue; if (comment != null) { newTaggedValue.comment = comment; } newTaggedValue.save(); return(newTaggedValue); }
/// <summary> /// adds a new tagged value to the element with the given name and value /// if a tagged value with that name already exists the value of the existing tagged value is updated./ /// </summary> /// <param name="name">the name of the tagged value to add</param> /// <param name="tagValue">the value of the tagged value</param> /// <param name = "comment">the comment to add to the tagged value</param> /// <param name = "addDuplicate"></param> /// <returns>the added (or updated) tagged value</returns> public virtual TaggedValue addTaggedValue(string name, string tagValue, string comment = null, bool addDuplicate = false) { TaggedValue newTaggedValue = null; if (!addDuplicate) { //we don't wan't any duplicates so we get the existing one newTaggedValue = this.getTaggedValue(name); } if (newTaggedValue == null) { //no existing tagged value found, or we need to create duplicates newTaggedValue = (TaggedValue)this.model.factory.createNewTaggedValue(this, name); //add it to the local list of tagged values if (_taggedValues != null) { _taggedValues.Add(newTaggedValue); } } newTaggedValue.tagValue = tagValue; if (comment != null) { newTaggedValue.comment = comment; } newTaggedValue.save(); return(newTaggedValue); }
/// <summary> /// adds a new tagged value to the element with the given name and value /// if a tagged value with that name already exists the value of the existing tagged value is updated./ /// </summary> /// <param name="name">the name fo the tagged value to add</param> /// <param name="tagValue">the value of the tagged value</param> /// <param name = "addDuplicate"></param> /// <returns>the added (or updated) tagged value</returns> public virtual TaggedValue addTaggedValue(string name, string tagValue, bool addDuplicate = false) { TaggedValue newTaggedValue = null; if (!addDuplicate) { //we don't wan't any duplicates so we get the existing one newTaggedValue = this.getTaggedValue(name); } if (newTaggedValue == null) { //no existing tagged value found, or we need to create duplicates newTaggedValue = (TaggedValue)this.model.factory.createNewTaggedValue(this, name); } newTaggedValue.tagValue = tagValue; newTaggedValue.save(); return(newTaggedValue); }