/// <summary> /// Applies the value changes created by the constructor to the underlying object, using the requested modification type to define how to apply the new values /// </summary> /// <param name="hologram">The object to apply the changes to</param> /// <param name="valueChanges">The value changes to apply</param> /// <param name="modificationType">The type of modification to apply to the object</param> protected void ApplyValueChanges(MAObjectHologram hologram, IList <ValueChange> valueChanges, AcmaAttributeModificationType modificationType) { switch (modificationType) { case AcmaAttributeModificationType.Add: hologram.UpdateAttributeValue(this.Attribute, valueChanges); break; case AcmaAttributeModificationType.Replace: hologram.SetAttributeValue(this.Attribute, valueChanges.Select(t => t.Value).ToList <object>()); break; case AcmaAttributeModificationType.Delete: hologram.UpdateAttributeValue(this.Attribute, valueChanges); break; default: throw new InvalidOperationException("The specified modification type is unsupported for this constructor"); } }
/// <summary> /// Removes a reference to the source object on the specified target object /// </summary> /// <param name="sourceObject">The object to remove the reference to</param> /// <param name="targetObject">The object to remove the reference from</param> private void RemoveReference(MAObjectHologram sourceObject, MAObjectHologram targetObject) { if (this.BackLinkAttribute.IsMultivalued) { targetObject.UpdateAttributeValue(this.BackLinkAttribute, new List <ValueChange>() { ValueChange.CreateValueDelete(sourceObject.ObjectID) }); } else { targetObject.DeleteAttribute(this.BackLinkAttribute); } }
/// <summary> /// Adds a reference to the source object on the specified target object /// </summary> /// <param name="sourceObject">The object to add a reference to</param> /// <param name="targetObject">The object to add the reference on</param> private void AddReference(MAObjectHologram sourceObject, MAObjectHologram targetObject) { if (this.BackLinkAttribute.IsMultivalued) { if (!targetObject.HasAttributeValue(this.BackLinkAttribute, sourceObject.ObjectID)) { targetObject.UpdateAttributeValue(this.BackLinkAttribute, new List <ValueChange>() { ValueChange.CreateValueAdd(sourceObject.ObjectID) }); } } else { targetObject.SetAttributeValue(this.BackLinkAttribute, sourceObject.ObjectID); } }