private void SetSingleValuedAttribute(PSPropertyInfo property, object value) { RmaObject resourceValue = property.Value as RmaObject; if (resourceValue != null) { this.InternalObject.Attributes[property.Name].SetValue(resourceValue.InternalObject.ObjectID); } else { this.InternalObject.Attributes[property.Name].SetValue(this.UnwrapPSObject(property.Value)); } }
public override int Add(object value) { RmaObject rmaObject = value as RmaObject; if (rmaObject != null) { // obj is an existing object return(base.Add(rmaObject.InternalObject.ObjectID)); } else { return(base.Add(value)); } }
private void SetMultivaluedAttribute(PSPropertyInfo property, IEnumerable <object> resourceValues) { List <object> newValues = new List <object>(); foreach (object value in resourceValues) { RmaObject resourceValue = value as RmaObject; if (resourceValue != null) { newValues.Add(resourceValue.InternalObject.ObjectID); } else { newValues.Add(this.UnwrapPSObject(value)); } } this.InternalObject.Attributes[property.Name].SetValue(newValues); }
public override void Remove(object obj) { if (base.Contains(obj)) { // obj is already a unique identifier base.Remove(obj); return; } RmaObject rmaObject = obj as RmaObject; if (rmaObject != null) { // obj is an existing object base.Remove(rmaObject.InternalObject.ObjectID); return; } if (obj is Guid) { // obj is a guid base.Remove(new UniqueIdentifier((Guid)obj)); return; } if (obj is string) { Guid guid; if (Guid.TryParse((string)obj, out guid)) { // obj is a string in GUID format base.Remove(new UniqueIdentifier(guid)); return; } } }