Advertisement
Guest User

Iterating a domainmodel

a guest
Jun 19th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #open domainmodel files in folder Model and iterate over the items...
  2. $files = (Get-Project $ProjectName).ProjectItems | Where-Object {$_.Name -eq "Model"} | ForEach{$_.ProjectItems }
  3. #activate each doc...
  4. $files | ForEach{$_.Open(); $_.Document.Activate()}
  5.  
  6. Start-Sleep -s 2
  7. #Find all namespaces
  8. $namespaces = $DTE.Documents | ForEach{$_.ProjectItem.FileCodeModel.CodeElements | Where-Object{$_.Kind -eq 5}}
  9. #Find classes  
  10. $classes = $namespaces | ForEach{$_.Children}
  11. #For each class scaffold only the ones inheriting "PersistentEntity"
  12. $classes | ForEach{    
  13.     $current = $_
  14.     $_.Bases | ForEach{
  15.         if($_.Name -eq "PersistentEntity"){                        
  16.             Scaffold CodePlanner.ScaffoldBackend.For $current.Name -Force:$Force           
  17.         }
  18.     }      
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement