internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() { var SignatureTypes_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddText(FileSystemProviderStrings.DirectoryDisplayGrouping) .AddScriptBlockExpressionBinding(@"split-path $_.Path") .AddNewline() .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { SignatureTypes_GroupingFormat }; yield return new ExtendedTypeDefinition( "System.Security.Cryptography.X509Certificates.X509Certificate2", ViewsOf_System_Security_Cryptography_X509Certificates_X509Certificate2()); var td2 = new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.X509StoreLocation", ViewsOf_CertificateProviderTypes()); td2.TypeNames.Add("System.Security.Cryptography.X509Certificates.X509Certificate2"); td2.TypeNames.Add("System.Security.Cryptography.X509Certificates.X509Store"); yield return td2; yield return new ExtendedTypeDefinition( "System.Management.Automation.Signature", ViewsOf_System_Management_Automation_Signature(sharedControls)); yield return new ExtendedTypeDefinition( "System.Security.Cryptography.X509Certificates.X509CertificateEx", ViewsOf_System_Security_Cryptography_X509Certificates_X509CertificateEx()); }
internal static IEnumerable <ExtendedTypeDefinition> GetFormatData() { var SignatureTypes_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame() .AddText(FileSystemProviderStrings.DirectoryDisplayGrouping) .AddScriptBlockExpressionBinding(@"split-path $_.Path") .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { SignatureTypes_GroupingFormat }; yield return(new ExtendedTypeDefinition( "System.Security.Cryptography.X509Certificates.X509Certificate2", ViewsOf_System_Security_Cryptography_X509Certificates_X509Certificate2())); var td2 = new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.X509StoreLocation", ViewsOf_CertificateProviderTypes()); td2.TypeNames.Add("System.Security.Cryptography.X509Certificates.X509Certificate2"); td2.TypeNames.Add("System.Security.Cryptography.X509Certificates.X509Store"); yield return(td2); yield return(new ExtendedTypeDefinition( "System.Management.Automation.Signature", ViewsOf_System_Management_Automation_Signature(sharedControls))); yield return(new ExtendedTypeDefinition( "System.Security.Cryptography.X509Certificates.X509CertificateEx", ViewsOf_System_Security_Cryptography_X509Certificates_X509CertificateEx())); }
private static void LoadFormatDataHelper( ExtendedTypeDefinition formatData, PSPropertyExpressionFactory expressionFactory, List <XmlLoaderLoggerEntry> logEntries, ref bool success, PSSnapInTypeAndFormatErrors file, TypeInfoDataBase db, bool isBuiltInFormatData, bool isForHelp) { using (TypeInfoDataBaseLoader loader = new TypeInfoDataBaseLoader()) { if (!loader.LoadFormattingData(formatData, db, expressionFactory, isBuiltInFormatData, isForHelp)) { success = false; } foreach (XmlLoaderLoggerEntry entry in loader.LogEntries) { // filter in only errors from the current file... if (entry.entryType == XmlLoaderLoggerEntry.EntryType.Error) { string mshsnapinMessage = StringUtil.Format(FormatAndOutXmlLoadingStrings.MshSnapinQualifiedError, file.PSSnapinName, entry.message); file.Errors.Add(mshsnapinMessage); } } // now aggregate the entries... logEntries.AddRange(loader.LogEntries); } }
internal static IEnumerable <ExtendedTypeDefinition> GetFormatData() { var FileSystemTypes_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddText(FileSystemProviderStrings.DirectoryDisplayGrouping) .AddScriptBlockExpressionBinding(@" $_.PSParentPath.Replace(""Microsoft.PowerShell.Core\FileSystem::"", """") ") .AddNewline() .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { FileSystemTypes_GroupingFormat }; var td1 = new ExtendedTypeDefinition( "System.IO.DirectoryInfo", ViewsOf_FileSystemTypes(sharedControls)); td1.TypeNames.Add("System.IO.FileInfo"); yield return(td1); yield return(new ExtendedTypeDefinition( "System.Security.AccessControl.FileSystemSecurity", ViewsOf_System_Security_AccessControl_FileSystemSecurity(sharedControls))); yield return(new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.AlternateStreamData", ViewsOf_Microsoft_PowerShell_Commands_AlternateStreamData())); }
internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() { var FileSystemTypes_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddText(FileSystemProviderStrings.DirectoryDisplayGrouping) .AddScriptBlockExpressionBinding(@" $_.PSParentPath.Replace(""Microsoft.PowerShell.Core\FileSystem::"", """") ") .AddNewline() .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { FileSystemTypes_GroupingFormat }; var td1 = new ExtendedTypeDefinition( "System.IO.DirectoryInfo", ViewsOf_FileSystemTypes(sharedControls)); td1.TypeNames.Add("System.IO.FileInfo"); yield return td1; yield return new ExtendedTypeDefinition( "System.Security.AccessControl.FileSystemSecurity", ViewsOf_System_Security_AccessControl_FileSystemSecurity(sharedControls)); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.AlternateStreamData", ViewsOf_Microsoft_PowerShell_Commands_AlternateStreamData()); }
public FormatConfigurationEntry(ExtendedTypeDefinition typeDefinition) : base("*") { if (typeDefinition == null) { throw PSTraceSource.NewArgumentNullException("typeDefinition"); } this._typeDefinition = typeDefinition; }
private void AddRemoteTypeDefinition(IList <ExtendedTypeDefinition> listOfTypeDefinitions, PSObject remoteTypeDefinition) { ExtendedTypeDefinition typeDefinition = this.ConvertTo <ExtendedTypeDefinition>("Get-FormatData", remoteTypeDefinition); if (this.IsSafeTypeDefinition(typeDefinition)) { listOfTypeDefinitions.Add(typeDefinition); } }
private bool IsSafeTypeDefinition(ExtendedTypeDefinition typeDefinition) { if (!this.IsTypeNameMatchingParameters(typeDefinition.TypeName)) { base.WriteError(this.GetErrorSkippedNonRequestedTypeDefinition(typeDefinition.TypeName)); return(false); } return(true); }
internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() { var Registry_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddText("Hive: ") .AddScriptBlockExpressionBinding(@"$_.PSParentPath.Replace(""Microsoft.PowerShell.Core\Registry::"", """")") .AddNewline() .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { Registry_GroupingFormat }; var td1 = new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.Internal.TransactedRegistryKey", ViewsOf_Microsoft_PowerShell_Commands_Internal_TransactedRegistryKey_Microsoft_Win32_RegistryKey_System_Management_Automation_TreatAs_RegistryValue(sharedControls)); td1.TypeNames.Add("Microsoft.Win32.RegistryKey"); td1.TypeNames.Add("System.Management.Automation.TreatAs.RegistryValue"); yield return td1; }
internal static IEnumerable <ExtendedTypeDefinition> GetFormatData() { var Registry_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame() .AddText(" Hive: ") .AddScriptBlockExpressionBinding(@"$_.PSParentPath.Replace(""Microsoft.PowerShell.Core\Registry::"", """")") .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { Registry_GroupingFormat }; var td1 = new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.Internal.TransactedRegistryKey", ViewsOf_Microsoft_PowerShell_Commands_Internal_TransactedRegistryKey_Microsoft_Win32_RegistryKey_System_Management_Automation_TreatAs_RegistryValue(sharedControls)); td1.TypeNames.Add("Microsoft.Win32.RegistryKey"); td1.TypeNames.Add("System.Management.Automation.TreatAs.RegistryValue"); yield return(td1); }
internal PSSnapInTypeAndFormatErrors(string psSnapinName, ExtendedTypeDefinition typeDefinition) { this.psSnapinName = psSnapinName; FormatData = typeDefinition; Errors = new ConcurrentBag<string>(); }
internal PSSnapInTypeAndFormatErrors(string psSnapinName, ExtendedTypeDefinition typeDefinition) { this.psSnapinName = psSnapinName; FormatData = typeDefinition; Errors = new ConcurrentBag <string>(); }
/// <summary> /// Takes out the content from the database and writes them out. /// </summary> protected override void ProcessRecord() { // Remoting detection: // * Automatic variable $PSSenderInfo is defined in true remoting contexts as well as in background jobs. // * $PSSenderInfo.ApplicationArguments.PSVersionTable.PSVersion contains the client version, as a [version] instance. // Note: Even though $PSVersionTable.PSVersion is of type [semver] in PowerShell 6+, it is of type [version] here, // presumably because only the latter type deserializes type-faithfully. var clientVersion = PowerShellVersion; PSSenderInfo remotingClientInfo = GetVariableValue("PSSenderInfo") as PSSenderInfo; if (clientVersion == null && remotingClientInfo != null) { clientVersion = PSObject.Base((PSObject.Base(remotingClientInfo.ApplicationArguments["PSVersionTable"]) as PSPrimitiveDictionary)?["PSVersion"]) as Version; } // During remoting, remain compatible with v5.0- clients by default. // Passing a -PowerShellVersion argument allows overriding the client version. bool writeOldWay = (remotingClientInfo != null && clientVersion == null) // To be safe: Remoting client version could unexpectedly not be determined. || (clientVersion != null && (clientVersion.Major < 5 || (clientVersion.Major == 5 && clientVersion.Minor < 1))); TypeInfoDataBase db = this.Context.FormatDBManager.Database; List<ViewDefinition> viewdefinitions = db.viewDefinitionsSection.viewDefinitionList; Dictionary<string, List<string>> typeGroupMap = GetTypeGroupMap(db.typeGroupSection.typeGroupDefinitionList); var typedefs = new Dictionary<ConsolidatedString, List<FormatViewDefinition>>(ConsolidatedString.EqualityComparer); foreach (ViewDefinition definition in viewdefinitions) { if (definition.isHelpFormatter) continue; var consolidatedTypeName = CreateConsolidatedTypeName(definition, typeGroupMap); if (!ShouldGenerateView(consolidatedTypeName)) continue; PSControl control; var tableControlBody = definition.mainControl as TableControlBody; if (tableControlBody != null) { control = new TableControl(tableControlBody, definition); } else { var listControlBody = definition.mainControl as ListControlBody; if (listControlBody != null) { control = new ListControl(listControlBody, definition); } else { var wideControlBody = definition.mainControl as WideControlBody; if (wideControlBody != null) { control = new WideControl(wideControlBody, definition); if (writeOldWay) { // Alignment was added to WideControl in V2, but wasn't // used. It was removed in V5, but old PowerShell clients // expect this property or fail to rehydrate the remote object. var psobj = new PSObject(control); psobj.Properties.Add(new PSNoteProperty("Alignment", 0)); } } else { var complexControlBody = (ComplexControlBody)definition.mainControl; control = new CustomControl(complexControlBody, definition); } } } // Older version of PowerShell do not know about something in the control, so // don't return it. if (writeOldWay && !control.CompatibleWithOldPowerShell()) continue; var formatdef = new FormatViewDefinition(definition.name, control, definition.InstanceId); List<FormatViewDefinition> viewList; if (!typedefs.TryGetValue(consolidatedTypeName, out viewList)) { viewList = new List<FormatViewDefinition>(); typedefs.Add(consolidatedTypeName, viewList); } viewList.Add(formatdef); } // write out all the available type definitions foreach (var pair in typedefs) { var typeNames = pair.Key; if (writeOldWay) { foreach (var typeName in typeNames) { var etd = new ExtendedTypeDefinition(typeName, pair.Value); WriteObject(etd); } } else { var etd = new ExtendedTypeDefinition(typeNames[0], pair.Value); for (int i = 1; i < typeNames.Count; i++) { etd.TypeNames.Add(typeNames[i]); } WriteObject(etd); } } }
/// <summary> /// Takes out the content from the database and writes them out. /// </summary> protected override void ProcessRecord() { bool writeOldWay = PowerShellVersion == null || PowerShellVersion.Major < 5 || (PowerShellVersion.Major == 5 && PowerShellVersion.Minor < 1); TypeInfoDataBase db = this.Context.FormatDBManager.Database; List <ViewDefinition> viewdefinitions = db.viewDefinitionsSection.viewDefinitionList; Dictionary <string, List <string> > typeGroupMap = GetTypeGroupMap(db.typeGroupSection.typeGroupDefinitionList); var typedefs = new Dictionary <ConsolidatedString, List <FormatViewDefinition> >(ConsolidatedString.EqualityComparer); foreach (ViewDefinition definition in viewdefinitions) { if (definition.isHelpFormatter) { continue; } var consolidatedTypeName = CreateConsolidatedTypeName(definition, typeGroupMap); if (!ShouldGenerateView(consolidatedTypeName)) { continue; } PSControl control; var tableControlBody = definition.mainControl as TableControlBody; if (tableControlBody != null) { control = new TableControl(tableControlBody, definition); } else { var listControlBody = definition.mainControl as ListControlBody; if (listControlBody != null) { control = new ListControl(listControlBody, definition); } else { var wideControlBody = definition.mainControl as WideControlBody; if (wideControlBody != null) { control = new WideControl(wideControlBody, definition); if (writeOldWay) { // Alignment was added to WideControl in V2, but wasn't // used. It was removed in V5, but old PowerShell clients // expect this property or fail to rehydrate the remote object. var psobj = new PSObject(control); psobj.Properties.Add(new PSNoteProperty("Alignment", 0)); } } else { var complexControlBody = (ComplexControlBody)definition.mainControl; control = new CustomControl(complexControlBody, definition); } } } // Older version of PowerShell do not know about something in the control, so // don't return it. if (writeOldWay && !control.CompatibleWithOldPowerShell()) { continue; } var formatdef = new FormatViewDefinition(definition.name, control, definition.InstanceId); List <FormatViewDefinition> viewList; if (!typedefs.TryGetValue(consolidatedTypeName, out viewList)) { viewList = new List <FormatViewDefinition>(); typedefs.Add(consolidatedTypeName, viewList); } viewList.Add(formatdef); }// foreach(ViewDefinition... // write out all the available type definitions foreach (var pair in typedefs) { var typeNames = pair.Key; if (writeOldWay) { foreach (var typeName in typeNames) { var etd = new ExtendedTypeDefinition(typeName, pair.Value); WriteObject(etd); } } else { var etd = new ExtendedTypeDefinition(typeNames[0], pair.Value); for (int i = 1; i < typeNames.Count; i++) { etd.TypeNames.Add(typeNames[i]); } WriteObject(etd); } } }
internal PSSnapInTypeAndFormatErrors(string psSnapinName, ExtendedTypeDefinition typeDefinition) { this.psSnapinName = psSnapinName; this.typeDefinition = typeDefinition; this.errors = new Collection <string>(); }
internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() { var TextPropertyControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"Text") .EndEntry() .EndControl(); var MamlShortDescriptionControl = CustomControl.Create() .StartEntry(entrySelectedByType: new[] { "MamlParaTextItem" }) .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndEntry() .StartEntry() .AddText(" ") .EndEntry() .EndControl(); var MamlDescriptionControl = CustomControl.Create() .StartEntry(entrySelectedByType: new[] { "MamlParaTextItem" }) .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlOrderedListTextItem" }) .StartFrame(firstLineHanging: 4) .AddPropertyExpressionBinding(@"Tag") .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndFrame() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlUnorderedListTextItem" }) .StartFrame(firstLineHanging: 2) .AddPropertyExpressionBinding(@"Tag") .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndFrame() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlDefinitionTextItem" }) .AddPropertyExpressionBinding(@"Term") .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Definition") .AddNewline() .EndFrame() .EndEntry() .StartEntry() .AddText(" ") .EndEntry() .EndControl(); var MamlParameterControl = CustomControl.Create() .StartEntry() .AddScriptBlockExpressionBinding( @"$optional = $_.required -ne 'true' $positional = (($_.position -ne $()) -and ($_.position -ne '') -and ($_.position -notmatch 'named') -and ([int]$_.position -ne $())) $parameterValue = if ($null -ne $_.psobject.Members['ParameterValueGroup']) { "" {$($_.ParameterValueGroup.ParameterValue -join ' | ')}"" } elseif ($null -ne $_.psobject.Members['ParameterValue']) { "" <$($_.ParameterValue)>"" } else { '' } $(if ($optional -and $positional) { '[[-{0}]{1}] ' } elseif ($optional) { '[-{0}{1}] ' } elseif ($positional) { '[-{0}]{1} ' } else { '-{0}{1} ' }) -f $_.Name, $parameterValue") .EndEntry() .EndControl(); var MamlParameterValueControl = CustomControl.Create() .StartEntry() .AddScriptBlockExpressionBinding(@"if ($_.required -ne 'true') { "" [<$_>]"" } else { "" <$_>"" }") .EndEntry() .EndControl(); var MamlTextItem = CustomControl.Create() .StartEntry(entrySelectedByType: new[] { "MamlParaTextItem" }) .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlOrderedListTextItem" }) .AddPropertyExpressionBinding(@"Tag") .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlUnorderedListTextItem" }) .AddPropertyExpressionBinding(@"Tag") .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlDefinitionTextItem" }) .AddPropertyExpressionBinding(@"Term") .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Definition") .EndFrame() .AddNewline() .EndEntry() .StartEntry(entrySelectedByType: new[] { "MamlPreformattedTextItem" }) .AddPropertyExpressionBinding(@"Text") .EndEntry() .StartEntry() .AddText(" ") .EndEntry() .EndControl(); var MamlAlertControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"Text") .AddNewline() .EndEntry() .EndControl(); var control4 = CustomControl.Create() .StartEntry() .AddText(HelpDisplayStrings.FalseShort) .EndEntry() .EndControl(); var control3 = CustomControl.Create() .StartEntry() .AddText(HelpDisplayStrings.TrueShort) .EndEntry() .EndControl(); var MamlTrueFalseShortControl = CustomControl.Create() .StartEntry() .AddScriptBlockExpressionBinding(@";", selectedByScript: @"$_.Equals('true', [System.StringComparison]::OrdinalIgnoreCase)", customControl: control3) .AddScriptBlockExpressionBinding(@";", selectedByScript: @"$_.Equals('false', [System.StringComparison]::OrdinalIgnoreCase)", customControl: control4) .EndEntry() .EndControl(); var CommonWorkflowParametersControl = CustomControl.Create() .StartEntry() .AddScriptBlockExpressionBinding(StringUtil.Format(@"$wfp = $_.psobject.Properties['WorkflowCommonParameters'] if ($null -ne $wfp -and $wfp.Value) {{ '[{0}] ' }}", HelpDisplayStrings.CommonWorkflowParameters)) .EndEntry() .EndControl(); var RelatedLinksHelpInfoControl = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddScriptBlockExpressionBinding(StringUtil.Format(@"Set-StrictMode -Off if (($_.relatedLinks -ne $()) -and ($_.relatedLinks.navigationLink -ne $()) -and ($_.relatedLinks.navigationLink.Length -ne 0)) {{ "" {0}`""get-help $($_.Details.Name) -online`"""" }}", HelpDisplayStrings.RelatedLinksHelpInfo)) .EndFrame() .EndEntry() .EndControl(); var control6 = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"linkText") .AddScriptBlockExpressionBinding("' '", selectedByScript: "$_.linkText.Length -ne 0") .AddPropertyExpressionBinding(@"uri") .AddNewline() .EndEntry() .EndControl(); var MamlRelatedLinksControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"navigationLink", enumerateCollection: true, customControl: control6) .EndEntry() .EndControl(); var MamlDetailsControl = CustomControl.Create() .StartEntry() .AddText(HelpDisplayStrings.Name) .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Name") .AddNewline() .AddNewline() .EndFrame() .AddText(HelpDisplayStrings.Synopsis) .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Description", enumerateCollection: true, customControl: MamlShortDescriptionControl) .AddNewline() .AddNewline() .EndFrame() .EndEntry() .EndControl(); var MamlExampleControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"Title") .AddNewline() .AddNewline() .AddPropertyExpressionBinding(@"Introduction", enumerateCollection: true, customControl: TextPropertyControl) .AddPropertyExpressionBinding(@"Code", enumerateCollection: true) .AddNewline() .AddPropertyExpressionBinding(@"results") .AddNewline() .AddPropertyExpressionBinding(@"remarks", enumerateCollection: true, customControl: MamlShortDescriptionControl) .EndEntry() .EndControl(); var control1 = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"description", enumerateCollection: true, customControl: MamlShortDescriptionControl) .EndFrame() .EndEntry() .EndControl(); var control0 = CustomControl.Create() .StartEntry() .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"uri") .AddNewline() .EndFrame() .EndEntry() .EndControl(); var MamlTypeControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"name", enumerateCollection: true) .AddCustomControlExpressionBinding(control0, selectedByScript: "$_.uri") .AddCustomControlExpressionBinding(control1, selectedByScript: "$_.description") .EndEntry() .EndControl(); var control2 = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"Value") .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Description", enumerateCollection: true, customControl: MamlShortDescriptionControl) .EndFrame() .AddNewline() .EndEntry() .EndControl(); var MamlPossibleValueControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"possibleValue", enumerateCollection: true, customControl: control2) .EndEntry() .EndControl(); var MamlIndentedDescriptionControl = CustomControl.Create() .StartEntry() .AddText(HelpDisplayStrings.DetailedDescription) .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"description", enumerateCollection: true, customControl: MamlDescriptionControl) .AddNewline() .EndFrame() .AddNewline() .EndEntry() .EndControl(); var control5 = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"name") .AddText(" ") .AddPropertyExpressionBinding(@"Parameter", enumerateCollection: true, customControl: MamlParameterControl) .AddCustomControlExpressionBinding(CommonWorkflowParametersControl) .AddText("[" + HelpDisplayStrings.CommonParameters + "]") .AddNewline(2) .EndEntry() .EndControl(); var MamlSyntaxControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"SyntaxItem", enumerateCollection: true, customControl: control5) .EndEntry() .EndControl(); var ExamplesControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"Example", enumerateCollection: true, customControl: MamlExampleControl) .EndEntry() .EndControl(); var MamlTypeWithDescriptionControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"type", customControl: MamlTypeControl) .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"description", enumerateCollection: true, customControl: MamlShortDescriptionControl) .EndFrame() .AddNewline() .EndEntry() .EndControl(); var ErrorControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"errorId") .AddText(HelpDisplayStrings.Category) .AddPropertyExpressionBinding(@"category") .AddText(")") .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"description", enumerateCollection: true, customControl: MamlShortDescriptionControl) .EndFrame() .AddNewline() .AddText(HelpDisplayStrings.TypeColon) .AddPropertyExpressionBinding(@"type", customControl: MamlTypeControl) .AddNewline() .AddText(HelpDisplayStrings.TargetObjectTypeColon) .AddPropertyExpressionBinding(@"targetObjectType", customControl: MamlTypeControl) .AddNewline() .AddText(HelpDisplayStrings.SuggestedActionColon) .AddPropertyExpressionBinding(@"recommendedAction", enumerateCollection: true, customControl: MamlShortDescriptionControl) .AddNewline() .AddNewline() .EndEntry() .EndControl(); var MamlPossibleValuesControl = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"possibleValues", customControl: MamlPossibleValueControl) .EndEntry() .EndControl(); var MamlIndentedSyntaxControl = CustomControl.Create() .StartEntry() .AddText(HelpDisplayStrings.Syntax) .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Syntax", customControl: MamlSyntaxControl) .AddNewline() .EndFrame() .EndEntry() .EndControl(); var control7 = CustomControl.Create() .StartEntry() .AddText(HelpDisplayStrings.NamedParameter) .EndEntry() .EndControl(); var MamlFullParameterControl = CustomControl.Create() .StartEntry() .AddText("-") .AddPropertyExpressionBinding(@"name") .AddPropertyExpressionBinding(@"ParameterValue", customControl: MamlParameterValueControl) .AddNewline() .StartFrame(leftIndent: 4) .AddPropertyExpressionBinding(@"Description", enumerateCollection: true, customControl: MamlDescriptionControl) .AddNewline() .AddCustomControlExpressionBinding(MamlPossibleValuesControl, selectedByScript: "$_.possibleValues -ne $()") .AddText(HelpDisplayStrings.ParameterRequired) .AddPropertyExpressionBinding(@"required", customControl: MamlTrueFalseShortControl) .AddNewline() .AddText(HelpDisplayStrings.ParameterPosition) .AddScriptBlockExpressionBinding(@" ", selectedByScript: @"($_.position -eq $()) -or ($_.position -eq '')", customControl: control7) .AddScriptBlockExpressionBinding(@"$_.position", selectedByScript: "$_.position -ne $()") .AddNewline() .AddText(HelpDisplayStrings.ParameterDefaultValue) .AddPropertyExpressionBinding(@"defaultValue") .AddNewline() .AddText(HelpDisplayStrings.AcceptsPipelineInput) .AddPropertyExpressionBinding(@"pipelineInput") .AddNewline() .AddText(HelpDisplayStrings.AcceptsWildCardCharacters) .AddPropertyExpressionBinding(@"globbing", customControl: MamlTrueFalseShortControl) .AddNewline() .AddNewline() .EndFrame() .EndEntry() .EndControl(); var control8 = CustomControl.Create() .StartEntry() .AddPropertyExpressionBinding(@"Parameter", enumerateCollection: true, customControl: MamlFullParameterControl) .EndEntry() .EndControl(); var zzz = CustomControl.Create() .StartEntry() .AddCustomControlExpressionBinding(control8) .AddText(HelpDisplayStrings.CommonParameters) .AddNewline() .StartFrame(leftIndent: 4) .AddText(HelpDisplayStrings.BaseCmdletInformation) .EndFrame() .AddNewline() .AddNewline() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { TextPropertyControl, MamlShortDescriptionControl, MamlDetailsControl, MamlIndentedDescriptionControl, MamlDescriptionControl, MamlParameterControl, MamlParameterValueControl, ExamplesControl, MamlExampleControl, MamlTypeControl, MamlTextItem, MamlAlertControl, MamlPossibleValuesControl, MamlPossibleValueControl, MamlTrueFalseShortControl, MamlIndentedSyntaxControl, CommonWorkflowParametersControl, MamlSyntaxControl, MamlTypeWithDescriptionControl, RelatedLinksHelpInfoControl, MamlRelatedLinksControl, ErrorControl, MamlFullParameterControl, zzz }; yield return new ExtendedTypeDefinition( "HelpInfoShort", ViewsOf_HelpInfoShort()); yield return new ExtendedTypeDefinition( "CmdletHelpInfo", ViewsOf_CmdletHelpInfo()); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo", ViewsOf_MamlCommandHelpInfo(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#DetailedView", ViewsOf_MamlCommandHelpInfo_DetailedView(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#ExamplesView", ViewsOf_MamlCommandHelpInfo_ExamplesView(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#FullView", ViewsOf_MamlCommandHelpInfo_FullView(sharedControls)); yield return new ExtendedTypeDefinition( "ProviderHelpInfo", ViewsOf_ProviderHelpInfo(sharedControls)); yield return new ExtendedTypeDefinition( "FaqHelpInfo", ViewsOf_FaqHelpInfo(sharedControls)); yield return new ExtendedTypeDefinition( "GeneralHelpInfo", ViewsOf_GeneralHelpInfo(sharedControls)); yield return new ExtendedTypeDefinition( "GlossaryHelpInfo", ViewsOf_GlossaryHelpInfo(sharedControls)); yield return new ExtendedTypeDefinition( "ScriptHelpInfo", ViewsOf_ScriptHelpInfo(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#Examples", ViewsOf_MamlCommandHelpInfo_Examples(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#Example", ViewsOf_MamlCommandHelpInfo_Example(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#commandDetails", ViewsOf_MamlCommandHelpInfo_commandDetails(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#Parameters", ViewsOf_MamlCommandHelpInfo_Parameters(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#Parameter", ViewsOf_MamlCommandHelpInfo_Parameter(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#Syntax", ViewsOf_MamlCommandHelpInfo_Syntax(sharedControls)); var td18 = new ExtendedTypeDefinition( "MamlDefinitionTextItem", ViewsOf_MamlDefinitionTextItem_MamlOrderedListTextItem_MamlParaTextItem_MamlUnorderedListTextItem(sharedControls)); td18.TypeNames.Add("MamlOrderedListTextItem"); td18.TypeNames.Add("MamlParaTextItem"); td18.TypeNames.Add("MamlUnorderedListTextItem"); yield return td18; yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#inputTypes", ViewsOf_MamlCommandHelpInfo_inputTypes(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#nonTerminatingErrors", ViewsOf_MamlCommandHelpInfo_nonTerminatingErrors(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#terminatingErrors", ViewsOf_MamlCommandHelpInfo_terminatingErrors(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#relatedLinks", ViewsOf_MamlCommandHelpInfo_relatedLinks(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#returnValues", ViewsOf_MamlCommandHelpInfo_returnValues(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#alertSet", ViewsOf_MamlCommandHelpInfo_alertSet(sharedControls)); yield return new ExtendedTypeDefinition( "MamlCommandHelpInfo#details", ViewsOf_MamlCommandHelpInfo_details(sharedControls)); }
/// <summary> /// Initiate an instance for type configuration entry. /// </summary> /// <param name="typeDefinition"></param> public FormatConfigurationEntry(ExtendedTypeDefinition typeDefinition) : base("*") { if (typeDefinition == null) { throw PSTraceSource.NewArgumentNullException("typeDefinition"); } FormatData = typeDefinition; }
internal static IEnumerable<ExtendedTypeDefinition> GetFormatData() { var AvailableModules_GroupingFormat = CustomControl.Create() .StartEntry() .StartFrame(leftIndent: 4) .AddText(FileSystemProviderStrings.DirectoryDisplayGrouping) .AddScriptBlockExpressionBinding(@"Split-Path -Parent $_.Path | %{ if([Version]::TryParse((Split-Path $_ -Leaf), [ref]$null)) { Split-Path -Parent $_} else {$_} } | Split-Path -Parent") .AddNewline() .EndFrame() .EndEntry() .EndControl(); var ByteCollection_GroupHeader = CustomControl.Create() .StartEntry() .StartFrame() .AddScriptBlockExpressionBinding(@" $header = "" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"" if($_.Path) { $header = "" "" + [Microsoft.PowerShell.Commands.UtilityResources]::FormatHexPathPrefix + $_.Path + ""`r`n`r`n"" + $header } $header ") .EndFrame() .EndEntry() .EndControl(); var sharedControls = new CustomControl[] { AvailableModules_GroupingFormat, ByteCollection_GroupHeader }; yield return new ExtendedTypeDefinition( "System.RuntimeType", ViewsOf_System_RuntimeType()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.MemberDefinition", ViewsOf_Microsoft_PowerShell_Commands_MemberDefinition()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.GroupInfo", ViewsOf_Microsoft_PowerShell_Commands_GroupInfo()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.GroupInfoNoElement", ViewsOf_Microsoft_PowerShell_Commands_GroupInfoNoElement()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.HistoryInfo", ViewsOf_Microsoft_PowerShell_Commands_HistoryInfo()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.MatchInfo", ViewsOf_Microsoft_PowerShell_Commands_MatchInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.PSVariable", ViewsOf_System_Management_Automation_PSVariable()); yield return new ExtendedTypeDefinition( "System.Management.Automation.PathInfo", ViewsOf_System_Management_Automation_PathInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.CommandInfo", ViewsOf_System_Management_Automation_CommandInfo()); var td10 = new ExtendedTypeDefinition( "System.Management.Automation.AliasInfo", ViewsOf_System_Management_Automation_AliasInfo_System_Management_Automation_ApplicationInfo_System_Management_Automation_CmdletInfo_System_Management_Automation_ExternalScriptInfo_System_Management_Automation_FilterInfo_System_Management_Automation_FunctionInfo_System_Management_Automation_ScriptInfo()); td10.TypeNames.Add("System.Management.Automation.ApplicationInfo"); td10.TypeNames.Add("System.Management.Automation.CmdletInfo"); td10.TypeNames.Add("System.Management.Automation.ExternalScriptInfo"); td10.TypeNames.Add("System.Management.Automation.FilterInfo"); td10.TypeNames.Add("System.Management.Automation.FunctionInfo"); td10.TypeNames.Add("System.Management.Automation.ScriptInfo"); yield return td10; yield return new ExtendedTypeDefinition( "System.Management.Automation.Runspaces.TypeData", ViewsOf_System_Management_Automation_Runspaces_TypeData()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.ControlPanelItem", ViewsOf_Microsoft_PowerShell_Commands_ControlPanelItem()); yield return new ExtendedTypeDefinition( "System.Management.Automation.ApplicationInfo", ViewsOf_System_Management_Automation_ApplicationInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.ScriptInfo", ViewsOf_System_Management_Automation_ScriptInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.ExternalScriptInfo", ViewsOf_System_Management_Automation_ExternalScriptInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.FunctionInfo", ViewsOf_System_Management_Automation_FunctionInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.FilterInfo", ViewsOf_System_Management_Automation_FilterInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.AliasInfo", ViewsOf_System_Management_Automation_AliasInfo()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.ListCommand+MemberInfo", ViewsOf_Microsoft_PowerShell_Commands_ListCommand_MemberInfo()); var td20 = new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.ActiveDirectoryProvider+ADPSDriveInfo", ViewsOf_Microsoft_PowerShell_Commands_ActiveDirectoryProvider_ADPSDriveInfo_System_Management_Automation_PSDriveInfo()); td20.TypeNames.Add("System.Management.Automation.PSDriveInfo"); yield return td20; yield return new ExtendedTypeDefinition( "System.Management.Automation.ProviderInfo", ViewsOf_System_Management_Automation_ProviderInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.CmdletInfo", ViewsOf_System_Management_Automation_CmdletInfo()); var td23 = new ExtendedTypeDefinition( "System.Management.Automation.FilterInfo", ViewsOf_System_Management_Automation_FilterInfo_System_Management_Automation_FunctionInfo()); td23.TypeNames.Add("System.Management.Automation.FunctionInfo"); yield return td23; yield return new ExtendedTypeDefinition( "System.Management.Automation.PSDriveInfo", ViewsOf_System_Management_Automation_PSDriveInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.ShellVariable", ViewsOf_System_Management_Automation_ShellVariable()); yield return new ExtendedTypeDefinition( "System.Management.Automation.ScriptBlock", ViewsOf_System_Management_Automation_ScriptBlock()); yield return new ExtendedTypeDefinition( "System.Management.Automation.ErrorRecord", ViewsOf_System_Management_Automation_ErrorRecord()); yield return new ExtendedTypeDefinition( "System.Management.Automation.WarningRecord", ViewsOf_System_Management_Automation_WarningRecord()); yield return new ExtendedTypeDefinition( "Deserialized.System.Management.Automation.WarningRecord", ViewsOf_Deserialized_System_Management_Automation_WarningRecord()); yield return new ExtendedTypeDefinition( "System.Management.Automation.InformationRecord", ViewsOf_System_Management_Automation_InformationRecord()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.ByteCollection", ViewsOf_Microsoft_PowerShell_Commands_ByteCollection(sharedControls)); yield return new ExtendedTypeDefinition( "System.Exception", ViewsOf_System_Exception()); yield return new ExtendedTypeDefinition( "System.Management.Automation.CommandParameterSetInfo", ViewsOf_System_Management_Automation_CommandParameterSetInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.Runspaces.Runspace", ViewsOf_System_Management_Automation_Runspaces_Runspace()); yield return new ExtendedTypeDefinition( "System.Management.Automation.Runspaces.PSSession", ViewsOf_System_Management_Automation_Runspaces_PSSession()); yield return new ExtendedTypeDefinition( "System.Management.Automation.Job", ViewsOf_System_Management_Automation_Job()); yield return new ExtendedTypeDefinition( "Deserialized.Microsoft.PowerShell.Commands.TextMeasureInfo", ViewsOf_Deserialized_Microsoft_PowerShell_Commands_TextMeasureInfo()); yield return new ExtendedTypeDefinition( "Deserialized.Microsoft.PowerShell.Commands.GenericMeasureInfo", ViewsOf_Deserialized_Microsoft_PowerShell_Commands_GenericMeasureInfo()); yield return new ExtendedTypeDefinition( "System.Management.Automation.CallStackFrame", ViewsOf_System_Management_Automation_CallStackFrame()); var td40 = new ExtendedTypeDefinition( "System.Management.Automation.CommandBreakpoint", ViewsOf_BreakpointTypes()); td40.TypeNames.Add("System.Management.Automation.LineBreakpoint"); td40.TypeNames.Add("System.Management.Automation.VariableBreakpoint"); yield return td40; yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration", ViewsOf_Microsoft_PowerShell_Commands_PSSessionConfigurationCommands_PSSessionConfiguration()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.ComputerChangeInfo", ViewsOf_Microsoft_PowerShell_Commands_ComputerChangeInfo()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.RenameComputerChangeInfo", ViewsOf_Microsoft_PowerShell_Commands_RenameComputerChangeInfo()); yield return new ExtendedTypeDefinition( "ModuleInfoGrouping", ViewsOf_ModuleInfoGrouping(sharedControls)); yield return new ExtendedTypeDefinition( "System.Management.Automation.PSModuleInfo", ViewsOf_System_Management_Automation_PSModuleInfo()); var td46 = new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject", ViewsOf_Microsoft_PowerShell_Commands_BasicHtmlWebResponseObject_Microsoft_PowerShell_Commands_HtmlWebResponseObject()); td46.TypeNames.Add("Microsoft.PowerShell.Commands.HtmlWebResponseObject"); yield return td46; yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.WebResponseObject", ViewsOf_Microsoft_PowerShell_Commands_WebResponseObject()); yield return new ExtendedTypeDefinition( "Microsoft.Powershell.Utility.FileHash", ViewsOf_Microsoft_Powershell_Utility_FileHash()); yield return new ExtendedTypeDefinition( "Microsoft.PowerShell.Commands.PSRunspaceDebug", ViewsOf_Microsoft_PowerShell_Commands_PSRunspaceDebug()); }