コード例 #1
0
        /// <summary>
        /// Performs enhanced record-by-record processing functionality for the cmdlet.
        /// </summary>
        protected override void ProcessRecordEx()
        {
            config = GetCmdletConfig();

            if (ShouldProcess($"{config.NameDescrption} ({config.IdDescription}, Destination: {DestinationId})"))
            {
                ExecuteOperation(Clone);
            }
        }
コード例 #2
0
        private CloneCmdletConfig GetCmdletConfig()
        {
            CloneCmdletConfig parameters;

            switch (ParameterSetName)
            {
            case ParameterSet.SensorToDestination:
                parameters = new CloneCmdletConfig(
                    Sensor,
                    Name ?? Sensor.Name,
                    GetSensors
                    );
                break;

            case ParameterSet.DeviceToDestination:
                parameters = new CloneCmdletConfig(
                    Device,
                    string.IsNullOrEmpty(Name) ? $"Clone of {Device.Name}" : Name,
                    Host ?? Device.Host,
                    GetDevices
                    );
                break;

            case ParameterSet.GroupToDestination:
                parameters = new CloneCmdletConfig(
                    Group,
                    Name ?? Group.Name,
                    GetGroups
                    );
                break;

            case ParameterSet.TriggerToDestination:
                parameters = new CloneCmdletConfig(Trigger, null, null);
                break;

            case ParameterSet.TargetForSource:
                DestinationId = Destination.Id;
                parameters    = new CloneCmdletConfig(sourceObj, sourceObj.Name, sourceObjResolver);
                break;

            default:
                throw new UnknownParameterSetException(ParameterSetName);
            }

            if (ParameterSetName != ParameterSet.TriggerToDestination)
            {
                parameters.AllowBasic = true;
            }

            return(parameters);
        }
コード例 #3
0
ファイル: CloneObject.cs プロジェクト: mrwulf/PrtgAPI
        private CloneCmdletConfig GetCmdletConfig()
        {
            CloneCmdletConfig parameters;

            switch (ParameterSetName)
            {
            case SensorToDestination:
                parameters = new CloneCmdletConfig(
                    Sensor,
                    Name ?? Sensor.Name,
                    GetSensors
                    );
                break;

            case DeviceToDestination:
                parameters = new CloneCmdletConfig(
                    Device,
                    string.IsNullOrEmpty(Name) ? $"Clone of {Device.Name}" : Name,
                    Host ?? Device.Host,
                    GetDevices
                    );
                break;

            case GroupToDestination:
                parameters = new CloneCmdletConfig(
                    Group,
                    Name ?? Group.Name,
                    GetGroups
                    );
                break;

            case TriggerToDestination:
                parameters = new CloneCmdletConfig(Trigger, null, null);
                break;

            case TargetForSource:
                DestinationId = Destination.Id;
                parameters    = new CloneCmdletConfig(sourceObj, sourceObj.Name, sourceObjResolver);
                break;

            default:
                throw new NotImplementedException($"Don't know how to handle parameter set '{ParameterSetName}'");
            }

            if (ParameterSetName != TriggerToDestination)
            {
                parameters.AllowBasic = true;
            }

            return(parameters);
        }
コード例 #4
0
        /// <summary>
        /// Performs enhanced record-by-record processing functionality for the cmdlet.
        /// </summary>
        protected override void ProcessRecordEx()
        {
            config = GetCmdletConfig();

            string destinationDescription;

            if (Destination != null)
            {
                destinationDescription = $"'{Destination.Name}' (ID: {Destination.Id})";
            }
            else
            {
                destinationDescription = DestinationId.ToString();
            }

            if (ShouldProcess($"'{config.NameDescrption}' ({config.IdDescription}), Destination: {destinationDescription}"))
            {
                ExecuteOperation(Clone);
            }
        }
コード例 #5
0
        private CloneCmdletConfig GetCmdletConfig()
        {
            CloneCmdletConfig parameters;

            switch (ParameterSetName)
            {
            case ParameterSet.SensorToDestination:
                parameters = new CloneCmdletConfig(
                    Sensor,
                    Name ?? Sensor.Name,
                    GetSensors
                    );
                break;

            case ParameterSet.DeviceToDestination:
                parameters = new CloneCmdletConfig(
                    Device,
                    string.IsNullOrEmpty(Name) ? $"Clone of {Device.Name}" : Name,
                    Host ?? Device.Host,
                    GetDevices
                    );
                break;

            case ParameterSet.GroupToDestination:
                parameters = new CloneCmdletConfig(
                    Group,
                    Name ?? Group.Name,
                    GetGroups
                    );
                break;

            case ParameterSet.TriggerToDestination:
                parameters = new CloneCmdletConfig(Trigger, null, null);
                break;

            case ParameterSet.TargetForSource:
                DestinationId = Destination.Id;
                parameters    = new CloneCmdletConfig(sourceObj, sourceObj.Name, sourceObjResolver);
                break;

            case ParameterSet.Manual:
                sourceObj = client.GetObject(SourceId);

                if (!MyInvocation.BoundParameters.ContainsKey(nameof(DestinationId)))
                {
                    DestinationId = sourceObj.ParentId;
                }

                parameters = new CloneCmdletConfig(sourceObj, Name ?? $"Clone of {sourceObj.Name}", GetObjects);
                break;

            default:
                throw new UnknownParameterSetException(ParameterSetName);
            }

            if (ParameterSetName != ParameterSet.TriggerToDestination)
            {
                parameters.AllowBasic = true;
            }

            return(parameters);
        }