public VariantGroup(string moduleName, string cmdletName, Variant[] variants, string outputFolder, string profileName = NoProfiles, bool isTest = false, bool isInternal = false) { ModuleName = moduleName; CmdletName = cmdletName; var cmdletNameParts = CmdletName.Split('-'); CmdletVerb = cmdletNameParts.First(); CmdletNoun = cmdletNameParts.Last(); ProfileName = profileName; Variants = variants; ParameterGroups = Variants.ToParameterGroups().OrderBy(pg => pg.OrderCategory).ThenByDescending(pg => pg.IsMandatory).ToArray(); var aliasDuplicates = ParameterGroups.SelectMany(pg => pg.Aliases) //https://stackoverflow.com/a/18547390/294804 .GroupBy(a => a).Where(g => g.Count() > 1).Select(g => g.Key).ToArray(); if (aliasDuplicates.Any()) { throw new ParsingMetadataException($"The alias(es) [{String.Join(", ", aliasDuplicates)}] are defined on multiple parameters for cmdlet '{CmdletName}', which is not supported."); } ComplexInterfaceInfos = ParameterGroups.Where(pg => !pg.DontShow && pg.IsComplexInterface).OrderBy(pg => pg.ParameterName).Select(pg => pg.ComplexInterfaceInfo).ToArray(); Aliases = Variants.SelectMany(v => v.Attributes).ToAliasNames().ToArray(); OutputTypes = Variants.SelectMany(v => v.Info.OutputType).Where(ot => ot.Type != null).GroupBy(ot => ot.Type).Select(otg => otg.First()).ToArray(); SupportsShouldProcess = Variants.Any(v => v.SupportsShouldProcess); SupportsPaging = Variants.Any(v => v.SupportsPaging); DefaultParameterSetName = DetermineDefaultParameterSetName(); HasMultipleVariants = Variants.Length > 1; HelpInfo = Variants.Select(v => v.HelpInfo).FirstOrDefault() ?? new PsHelpInfo(); IsGenerated = Variants.All(v => v.Attributes.OfType <GeneratedAttribute>().Any()); IsInternal = isInternal; OutputFolder = outputFolder; FileName = $"{CmdletName}{(isTest ? ".Tests" : String.Empty)}.ps1"; FilePath = Path.Combine(OutputFolder, FileName); CommentInfo = new CommentInfo(this); }
/// <summary> /// Returns true if ChannelTypeDTO instances are equal /// </summary> /// <param name="input">Instance of ChannelTypeDTO to be compared</param> /// <returns>Boolean</returns> public bool Equals(ChannelTypeDTO input) { if (input == null) { return(false); } return (( Parameters == input.Parameters || Parameters != null && Parameters.SequenceEqual(input.Parameters) ) && ( ParameterGroups == input.ParameterGroups || ParameterGroups != null && ParameterGroups.SequenceEqual(input.ParameterGroups) ) && ( Description == input.Description || (Description != null && Description.Equals(input.Description)) ) && ( Label == input.Label || (Label != null && Label.Equals(input.Label)) ) && ( Category == input.Category || (Category != null && Category.Equals(input.Category)) ) && ( ItemType == input.ItemType || (ItemType != null && ItemType.Equals(input.ItemType)) ) && ( Kind == input.Kind || (Kind != null && Kind.Equals(input.Kind)) ) && ( StateDescription == input.StateDescription || (StateDescription != null && StateDescription.Equals(input.StateDescription)) ) && ( Tags == input.Tags || Tags != null && Tags.SequenceEqual(input.Tags) ) && ( UID == input.UID || (UID != null && UID.Equals(input.UID)) ) && ( Advanced == input.Advanced || (Advanced != null && Advanced.Equals(input.Advanced)) ) && ( CommandDescription == input.CommandDescription || (CommandDescription != null && CommandDescription.Equals(input.CommandDescription)) )); }
/// <summary> /// Returns true if ThingTypeDTO instances are equal /// </summary> /// <param name="input">Instance of ThingTypeDTO to be compared</param> /// <returns>Boolean</returns> public bool Equals(ThingTypeDTO input) { if (input == null) { return(false); } return (( UID == input.UID || (UID != null && UID.Equals(input.UID)) ) && ( Label == input.Label || (Label != null && Label.Equals(input.Label)) ) && ( Description == input.Description || (Description != null && Description.Equals(input.Description)) ) && ( Category == input.Category || (Category != null && Category.Equals(input.Category)) ) && ( Listed == input.Listed || (Listed != null && Listed.Equals(input.Listed)) ) && ( SupportedBridgeTypeUIDs == input.SupportedBridgeTypeUIDs || SupportedBridgeTypeUIDs != null && SupportedBridgeTypeUIDs.SequenceEqual(input.SupportedBridgeTypeUIDs) ) && ( Bridge == input.Bridge || (Bridge != null && Bridge.Equals(input.Bridge)) ) && ( Channels == input.Channels || Channels != null && Channels.SequenceEqual(input.Channels) ) && ( ChannelGroups == input.ChannelGroups || ChannelGroups != null && ChannelGroups.SequenceEqual(input.ChannelGroups) ) && ( ConfigParameters == input.ConfigParameters || ConfigParameters != null && ConfigParameters.SequenceEqual(input.ConfigParameters) ) && ( ParameterGroups == input.ParameterGroups || ParameterGroups != null && ParameterGroups.SequenceEqual(input.ParameterGroups) ) && ( Properties == input.Properties || Properties != null && Properties.SequenceEqual(input.Properties) ) && ( ExtensibleChannelTypeIds == input.ExtensibleChannelTypeIds || ExtensibleChannelTypeIds != null && ExtensibleChannelTypeIds.SequenceEqual(input.ExtensibleChannelTypeIds) )); }