Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Show compistion doesn't work when static methods #108

Open
Stephanevg opened this issue Jun 5, 2019 · 1 comment
Open

-Show compistion doesn't work when static methods #108

Stephanevg opened this issue Jun 5, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@Stephanevg
Copy link
Owner

Result of image below
image

@Stephanevg Stephanevg added the bug Something isn't working label Jun 5, 2019
@Stephanevg
Copy link
Owner Author

Stephanevg commented Oct 29, 2019

Another example:

Enum RunSourceType {
    json
    xml
    database
}

Class PCCRunDocument {

    [String]$ComputerName
    [String]$PackageName
    [DateTime]$Executiondate
    [RunSourceType]$FileType
    [Object]$Data
    Hidden [String]$Source
    #[PCCRunDocument]::New('C:\Users\taavast3\OneDrive\Repo\Projects\Clients\Swisscom\ESC\PCCComplianceChecks\Tests\PCC_SAGITTA5170017_PCC.chk.esc.win.spdn_20191023-172317.json')
    
    
    
    PccRunDocument([system.io.fileInfo]$Document){
        $d = $Document.Name.Split('_')
        $This.ComputerName = $d[1]
        $This.PackageName = $d[2]
        If($d[3] -match "^(?'year'\d{4})(?'month'\d{2})(?'day'\d{2})-(?'hour'\d{2})(?'minute'\d{2})(?'second'\d{2}).*$"){
            $this.Executiondate = Get-date -Year $Matches.Year -Month $Matches.Month -Day $Matches.Day -Hour $Matches.Hour -Minute $Matches.minute -Second $Matches.second
        }
        $This.FileType = $Document.Extension.Replace(".","")
        $this.Data = gc $Document.FullName | ConvertFrom-Json
        $This.Source = $Document
    }

    <#
    
    static [PccRunDocument[]]  GetPccRunDocument([System.IO.DirectoryInfo]$Folder){

        $RunDocuments = Find-pccRunDocument -Path $Folder
        $AllDocuments = @()
        Foreach($Doc in $RunDocuments){
            $AllDocuments = [PCCRunDocument]::New($Doc)
        }

        Return $AllDocuments
    }
    #>


}

Class PCCRunDocumentFactory{


    <#
        static [PCCRunDocument[]] Create([String]$Path){
        $Item = Get-Item -Path $Path
        $Return = @()
        Switch($Item.GetType().FullName){
            "system.io.FileInfo"{
                $Return += [PCCRunDocument]::New($Item)
            }
            "system.io.DirectoryInfo"{
                $Files = Find-pccRunDocument -Path $Item.FullName
                Foreach($File in $Files){

                    $Return += [PCCRunDocument]::New($File)
                }
            }
        }

        return $Return
    }
    #>


    static [PCCRunDocuments] Create([String]$Path){
        $Item = Get-Item -Path $Path
        $Return = [PccRunDocuments]::New()
        Switch($Item.GetType().FullName){
            "system.io.FileInfo"{
                $Return.AddRunDocument([PCCRunDocument]::New($Item))
            }
            "system.io.DirectoryInfo"{
                $Files = Find-pccRunDocument -Path $Item.FullName
                Foreach($File in $Files){

                    $Return.AddRunDocument([PCCRunDocument]::New($File))
                }
            }
        }

        return $Return
    }

}

Class PCCRunDocuments {
    [System.Collections.Generic.List[PCCRunDocument]]$RunDocuments = @()

    PccRunDocuments(){

    }

    AddRunDocument([PccRunDocument[]]$Document){

        Foreach($doc in $Document){
            $this.RunDocuments.Add($doc)
        }
    }

    [System.Collections.Generic.List[PCCRunDocument]]GetRunDocuments(){
        return $This.RunDocuments
    }

    [PCCRunDocument[]] GetRunDocumentsOfComputer([String]$ComputerName){
        $Return = @()

        $Return += $This.RunDocuments | ? {$_.ComputerName -eq $ComputerName}

        return $Return
    }

    [PCCRunDocument[]] GetRunDocumentsOfPackage([String]$PackageName){
        $Return = @()

        $Return += $This.RunDocuments | ? {$_.PackageName -eq $PackageName}

        return $Return
    }
}

REturns

image

Write-CUClassDiagram -Path C:\Users\taavast3\OneDrive\Repo\Projects\Clients\Swisscom\ESC\PCCComplianceChecks\Code\Classes\Class.PCCPackage.ps1 -Show -ShowComposition -Verbose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant