< Back

Test-CTypeDotNetTypeIsDefined

Mon Jan 13, 2020 8:21 am

NAME Test-CTypeDotNetTypeIsDefined



SYNOPSIS

Test whether a type is already defined.





SYNTAX

Test-CTypeDotNetTypeIsDefined [-TypeName] <String> [<CommonParameters>]





DESCRIPTION

Test whether a type is already defined.

Note that types may not be removed from a PowerShell session once defined.





PARAMETERS

-TypeName <String>

Name for the type.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.Boolean





NOTES





This method uses .NET reflection to search for the type, so it can take 100-200ms to run.

Use it sparingly. Consider using Test-CTypeIsDefined instead.



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>if (-not (Test-CTypeDotNetTypeIsDefined MyCompany.MyNamespace.ClassName))



{

CType MyCompany.MyNamespace.ClassName2 {

CTypeProperty int Property1

CTypeProperty string Property2

CTypeProperty boolean Property3

}

}











RELATED LINKS

CType

Add-CType