private void SetSingleValuedAttribute(PSPropertyInfo property, object value) { AcmaPSObject resourceValue = property.Value as AcmaPSObject; if (resourceValue != null) { this.Hologram.SetAttributeValue(ActiveConfig.DB.GetAttribute(property.Name), resourceValue.Hologram.ObjectID); } else { this.Hologram.SetAttributeValue(ActiveConfig.DB.GetAttribute(property.Name), value); } }
public override void Remove(object obj) { if (base.Contains(obj)) { // obj is already a unique identifier base.Remove(obj); return; } AcmaPSObject rmaObject = obj as AcmaPSObject; if (rmaObject != null) { // obj is an existing object base.Remove(rmaObject); return; } }
private void SetMultivaluedAttribute(PSPropertyInfo property, IList resourceValues) { List <object> newValues = new List <object>(); foreach (object value in resourceValues) { AcmaPSObject resourceValue = value as AcmaPSObject; if (resourceValue != null) { newValues.Add(resourceValue.Hologram.ObjectID); } else { newValues.Add(this.UnwrapPSObject(value)); } } this.Hologram.SetAttributeValue(ActiveConfig.DB.GetAttribute(property.Name), newValues); }
protected override void ProcessRecord() { Global.ThrowIfNotConnected(this); try { AcmaPSObject maobject; if (this.AcmaObject == null) { maobject = new AcmaPSObject(ActiveConfig.DB.GetMAObjectOrDefault(this.ID)); } else { maobject = this.AcmaObject; } if (maobject == null) { ErrorRecord error = new ErrorRecord(new NotFoundException(), "ObjectNotFound", ErrorCategory.ObjectNotFound, this.ID); ThrowTerminatingError(error); } maobject.Hologram.SetObjectModificationType(TriggerEvents.Delete); maobject.Hologram.CommitCSEntryChange(); if (this.ForceDelete) { ActiveConfig.DB.DeleteMAObjectPermanent(maobject.Hologram.ObjectID); } } catch (Exception ex) { ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, this.ID); ThrowTerminatingError(error); } }