Last active
December 14, 2015 20:58
-
-
Save achingono/5147395 to your computer and use it in GitHub Desktop.
T4 Scaffolder using the the module created by @ulfbjo [ http://pastebin.com/rjYdsuD7 ]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[T4Scaffolding.Scaffolder(Description = "Enter a description of Generator here")][CmdletBinding()] | |
param( | |
[parameter(Mandatory = $true, Position = 0)][string]$ParentTypeName, | |
[string]$Project, | |
[string]$CodeLanguage, | |
[string[]]$TemplateFolders, | |
[switch]$Force = $false | |
) | |
$parentType = Get-ProjectType $ParentTypeName | |
$parentNamespace = $parentType.Namespace.Name | |
$derivingTypes = @() | |
# Get the namespaces that match the parent type | |
$namespaces = $parentType.ProjectItem.ContainingProject.CodeModel.CodeElements | Where-Object{ $parentNamespace.StartsWith($_.FullName) } | |
$namespaces | ForEach { | |
# find child namespaces matching the parent type | |
$_.Members | Where-Object{ $parentNamespace.StartsWith($_.FullName) } | ForEach { | |
# find classes in namespace | |
$_.Members | Where-Object{ $_.Kind -eq 1 } | ForEach { | |
$current = $_ | |
# check if class inherits from parent type | |
$current.Bases | ForEach { | |
if($_.FullName -eq $parentType.FullName){ | |
$derivingTypes += $current | |
} | |
} | |
} | |
} | |
} | |
$derivingTypes | ForEach { | |
Write-Host $_.Name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment