Beispiel #1
0
        /// <summary>
        /// Retrieves an object that defines the dynamic parameters of this cmdlet.
        /// </summary>
        /// <returns>An object that defines the dynamic parameters of this cmdlet.</returns>
        public object GetDynamicParameters()
        {
            if (dynamicParameterSet == null)
            {
                var properties = ReflectionCacheManager.Get(typeof(NotificationTrigger)).Properties.
                                 Where(p => p.GetAttribute <PropertyParameterAttribute>() != null).
                                 Select(p => Tuple.Create((TriggerProperty)p.GetAttribute <PropertyParameterAttribute>().Property, p)).ToList();

                dynamicParameterSet = new PropertyDynamicParameterSet <TriggerProperty>(
                    new[] { ParameterSet.Dynamic, ParameterSet.DynamicManual },
                    e => ReflectionCacheManager.GetArrayPropertyType(properties.FirstOrDefault(p => p.Item1 == e)?.Item2.Property.PropertyType),
                    this
                    );
            }

            return(dynamicParameterSet.Parameters);
        }
Beispiel #2
0
        internal object GetDynamicParameters(params string[] parameterSets)
        {
            if (parameterSets.Length == 0)
            {
                parameterSets = new[] { ParameterSet.Dynamic }
            }
            ;

            if (dynamicParameterSet == null)
            {
                var properties = ReflectionCacheManager.Get(typeof(TObject)).Properties.
                                 Where(p => p.GetAttribute <PropertyParameterAttribute>() != null).
                                 Select(p => Tuple.Create((Property)p.GetAttribute <PropertyParameterAttribute>().Property, p)).ToList();

                dynamicParameterSet = new PropertyDynamicParameterSet <Property>(
                    parameterSets,
                    e => ReflectionCacheManager.GetArrayPropertyType(properties.FirstOrDefault(p => p.Item1 == e)?.Item2.Property.PropertyType),
                    this
                    );
            }

            return(dynamicParameterSet.Parameters);
        }