private void SetSourceIdObject() { var sensor = client.GetSensors(Property.Id, SourceId).FirstOrDefault(); if (sensor != null) { sourceObj = sensor; sourceObjResolver = GetSensors; return; } var device = client.GetDevices(Property.Id, SourceId).FirstOrDefault(); if (device != null) { sourceObj = device; sourceObjResolver = GetDevices; return; } var group = client.GetGroups(Property.Id, SourceId).FirstOrDefault(); if (group != null) { sourceObj = group; sourceObjResolver = GetGroups; return; } throw new PSArgumentException($"Cannot clone object with ID '{SourceId}' as it is not a sensor, device or group."); }
private void ExecuteOperation(SensorOrDeviceOrGroupOrProbe obj) { if (ShouldProcess($"'{obj.Name}' (ID: {obj.Id}) (Destination ID: {DestinationId})")) { ExecuteOperation(() => client.MoveObject(obj.Id, DestinationId), $"Moving {obj.BaseType.ToString().ToLower()} {obj.Name} (ID: {obj.Id}) to object ID {DestinationId}"); } }
private static int ValidateObject(SensorOrDeviceOrGroupOrProbe obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } return(obj.Id); }
private void ExecuteOperation(SensorOrDeviceOrGroupOrProbe obj) { var ids = new[] { Id }; if (ShouldProcess(GetShouldProcessMessage(obj, new[] { Id }, $"Destination ID: {DestinationId}"))) { ExecuteOperation( () => client.MoveObject(GetSingleOperationId(obj, ids)[0], DestinationId), GetSingleOperationProgressMessage(obj, ids, "Moving", obj?.BaseType.ToString().ToLower() ?? "object", $"to object ID {DestinationId}") ); } }
public SetPositionParameters(SensorOrDeviceOrGroupOrProbe obj, int position) : base(ValidateObject(obj)) { var newPos = PositionConverter.SerializePosition(position) + (position > obj.Position ? 1 : -1); Position = newPos; }
/// <summary> /// If <see cref="Batch"/> is true, queues the object for processing after all items have been identified. Otherwise, executes this cmdlet's action immediately. /// </summary> /// <param name="obj">The object to process.</param> protected void ExecuteOrQueue(SensorOrDeviceOrGroupOrProbe obj) { ExecuteOrQueue(obj, $"Queuing {obj.BaseType.ToString().ToLower()} '{obj.Name}'"); }
public SetPositionParameters(SensorOrDeviceOrGroupOrProbe obj, int position) : base(ValidateObject(obj)) { var newPos = position * 10 + (position > obj.Position ? 1 : -1); Position = newPos; }