Exemple #1
0
        private static IEnumerable <FormatViewDefinition> ViewsOf_FileSystemTypes(CustomControl[] sharedControls)
        {
            const string LengthScriptBlock =
                @"if ($_ -is [System.IO.DirectoryInfo]) { return '' }
if ($_.Attributes -band [System.IO.FileAttributes]::Offline)
{
    return '({0})' -f $_.Length
}
return $_.Length";

            yield return(new FormatViewDefinition("children",
                                                  TableControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddHeader(Alignment.Left, label: "Mode", width: 7)
                                                  .AddHeader(Alignment.Right, label: "LastWriteTime", width: 25)
                                                  .AddHeader(Alignment.Right, label: "Length", width: 14)
                                                  .AddHeader()
                                                  .StartRowDefinition(wrap: true)
                                                  .AddPropertyColumn("Mode")
                                                  .AddScriptBlockColumn(@"
                                    [String]::Format(""{0,10} {1,8}"", $_.LastWriteTime.ToString(""d""), $_.LastWriteTime.ToString(""t""))
                                ")
                                                  .AddScriptBlockColumn(LengthScriptBlock)
                                                  .AddPropertyColumn("Name")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("children",
                                                  ListControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .StartEntry(entrySelectedByType: new[] { "System.IO.FileInfo" })
                                                  .AddItemProperty(@"Name")
                                                  .AddItemScriptBlock(LengthScriptBlock, label: "Length")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .AddItemProperty(@"VersionInfo")
                                                  .EndEntry()
                                                  .StartEntry()
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .EndEntry()
                                                  .EndList()));

            yield return(new FormatViewDefinition("children",
                                                  WideControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddPropertyEntry("Name")
                                                  .AddPropertyEntry("Name", format: "[{0}]", entrySelectedByType: new[] { "System.IO.DirectoryInfo" })
                                                  .EndWideControl()));
        }
Exemple #2
0
        private static IEnumerable <FormatViewDefinition> ViewsOf_CertificateProviderTypes()
        {
            yield return(new FormatViewDefinition("ThumbprintList",
                                                  ListControl.Create()
                                                  .StartEntry(entrySelectedByType: new[] { "Microsoft.PowerShell.Commands.X509StoreLocation" })
                                                  .AddItemProperty(@"Location")
                                                  .AddItemProperty(@"StoreNames")
                                                  .EndEntry()
                                                  .StartEntry(entrySelectedByType: new[] { "System.Security.Cryptography.X509Certificates.X509Store" })
                                                  .AddItemProperty(@"Name")
                                                  .EndEntry()
                                                  .StartEntry()
                                                  .AddItemScriptBlock(@"$_.SubjectName.Name", label: "Subject")
                                                  .AddItemScriptBlock(@"$_.IssuerName.Name", label: "Issuer")
                                                  .AddItemProperty(@"Thumbprint")
                                                  .AddItemProperty(@"FriendlyName")
                                                  .AddItemProperty(@"NotBefore")
                                                  .AddItemProperty(@"NotAfter")
                                                  .AddItemProperty(@"Extensions")
                                                  .EndEntry()
                                                  .EndList()));

            yield return(new FormatViewDefinition("ThumbprintWide",
                                                  WideControl.Create()
                                                  .GroupByProperty("PSParentPath")
                                                  .AddPropertyEntry("Thumbprint")
                                                  .EndWideControl()));

            yield return(new FormatViewDefinition("PathOnly",
                                                  ListControl.Create()
                                                  .StartEntry()
                                                  .AddItemProperty(@"PSPathPath")
                                                  .EndEntry()
                                                  .StartEntry(entrySelectedByType: new[] { "Microsoft.PowerShell.Commands.X509StoreLocation" })
                                                  .AddItemProperty(@"PSPathPath")
                                                  .EndEntry()
                                                  .StartEntry(entrySelectedByType: new[] { "System.Security.Cryptography.X509Certificates.X509Store" })
                                                  .AddItemProperty(@"PSPath")
                                                  .EndEntry()
                                                  .EndList()));
        }
Exemple #3
0
        private static IEnumerable <FormatViewDefinition> ViewsOf_System_Management_Automation_Signature(CustomControl[] sharedControls)
        {
            yield return(new FormatViewDefinition("PSThumbprintTable",
                                                  TableControl.Create()
                                                  .GroupByScriptBlock("split-path $_.Path", customControl: sharedControls[0])
                                                  .AddHeader(label: "SignerCertificate", width: 41)
                                                  .AddHeader()
                                                  .AddHeader(label: "Path")
                                                  .StartRowDefinition()
                                                  .AddScriptBlockColumn("$_.SignerCertificate.Thumbprint")
                                                  .AddPropertyColumn("Status")
                                                  .AddScriptBlockColumn("split-path $_.Path -leaf")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("PSThumbprintWide",
                                                  WideControl.Create()
                                                  .GroupByScriptBlock("split-path $_.Path", customControl: sharedControls[0])
                                                  .AddScriptBlockEntry(@"""$(split-path $_.Path -leaf): $($_.Status)""")
                                                  .EndWideControl()));
        }
Exemple #4
0
        private static IEnumerable <FormatViewDefinition> ViewsOf_FileSystemTypes(CustomControl[] sharedControls)
        {
            yield return(new FormatViewDefinition("children",
                                                  TableControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddHeader(Alignment.Left, label: "Mode", width: 7)
                                                  .AddHeader(Alignment.Right, label: "LastWriteTime", width: 26)
                                                  .AddHeader(Alignment.Right, label: "Length", width: 14)
                                                  .AddHeader(Alignment.Left, label: "Name")
                                                  .StartRowDefinition(wrap: true)
                                                  .AddPropertyColumn("ModeWithoutHardLink")
                                                  .AddPropertyColumn("LastWriteTimeString")
                                                  .AddPropertyColumn("LengthString")
                                                  .AddPropertyColumn("NameString")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("childrenWithHardlink",
                                                  TableControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddHeader(Alignment.Left, label: "Mode", width: 7)
                                                  .AddHeader(Alignment.Right, label: "LastWriteTime", width: 26)
                                                  .AddHeader(Alignment.Right, label: "Length", width: 14)
                                                  .AddHeader(Alignment.Left, label: "Name")
                                                  .StartRowDefinition(wrap: true)
                                                  .AddPropertyColumn("Mode")
                                                  .AddPropertyColumn("LastWriteTimeString")
                                                  .AddPropertyColumn("LengthString")
                                                  .AddPropertyColumn("NameString")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("children",
                                                  ListControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .StartEntry(entrySelectedByType: new[] { "System.IO.FileInfo" })
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty("LengthString", label: "Length")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .AddItemProperty(@"VersionInfo")
                                                  .EndEntry()
                                                  .StartEntry()
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .EndEntry()
                                                  .EndList()));

            yield return(new FormatViewDefinition("children",
                                                  WideControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddPropertyEntry("Name")
                                                  .AddPropertyEntry("Name", format: "[{0}]", entrySelectedByType: new[] { "System.IO.DirectoryInfo" })
                                                  .EndWideControl()));
        }
Exemple #5
0
        private static IEnumerable <FormatViewDefinition> ViewsOf_FileSystemTypes(CustomControl[] sharedControls)
        {
#if UNIX
            if (ExperimentalFeature.IsEnabled("PSUnixFileStat"))
            {
                yield return(new FormatViewDefinition("childrenWithUnixStat",
                                                      TableControl.Create()
                                                      .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                      .AddHeader(Alignment.Left, label: "UnixMode", width: 10)
                                                      .AddHeader(Alignment.Left, label: "User", width: 16)
                                                      .AddHeader(Alignment.Left, label: "Group", width: 16)
                                                      .AddHeader(Alignment.Right, label: "LastWriteTime", width: 18)
                                                      .AddHeader(Alignment.Right, label: "Size", width: 14)
                                                      .AddHeader(Alignment.Left, label: "Name")
                                                      .StartRowDefinition(wrap: true)
                                                      .AddPropertyColumn("UnixMode")
                                                      .AddPropertyColumn("User")
                                                      .AddPropertyColumn("Group")
                                                      .AddScriptBlockColumn(scriptBlock: @"'{0:d} {0:HH}:{0:mm}' -f $_.LastWriteTime")
                                                      .AddPropertyColumn("Size")
                                                      .AddPropertyColumn("NameString")
                                                      .EndRowDefinition()
                                                      .EndTable()));
            }
#endif

            yield return(new FormatViewDefinition("children",
                                                  TableControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddHeader(Alignment.Left, label: "Mode", width: 7)
                                                  .AddHeader(Alignment.Right, label: "LastWriteTime", width: 26)
                                                  .AddHeader(Alignment.Right, label: "Length", width: 14)
                                                  .AddHeader(Alignment.Left, label: "Name")
                                                  .StartRowDefinition(wrap: true)
                                                  .AddPropertyColumn("ModeWithoutHardLink")
                                                  .AddPropertyColumn("LastWriteTimeString")
                                                  .AddPropertyColumn("LengthString")
                                                  .AddPropertyColumn("NameString")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("childrenWithHardlink",
                                                  TableControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddHeader(Alignment.Left, label: "Mode", width: 7)
                                                  .AddHeader(Alignment.Right, label: "LastWriteTime", width: 26)
                                                  .AddHeader(Alignment.Right, label: "Length", width: 14)
                                                  .AddHeader(Alignment.Left, label: "Name")
                                                  .StartRowDefinition(wrap: true)
                                                  .AddPropertyColumn("Mode")
                                                  .AddPropertyColumn("LastWriteTimeString")
                                                  .AddPropertyColumn("LengthString")
                                                  .AddPropertyColumn("NameString")
                                                  .EndRowDefinition()
                                                  .EndTable()));

            yield return(new FormatViewDefinition("children",
                                                  ListControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .StartEntry(entrySelectedByType: new[] { "System.IO.FileInfo" })
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty("LengthString", label: "Length")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .AddItemProperty(@"VersionInfo")
                                                  .EndEntry()
                                                  .StartEntry()
                                                  .AddItemProperty(@"Name")
                                                  .AddItemProperty(@"CreationTime")
                                                  .AddItemProperty(@"LastWriteTime")
                                                  .AddItemProperty(@"LastAccessTime")
                                                  .AddItemProperty(@"Mode")
                                                  .AddItemProperty(@"LinkType")
                                                  .AddItemProperty(@"Target")
                                                  .EndEntry()
                                                  .EndList()));

            yield return(new FormatViewDefinition("children",
                                                  WideControl.Create()
                                                  .GroupByProperty("PSParentPath", customControl: sharedControls[0])
                                                  .AddPropertyEntry("Name")
                                                  .AddPropertyEntry("Name", format: "[{0}]", entrySelectedByType: new[] { "System.IO.DirectoryInfo" })
                                                  .EndWideControl()));
        }