Beispiel #1
0
        /// <summary>
        /// Returns a list of verbs.
        /// </summary>
        protected override void ProcessRecord()
        {
            Type[] verbTypes = new Type[] { typeof(VerbsCommon), typeof(VerbsCommunications), typeof(VerbsData),
                                            typeof(VerbsDiagnostic), typeof(VerbsLifecycle), typeof(VerbsOther), typeof(VerbsSecurity) };

            Collection <WildcardPattern> matchingVerbs = SessionStateUtilities.CreateWildcardsFromStrings(
                this.Verb,
                WildcardOptions.IgnoreCase
                );

            foreach (Type type in verbTypes)
            {
                string groupName = type.Name.Substring(5);
                if (this.Group != null)
                {
                    if (!SessionStateUtilities.CollectionContainsValue(this.Group, groupName, StringComparer.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                }

                foreach (FieldInfo field in type.GetFields())
                {
                    if (field.IsLiteral)
                    {
                        if (this.Verb != null)
                        {
                            if (!SessionStateUtilities.MatchesAnyWildcardPattern(field.Name, matchingVerbs, false))
                            {
                                continue;
                            }
                        }

                        VerbInfo verb = new VerbInfo();
                        verb.Verb        = field.Name;
                        verb.AliasPrefix = VerbAliasPrefixes.GetVerbAliasPrefix(field.Name);
                        verb.Group       = groupName;
                        verb.Description = VerbDescriptions.GetVerbDescription(field.Name);
                        WriteObject(verb);
                    }
                }
            }
        }