/// <summary>
        /// Creates dynamic parameters for all parameters defined on a <see cref="NewSensorParameters"/> object.
        /// </summary>
        /// <param name="dictionary">The dynamic parameters dictionary to add parameters to.</param>
        private void AddParametersObjectDynamicParameters(RuntimeDefinedParameterDictionaryEx dictionary)
        {
            //If TypeAttribute.Class is null (i.e. creating the parameters are not actually supported) a SwitchParameter wouldn't have been created
            //and we won't actually get to this point
            var parametersType = Type.GetEnumAttribute <TypeAttribute>(true);

            var properties = ReflectionCacheManager.Get(parametersType.Class).Properties.Where(p => p.GetAttribute <PropertyParameterAttribute>() != null);

            var parameterConfig = Type.GetEnumAttribute <NewSensorAttribute>() ?? new NewSensorAttribute();

            int?position = null;

            foreach (var property in properties)
            {
                var parameterAttributes = new List <Attribute>();

                var isNameParameter = property.Property.Name == nameof(NewObjectParameters.Name);

                position = GetPosition(property, isNameParameter, parameterConfig, position);

                foreach (var set in ParameterSets.Where(s => PropertyIsAllowedInSet(property, s)))
                {
                    parameterAttributes.Add(new ParameterAttribute
                    {
                        Mandatory        = GetMandatory(property, isNameParameter, parameterConfig),
                        Position         = position.Value,
                        ParameterSetName = $"{Type}{set.Name}"
                    });
                }

                var name = GetParameterName(property);

                var type = property.Property.PropertyType;

                if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>))
                {
                    var underlying = type.GetGenericArguments()[0];
                    type = underlying.MakeArrayType();
                }

                dictionary.AddOrMerge(name, type, parameterAttributes.ToArray());

                if (alternateSet != null)
                {
                    IAlternateParameter alternateParameter;

                    if (TryGetAlternateProperty(property, alternateSet.Name, out alternateParameter))
                    {
                        var parameterAttribute = new ParameterAttribute
                        {
                            Mandatory        = HasRequireValueTrue(property),
                            Position         = position.Value,
                            ParameterSetName = $"{Type}{alternateSet.Name}"
                        };

                        dictionary.AddOrMerge(alternateParameter.Name, alternateParameter.Type, parameterAttribute);
                    }
                }
            }
        }
        private void AddSensorTypeDynamicParameter(RuntimeDefinedParameterDictionaryEx dictionary)
        {
            var attributes = ParameterSets.Select(set => new ParameterAttribute
            {
                Mandatory        = true,
                ParameterSetName = $"{Type}{set.Name}",
                Position         = 0 //Force it to the front so it displays first in PowerShell help
            }).ToArray();

            dictionary.AddOrMerge(Type.ToString(), typeof(SwitchParameter), attributes);
        }
        private void AddDestinationParameter(RuntimeDefinedParameterDictionaryEx dictionary)
        {
            var type = DestinationType == NewSensorDestinationType.DestinationId ? typeof(int) : typeof(Device);

            var attributes = ParameterSets.Select(set => new ParameterAttribute
            {
                Mandatory         = true,
                ValueFromPipeline = DestinationType == NewSensorDestinationType.Device,
                ParameterSetName  = $"{Type}{set.Name}"
            }).ToArray();

            dictionary.AddOrMerge(DestinationType.ToString(), type, attributes);
        }
        private void AddCmdletDynamicParameters(NewSensor newSensorCmdlet, RuntimeDefinedParameterDictionaryEx dictionary)
        {
            var properties = ReflectionCacheManager.Get(GetInvoker(newSensorCmdlet).CmdletToInvoke.GetType()).Properties
                             .Where(p => p.GetAttribute <ParameterAttribute>() != null).ToList();

            var highestPosition = GetHighestParameterPosition(dictionary);

            foreach (var property in properties)
            {
                var description = property.GetAttribute <DescriptionAttribute>();

                var name = description?.Description ?? property.Property.Name;

                //Not cached so we can modify it
                var attributes = Attribute.GetCustomAttributes(property.Property, typeof(ParameterAttribute)).ToList();

                foreach (ParameterAttribute attribute in attributes)
                {
                    attribute.ParameterSetName = $"{Type}{attribute.ParameterSetName}";

                    if (attribute.Position >= 0 && highestPosition != null)
                    {
                        attribute.Position += highestPosition.Value + 1;
                    }
                }

                var aliases = property.GetAttribute <AliasAttribute>();

                if (aliases != null && !aliases.AliasNames.Contains(name))
                {
                    attributes.Add(aliases);
                }

                dictionary.AddOrMerge(name, property.Property.PropertyType, attributes.ToArray());
            }
        }