Carbon.types.ps1xml

<?xml version="1.0" encoding="utf-8"?>
<!--
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
    
       http://www.apache.org/licenses/LICENSE-2.0
    
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<Types>
    <Type>
        <Name>Carbon.Firewall.Rule</Name>
        <Members>
            <AliasProperty>
                <Name>LocalIP</Name>
                <ReferencedMemberName>
                    LocalIPAddress
                </ReferencedMemberName>
            </AliasProperty>
            <AliasProperty>
                <Name>RemoteIP</Name>
                <ReferencedMemberName>
                    RemoteIPAddress
                </ReferencedMemberName>
            </AliasProperty>
        </Members>
    </Type>
    <Type>
        <Name>Carbon.TaskScheduler.TaskInfo</Name>
        <Members>
            <AliasProperty>
                <Name>State</Name>
                <ReferencedMemberName>Status</ReferencedMemberName>
            </AliasProperty>
            <ScriptProperty>
                <Name>FullName</Name>
                <GetScriptBlock>
                    return Join-Path -Path $this.TaskPath -ChildPath $this.TaskName
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
    <Type>
        <Name>System.Diagnostics.Process</Name>
        <Members>
            <ScriptProperty>
                <Name>ParentProcessID</Name>
                <GetScriptBlock>
                    $filter = "ProcessID='{0}'" -f $this.Id
                    $process = Get-WmiObject Win32_Process -Filter $filter
                    $process.ParentProcessID
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
    <Type>
        <Name>System.DirectoryServices.AccountManagement.Principal</Name>
        <Members>
            <ScriptProperty>
                <Name>ConnectedServer</Name>
                <GetScriptBlock>
                    $this.Context.ConnectedServer
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
    <Type>
        <Name>System.IO.DirectoryInfo</Name>
        <Members>
            <ScriptProperty>
                <Name>IsJunction</Name>
                <GetScriptBlock>
                    (($this.Attributes -band [IO.FileAttributes]::ReparsePoint) -eq [IO.FileAttributes]::ReparsePoint)
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>TargetPath</Name>
                <GetScriptBlock>
                    if( -not $this.IsJunction )
                    {
                        return
                    }
                     
                    [Carbon.IO.JunctionPoint]::GetTarget( $this.FullName )
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
    <Type>
        <Name>System.Security.Cryptography.X509Certificates.X509Certificate2</Name>
        <Members>
            <ScriptProperty>
                <Name>IssuedTo</Name>
                <GetScriptBlock>
                    $this.GetNameInfo( 'SimpleName', $false )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>IssuedBy</Name>
                <GetScriptBlock>
                    $this.GetNameInfo( 'SimpleName', $true )
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
    <Type>
        <Name>System.Security.Cryptography.X509Certificates.X509Store</Name>
        <Members>
            <ScriptProperty>
                <Name>DisplayName</Name>
                <GetScriptBlock>
                    switch( $this.Name )
                    {
                        'AddressBook' { return 'Other People' }
                        'AuthRoot' { return 'Third-Party Root Certification Authorities' }
                        'CA' { return 'Intermediate Certification Authorities' }
                        'CertificateAuthority' { return 'Intermediate Certification Authorities' }
                        'Disallowed' { return 'Untrusted Certificates' }
                        'My' { return 'Personal' }
                        'Root' { return 'Trusted Root Certification Authorities' }
                        'TrustedPeople' { return 'Trusted People' }
                        'TrustedPublisher' { return 'Trusted Publishers' }
                        default { return '' }
                    }
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>StoreName</Name>
                <GetScriptBlock>
                    if( $this.Name -eq 'CA' )
                    {
                        return [Security.Cryptography.X509Certificates.StoreName]::CertificateAuthority
                    }
 
                    foreach( $value in ([Enum]::GetValues([Security.Cryptography.X509Certificates.StoreName])) )
                    {
                        if( $this.Name -eq $value.ToString() )
                        {
                            return $value
                        }
                    }
 
                    return ''
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
    <Type>
        <Name>System.ServiceProcess.ServiceController</Name>
        <Members>
            <ScriptMethod>
                <Name>GetServiceConfigProperty</Name>
                <Script>
                    param(
                        [Parameter(Mandatory=$true)]
                        [string]
                        # The name of the property to retrieve.
                        $Name
                    )
 
                    Set-StrictMode -Version 'Latest'
 
                    if( -not ($this | Get-Member -Name 'Configuration') )
                    {
                        $value = $null
                        try
                        {
                            $value = New-Object 'Carbon.Service.ServiceInfo' $this.Name,$this.MachineName
                        }
                        catch
                        {
                            $ex = $_.Exception
                            while( $ex.InnerException )
                            {
                                $ex = $ex.InnerException
                            }
                            if( $Global:Error.Count -gt 0 )
                            {
                                $Global:Error.RemoveAt(0)
                            }
                            Write-Error ('Failed to load extended service information for service ''{0}'' on ''{1}'': {2}' -f $this.Name,$this.MachineName,$ex.Message)
                        }
                        Add-Member -InputObject $this -MemberType NoteProperty -Name 'Configuration' -Value $value
                    }
 
                    if( -not $this.Configuration )
                    {
                        return
                    }
 
                    if( -not ($this.Configuration | Get-Member -Name $Name) )
                    {
                        return
                    }
 
                    return $this.Configuration.$Name
                </Script>
            </ScriptMethod>
            <ScriptProperty>
                <Name>Description</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'Description' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>ErrorControl</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'ErrorControl' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>FailureProgram</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'FailureProgram' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>FirstFailure</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'FirstFailure' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>LoadOrderGroup</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'LoadOrderGroup' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>Path</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'Path' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RebootDelay</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RebootDelay' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RebootDelayMinutes</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RebootDelayMinutes' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RebootMessage</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RebootMessage' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>ResetPeriod</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'ResetPeriod' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>ResetPeriodDays</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'ResetPeriodDays' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RestartDelay</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RestartDelay' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RestartDelayMinutes</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RestartDelayMinutes' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RunCommandDelay</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RunCommandDelay' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>RunCommandDelayMinutes</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'RunCommandDelayMinutes' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>SecondFailure</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'SecondFailure' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>StartMode</Name>
                <GetScriptBlock>
                    $startType = $this.GetServiceConfigProperty( 'StartType' )
                    if( $startType -ne $null )
                    {
                        [System.ServiceProcess.ServiceStartMode][int]$startType
                    }
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>StartType</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'StartType' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>TagID</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'TagID' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>ThirdFailure</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'ThirdFailure' )
                </GetScriptBlock>
            </ScriptProperty>
            <ScriptProperty>
                <Name>UserName</Name>
                <GetScriptBlock>
                    $this.GetServiceConfigProperty( 'UserName' )
                </GetScriptBlock>
            </ScriptProperty>
        </Members>
    </Type>
</Types>