Permalink
Browse files

init

  • Loading branch information...
1 parent d95b258 commit 152a595a8dbe9ad93bf989fd632fc088bee05cb9 @danielmoore danielmoore committed May 23, 2012
Showing with 682,059 additions and 9 deletions.
  1. +26 −0 Appendix A/GetFunction.ps1
  2. +35 −0 Appendix A/IndexText.ps1
  3. +4 −0 Appendix A/ProductivePowerShell.ps1
  4. +15 −0 Appendix A/RDP.ps1
  5. +14 −0 Appendix A/SearchGoogle.ps1
  6. +11 −0 Appendix A/StartPowerShell.ps1
  7. +20 −0 Appendix A/SubversionPrompt.ps1
  8. +6 −0 Appendix A/TimesConstruct.ps1
  9. +5,501 −0 Appendix A/holmes.txt
  10. +11 −0 LICENSE.md
  11. +42 −9 README.md
  12. +17 −0 chapter04/InvokeTemplate/CodeAst.ps1
  13. +15 −0 chapter04/InvokeTemplate/Invoke-Template.ps1
  14. +14 −0 chapter04/InvokeTemplate/Properties.xml
  15. +40 −0 chapter04/InvokeTemplate/Test-CodeAST.ps1
  16. +11 −0 chapter04/InvokeTemplate/Test-ComplexLogicTemplate.ps1
  17. +7 −0 chapter04/InvokeTemplate/Test-HTMLTemplate.ps1
  18. +13 −0 chapter04/InvokeTemplate/Test-MultipleTemplates.ps1
  19. +9 −0 chapter04/InvokeTemplate/Test-MultipleVariableTemplate.ps1
  20. +11 −0 chapter04/InvokeTemplate/Test-ReadXMLTemplate.ps1
  21. +17 −0 chapter04/InvokeTemplate/Test-UMLSyntax.ps1
  22. +10 −0 chapter04/InvokeTemplate/Test-UMLSyntaxWithFile.ps1
  23. +6 −0 chapter04/InvokeTemplate/Uml.txt
  24. +11 −0 chapter04/InvokeTemplate/etc/AstVisitAction.txt
  25. +14 −0 chapter04/InvokeTemplate/etc/CommandMatcher.txt
  26. +1 −0 chapter04/InvokeTemplate/etc/TestHtml.htm
  27. +1 −0 chapter04/InvokeTemplate/etc/privateSet.txt
  28. +1 −0 chapter04/InvokeTemplate/etc/properties.txt
  29. +47 −0 chapter04/InvokeTemplate/githubViewer.ps1
  30. +12 −0 chapter04/InvokeTemplate/html/Test-HTML.ps1
  31. +1 −0 chapter04/InvokeTemplate/html/body.htm
  32. +12 −0 chapter04/InvokeTemplate/html/header.htm
  33. +26 −0 chapter04/InvokeTemplate/html/test.htm
  34. +3 −0 chapter04/InvokeTemplate/properties.csv
  35. +13 −0 chapter04/ParseASingleFile.ps1
  36. +13 −0 chapter04/ParseCSharpFiles.ps1
  37. +34 −0 chapter04/Test-GetParameter.ps1
  38. +14 −0 chapter04/Test-MyMath.ps1
  39. +18 −0 chapter04/test.cs
  40. +18 −0 chapter04/test1.cs
  41. +29 −0 chapter05/BeaverMusic/.gitignore
  42. +16 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditDialogView.xaml
  43. +26 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditDialogView.xaml.cs
  44. +69 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditDialogViewModel.cs
  45. +53 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditView.xaml
  46. +12 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditView.xaml.cs
  47. +90 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditViewModel.cs
  48. +31 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumListView.xaml
  49. +14 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumListView.xaml.cs
  50. +84 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumListViewModel.cs
  51. +137 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/App.xaml
  52. +39 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/App.xaml.cs
  53. +146 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/BeaverMusic.UI.Shell.csproj
  54. +1 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/BeaverMusicProfile.ps1
  55. BIN chapter05/BeaverMusic/BeaverMusic.UI.Shell/ChinookData.xml
  56. +9 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/MainViewModel.cs
  57. +11 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/MainWindow.xaml
  58. +12 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/MainWindow.xaml.cs
  59. +72 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/PowerShellConsoleLauncher.cs
  60. +55 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/Properties/AssemblyInfo.cs
  61. +27 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/albums.csv
  62. +3 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/app.config
  63. +234 −0 chapter05/BeaverMusic/BeaverMusic.UI.Shell/test.ps1
  64. +85 −0 chapter05/BeaverMusic/BeaverMusic.UI/BeaverMusic.UI.csproj
  65. +133 −0 chapter05/BeaverMusic/BeaverMusic.UI/BindableBase.cs
  66. +81 −0 chapter05/BeaverMusic/BeaverMusic.UI/Controls/WatermarkTextBox.cs
  67. +99 −0 chapter05/BeaverMusic/BeaverMusic.UI/Controls/WatermarkTextBox.xaml
  68. +49 −0 chapter05/BeaverMusic/BeaverMusic.UI/DelegateCommand.cs
  69. +13 −0 chapter05/BeaverMusic/BeaverMusic.UI/IViewFactory.cs
  70. +57 −0 chapter05/BeaverMusic/BeaverMusic.UI/Properties/AssemblyInfo.cs
  71. +7 −0 chapter05/BeaverMusic/BeaverMusic.UI/Themes/Generic.xaml
  72. +165 −0 chapter05/BeaverMusic/BeaverMusic.UI/ViewElement.cs
  73. +95 −0 chapter05/BeaverMusic/BeaverMusic.UI/ViewFactory.cs
  74. +66 −0 chapter05/BeaverMusic/BeaverMusic.sln
  75. +24 −0 chapter05/BeaverMusic/BeaverMusic/Album.cs
  76. +65 −0 chapter05/BeaverMusic/BeaverMusic/AlbumRepository.cs
  77. +59 −0 chapter05/BeaverMusic/BeaverMusic/BeaverMusic.csproj
  78. +39 −0 chapter05/BeaverMusic/BeaverMusic/Composition/ExistingComposablePart.cs
  79. +21 −0 chapter05/BeaverMusic/BeaverMusic/Core/CloneFactory.cs
  80. +15 −0 chapter05/BeaverMusic/BeaverMusic/IAlbumRepository.cs
  81. +36 −0 chapter05/BeaverMusic/BeaverMusic/Properties/AssemblyInfo.cs
  82. +7 −0 chapter05/BeaverMusic/BeaverMusic/Scripting/IScriptingEngine.cs
  83. +14 −0 chapter05/BeaverMusic/BeaverMusic/Song.cs
  84. +98 −0 chapter05/BeaverMusic/EmbeddedPSConsole/EmbeddedPSConsole.csproj
  85. +77 −0 chapter05/BeaverMusic/EmbeddedPSConsole/PS.cs
  86. +53 −0 chapter05/BeaverMusic/EmbeddedPSConsole/PSConfig.cs
  87. +81 −0 chapter05/BeaverMusic/EmbeddedPSConsole/PSConsole.xaml
  88. +95 −0 chapter05/BeaverMusic/EmbeddedPSConsole/PSConsole.xaml.cs
  89. +55 −0 chapter05/BeaverMusic/EmbeddedPSConsole/Properties/AssemblyInfo.cs
  90. +63 −0 chapter05/BeaverMusic/EmbeddedPSConsole/Properties/Resources.Designer.cs
  91. +117 −0 chapter05/BeaverMusic/EmbeddedPSConsole/Properties/Resources.resx
  92. +26 −0 chapter05/BeaverMusic/EmbeddedPSConsole/Properties/Settings.Designer.cs
  93. +7 −0 chapter05/BeaverMusic/EmbeddedPSConsole/Properties/Settings.settings
  94. +29 −0 chapter05/EmbeddedPSConsole/.gitignore
  95. +23 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole.nuspec
  96. +20 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole.sln
  97. +29 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/.gitignore
  98. +94 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/EmbeddedPSConsole.csproj
  99. +77 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/PS.cs
  100. +53 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/PSConfig.cs
  101. +81 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/PSConsole.xaml
  102. +94 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/PSConsole.xaml.cs
  103. +55 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/Properties/AssemblyInfo.cs
  104. +63 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/Properties/Resources.Designer.cs
  105. +117 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/Properties/Resources.resx
  106. +26 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/Properties/Settings.Designer.cs
  107. +7 −0 chapter05/EmbeddedPSConsole/EmbeddedPSConsole/Properties/Settings.settings
  108. BIN chapter05/EmbeddedPSConsole/nuget/EmbeddedPSConsole.1.0.0.nupkg
  109. +13 −0 chapter06/BingFlights.ps1
  110. +4 −0 chapter06/Get-AlbumsCsv.ps1
  111. +2 −0 chapter06/Get-AlbumsCsvWithInvokeRestMethod.ps1
  112. +2 −0 chapter06/Get-AlbumsJSWithInvokeRestMethod.ps1
  113. +4 −0 chapter06/Get-AlbumsXml.ps1
  114. +2 −0 chapter06/Get-AlbumsXmlWithInvokeRestMethod.ps1
  115. +4 −0 chapter06/Get-RecallData.ps1
  116. +11 −0 chapter06/Get-WebData.ps1
  117. +11 −0 chapter06/GoogleFlightStatus.ps1
  118. +36 −0 chapter06/NYTSemanticAPI.ps1
  119. +3 −0 chapter06/NetWebclient.ps1
  120. +16 −0 chapter06/ParallelBlogFeed.ps1
  121. +5 −0 chapter06/SearchTwitter.ps1
  122. +27 −0 chapter06/StockWebService.ps1
  123. +66 −0 chapter07/PowerShellHighlighter.ps1
  124. +28 −0 chapter07/SearchTwitter.ps1
  125. +72 −0 chapter07/ShowUI/C#/GetReferencedCommand.cs
  126. +21 −0 chapter07/ShowUI/C#/LanguagePrimitivesValueConverter.cs
  127. +72 −0 chapter07/ShowUI/C#/OutXaml.cs
  128. +752 −0 chapter07/ShowUI/C#/PowerShellDataSource.cs
  129. +29 −0 chapter07/ShowUI/C#/ShowUICommand.cs
  130. +140 −0 chapter07/ShowUI/C#/ShowUIDependencyObjects.cs
  131. +521 −0 chapter07/ShowUI/C#/WPFJob.cs
  132. +81 −0 chapter07/ShowUI/CodeGenerator/Add-CodeGenerationRule.ps1
  133. BIN chapter07/ShowUI/CodeGenerator/Add-UIModule.ps1
  134. +473 −0 chapter07/ShowUI/CodeGenerator/ConvertFrom-TypeToCmdlet.ps1
  135. +98 −0 chapter07/ShowUI/CodeGenerator/ConvertTo-ParameterMetaData.ps1
  136. +29 −0 chapter07/ShowUI/CodeGenerator/Get-AssemblyName.ps1
  137. +178 −0 chapter07/ShowUI/CodeGenerator/InstallShowUIAssembly.ps1
  138. BIN chapter07/ShowUI/CodeGenerator/Rules/WPFCodeGenerationRules.ps1
  139. +112 −0 chapter07/ShowUI/CodeGenerator/Select-UIType.ps1
  140. +119 −0 chapter07/ShowUI/CommonControls/Edit-StringList.ps1
  141. +240 −0 chapter07/ShowUI/CommonControls/Get-Input.ps1
  142. +96 −0 chapter07/ShowUI/CommonControls/Select-Date.ps1
  143. +134 −0 chapter07/ShowUI/CommonControls/Select-ViaUI.ps1
  144. +279 −0 chapter07/ShowUI/CommonControls/Show-Clock.ps1
  145. +138 −0 chapter07/ShowUI/ConvertTo-ISEAddOn.ps1
  146. +12 −0 chapter07/ShowUI/Examples/AddGridRowExample.ps1
  147. +9 −0 chapter07/ShowUI/Examples/DataTemplate.ps1
  148. +5 −0 chapter07/ShowUI/Examples/DigitalClock.ps1
  149. +8 −0 chapter07/ShowUI/Examples/EllipseAnimation.ps1
  150. +18 −0 chapter07/ShowUI/Examples/GetSimpleDetails.ps1
  151. BIN chapter07/ShowUI/Examples/InvokeBackground.ps1
  152. +3 −0 chapter07/ShowUI/Examples/ListBoxSamples.ps1
  153. +14 −0 chapter07/ShowUI/Examples/ListView.ps1
  154. +40 −0 chapter07/ShowUI/Examples/ModuleExplorer.ps1
  155. +22 −0 chapter07/ShowUI/Examples/MoveControlExample.ps1
  156. +9 −0 chapter07/ShowUI/Examples/SelectEventLog.ps1
  157. +7 −0 chapter07/ShowUI/Examples/SimpleGradient.ps1
  158. +18 −0 chapter07/ShowUI/Examples/SimpleUserInputAndSplatting.ps1
  159. +8 −0 chapter07/ShowUI/Examples/SkewAnimation.ps1
  160. +15 −0 chapter07/ShowUI/Examples/Stopwatch.ps1
  161. BIN chapter07/ShowUI/Examples/VideoPlayer.ps1
  162. BIN chapter07/ShowUI/Examples/firstnamelastname.ps1
  163. +185 −0 chapter07/ShowUI/Export-Application.ps1
  164. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUI.CLR2.0.50727.5446.dll
  165. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUI.CLR4.0.30319.225.dll
  166. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUI.CLR4.0.30319.225.pdb
  167. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUI.CLR4.0.30319.239.dll
  168. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUI.CLR4.0.30319.239.pdb
  169. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUICore.CLR2.0.50727.5446.dll
  170. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUICore.CLR4.0.30319.225.dll
  171. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUICore.CLR4.0.30319.225.pdb
  172. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUICore.CLR4.0.30319.239.dll
  173. BIN chapter07/ShowUI/GeneratedAssemblies/ShowUICore.CLR4.0.30319.239.pdb
  174. +190,362 −0 chapter07/ShowUI/GeneratedCode/ShowUI.CLR2.0.50727.5446.cs
  175. +233,712 −0 chapter07/ShowUI/GeneratedCode/ShowUI.CLR4.0.30319.225.cs
  176. +233,712 −0 chapter07/ShowUI/GeneratedCode/ShowUI.CLR4.0.30319.239.cs
  177. +1,571 −0 chapter07/ShowUI/GeneratedCode/ShowUICore.CLR2.0.50727.5446.cs
  178. +1,543 −0 chapter07/ShowUI/GeneratedCode/ShowUICore.CLR4.0.30319.225.cs
  179. +1,543 −0 chapter07/ShowUI/GeneratedCode/ShowUICore.CLR4.0.30319.239.cs
  180. +10 −0 chapter07/ShowUI/Get-PowerShellCommand.ps1
  181. +80 −0 chapter07/ShowUI/Get-PowerShellDataSource.ps1
  182. +70 −0 chapter07/ShowUI/Get-PowerShellOutput.ps1
  183. +105 −0 chapter07/ShowUI/Get-ReferencedCommand.ps1
  184. +58 −0 chapter07/ShowUI/Get-UICommand.ps1
  185. +86 −0 chapter07/ShowUI/Get-UIValue.ps1
  186. +160 −0 chapter07/ShowUI/Invoke-Background.ps1
  187. +52 −0 chapter07/ShowUI/New-UIWidget.ps1
  188. +65 −0 chapter07/ShowUI/Register-PowerShellCommand.ps1
  189. +45 −0 chapter07/ShowUI/Set-UIValue.ps1
  190. +164 −0 chapter07/ShowUI/ShowUI.Formats.ps1xml
  191. +111 −0 chapter07/ShowUI/ShowUI.VersionHistory.txt
  192. +11 −0 chapter07/ShowUI/ShowUI.psd1
  193. +243 −0 chapter07/ShowUI/ShowUI.psm1
  194. +61 −0 chapter07/ShowUI/Start-PowerShellCommand.ps1
  195. +82 −0 chapter07/ShowUI/Start-WPFJob.ps1
  196. +46 −0 chapter07/ShowUI/Stop-PowerShellCommand.ps1
  197. BIN chapter07/ShowUI/StyleSystem/Current.style
  198. +34 −0 chapter07/ShowUI/StyleSystem/Get-UIStyle.ps1
  199. +46 −0 chapter07/ShowUI/StyleSystem/Import-UIStyle.ps1
  200. +135 −0 chapter07/ShowUI/StyleSystem/Set-UIStyle.ps1
  201. BIN chapter07/ShowUI/Styles/Current.style
  202. +45 −0 chapter07/ShowUI/Unregister-PowerShellCommand.ps1
  203. +35 −0 chapter07/ShowUI/Update-ControlOutput.ps1
  204. +65 −0 chapter07/ShowUI/Update-WPFJob.ps1
  205. +81 −0 chapter07/ShowUI/WPF/Add-ChildControl.ps1
  206. +101 −0 chapter07/ShowUI/WPF/Add-EventHandler.ps1
  207. +59 −0 chapter07/ShowUI/WPF/Add-GridColumn.ps1
  208. +55 −0 chapter07/ShowUI/WPF/Add-GridRow.ps1
  209. +24 −0 chapter07/ShowUI/WPF/Close-Control.ps1
  210. +112 −0 chapter07/ShowUI/WPF/ConvertTo-DataTemplate.ps1
  211. +44 −0 chapter07/ShowUI/WPF/ConvertTo-GridLength.ps1
  212. +34 −0 chapter07/ShowUI/WPF/ConvertTo-Xaml.ps1
  213. +44 −0 chapter07/ShowUI/WPF/Copy-DependencyProperty.ps1
  214. +153 −0 chapter07/ShowUI/WPF/Enable-Multitouch.ps1
  215. +132 −0 chapter07/ShowUI/WPF/Get-ChildControl.ps1
  216. +22 −0 chapter07/ShowUI/WPF/Get-CommonParentControl.ps1
  217. +47 −0 chapter07/ShowUI/WPF/Get-ControlPosition.ps1
  218. +21 −0 chapter07/ShowUI/WPF/Get-DependencyProperty.ps1
  219. +24 −0 chapter07/ShowUI/WPF/Get-ParentControl.ps1
  220. +56 −0 chapter07/ShowUI/WPF/Get-Resource.ps1
  221. +47 −0 chapter07/ShowUI/WPF/Hide-UIElement.ps1
  222. +40 −0 chapter07/ShowUI/WPF/Initialize-EventHandler.ps1
  223. +294 −0 chapter07/ShowUI/WPF/Move-Control.ps1
  224. +57 −0 chapter07/ShowUI/WPF/Out-Xaml.ps1
  225. +26 −0 chapter07/ShowUI/WPF/Remove-ChildControl.ps1
  226. +68 −0 chapter07/ShowUI/WPF/Set-DependencyProperty.ps1
  227. +184 −0 chapter07/ShowUI/WPF/Set-Property.ps1
  228. +67 −0 chapter07/ShowUI/WPF/Set-Resource.ps1
  229. +52 −0 chapter07/ShowUI/WPF/Show-UIElement.ps1
  230. +226 −0 chapter07/ShowUI/WPF/Show-Window.ps1
  231. +52 −0 chapter07/ShowUI/WPF/Start-Animation.ps1
  232. +13 −0 chapter07/ShowUI/WPF/Test-Ancestor.ps1
  233. +13 −0 chapter07/ShowUI/WPF/Test-Descendent.ps1
  234. +30 −0 chapter07/ShowUI/WPF/Write-WPFError.ps1
  235. +279 −0 chapter07/ShowUI/Write-Program.ps1
  236. BIN chapter07/ShowUI/en-us/About_ShowUI.help.txt
  237. BIN chapter07/ShowUI/en-us/About_ShowUI_Jobs.walkthru.help.txt
  238. BIN chapter07/ShowUI/en-us/Advanced_ShowUI_Videos.walkthru.help.txt
  239. +8 −0 chapter07/ShowUI/en-us/Fun_With_ShowUI_Videos.walkthru.help.txt
  240. BIN chapter07/ShowUI/en-us/Getting_Started_Videos.walkthru.help.txt
  241. +150 −0 chapter07/ShowUI/en-us/Getting_started_with_ShowUI.walkthru.help.txt
  242. +127 −0 chapter07/ShowUI/en-us/ShowUI-Events_and_Output.txt
  243. +211 −0 chapter07/ShowUI/en-us/ShowUI-The-Walkthrough-Tutorial.txt
  244. +14 −0 chapter07/SimpleWinformGui.ps1
  245. +11 −0 chapter08/Add-RoslynLibraries.ps1
  246. +16 −0 chapter08/FindCSharpClass.ps1
  247. +9 −0 chapter08/Get-RosylnPath.ps1
  248. +21 −0 chapter08/GetCSharpClass.ps1
  249. +16 −0 chapter08/GetProjectsAndFiles.ps1
  250. +14 −0 chapter08/GetStackOverflowUser.ps1
  251. +13 −0 chapter08/GetUsingStatements.ps1
  252. +58 −0 chapter08/InvokeRoslynCodeGen.ps1
  253. +16 −0 chapter08/LoadSln.ps1
  254. +6 −0 chapter08/LoadSln1.ps1
  255. +7 −0 chapter08/LoadSolution.ps1
  256. +10 −0 chapter08/OutClipboard.ps1
  257. +27 −0 chapter08/Roslyn.ps1
  258. +6 −0 chapter08/RoslynDiscovery.ps1
  259. +4 −0 chapter08/RoslynDiscovery2.ps1
  260. +12 −0 chapter08/RoslynDiscoveryDocumentMethods.ps1
  261. +3 −0 chapter08/RoslynDiscoveryGetStatic.ps1
  262. +4 −0 chapter08/RoslynDiscoveryPublicClasses.ps1
  263. +23 −0 chapter08/ShowClasses.ps1
  264. +7 −0 chapter08/ShowFirstProject.ps1
  265. +12 −0 chapter08/ShowGetSyntaxTreeRoot.ps1
  266. +13 −0 chapter09/GraphCompanies.ps1
  267. +5 −0 chapter09/HelloWorld.ps1
  268. +9 −0 chapter09/PowerShell-BetterGraphViz.ps1
  269. +32 −0 chapter09/ToDoList.ps1
  270. +25 −0 chapter09/graphviz.ps1
  271. +10 −0 chapter09/housework.ps1
  272. +10 −0 chapter09/repeat.ps1
  273. +11 −0 chapter10/AutomateExcel.ps1
  274. +3 −0 chapter10/CreateWorkbookAndWorkSheet.ps1
  275. +17 −0 chapter10/ExcelWorkfunctions.ps1
  276. +25 −0 chapter10/ExportAuthors.ps1
  277. +4 −0 chapter10/GetAgeData.ps1
  278. +15 −0 chapter10/GetCrimeInfo.ps1
  279. +15 −0 chapter10/GetExcelWorkfunction.ps1
  280. +5 −0 chapter10/GetProduceDetail.ps1
  281. +37 −0 chapter10/GetProgID.ps1
  282. +2 −0 chapter10/MakeExcelVisible.ps1
  283. +14 −0 chapter10/MoreExcelWorkfunctions.ps1
  284. +107 −0 chapter10/Out-ExcelPivotTable.ps1
  285. +7 −0 chapter10/PutDataInACell.ps1
  286. +25 −0 chapter10/ReadExcelFile.ps1
  287. +3 −0 chapter10/ShowIE.ps1
  288. +2 −0 chapter10/ShowPeople.ps1
  289. +5 −0 chapter10/authors.csv
  290. +9 −0 chapter10/people.csv
  291. BIN chapter10/test.xlsx
  292. +4 −0 chapter11/NewObjectHashTable.ps1
  293. +6 −0 chapter11/PSCustomObject.ps1
  294. +13 −0 chapter11/PSCustomObjectAndMore.ps1
  295. +36 −0 chapter11/PowerShellAndJSON.ps1
  296. +3 −0 chapter11/SearchTwitter.ps1
  297. +20 −0 chapter11/StartScheduledJobIn.ps1
  298. +20 −0 chapter11/TestWorkflowForPowerShell/TestWorkflowForPowerShell.sln
  299. BIN chapter11/TestWorkflowForPowerShell/TestWorkflowForPowerShell.suo
  300. +8 −0 chapter11/TestWorkflowForPowerShell/TestWorkflowForPowerShell/App.config
Sorry, we could not display the entire diff because too many files (305) changed.
View
26 Appendix A/GetFunction.ps1
@@ -0,0 +1,26 @@
+Function Get-Function ([string]$Pattern, [string]$Path="$pwd") {
+
+ $parser = [System.Management.Automation.PSParser]
+
+ $(ForEach( $file in Get-ChildItem $Path -Recurse -Include *.ps1, *.psm1) {
+
+ $content = [IO.File]::ReadAllText($file.FullName)
+ $tokens = $parser::Tokenize($content, [ref] $null)
+ $count = $tokens.Count
+
+ for($idx=0; $idx -lt $count; $idx += 1) {
+ if($tokens[$idx].Content -eq 'function') {
+
+ $targetToken = $tokens[$idx+1]
+
+ New-Object PSObject -Property @{
+ FileName = $file.FullName
+ FunctionName = $targetToken.Content
+ Line = $targetToken.StartLine
+ } | Select FunctionName, FileName, Line
+ }
+ }
+ }) | Where {$_.FunctionName -match $Pattern}
+}
+
+Get-Function -Path $PSHOME\Modules\PSDiagnostics | Out-GridView
View
35 Appendix A/IndexText.ps1
@@ -0,0 +1,35 @@
+function SlowTrain($text) {
+
+ $h = @{}
+ [regex]::split($text.ToLower(), ‘\W+) |
+ ForEach {
+ $h[$_] =''
+ }
+ $h
+}
+
+function FastTrain($text) {
+
+ $h = @{}
+ ForEach ($word in [regex]::split($text.ToLower(), ‘\W+) )
+ {
+ $h[$word] = ''
+ }
+ $h
+}
+
+function Do-Timing {
+ param(
+ $Caption,
+ $ScriptBlock
+ )
+
+ "{0} Seconds: {1}" -f $Caption, (Measure-Command $ScriptBlock).TotalSeconds
+}
+
+$Text = [IO.File]::ReadAllText( "$pwd\holmes.txt" )
+
+Write-Host -ForegroundColor Green "Timing the SlowTrain"
+Do-Timing "SlowTrain in" {SlowTrain $Text}
+Write-Host -ForegroundColor Green "Timing the FastTrain"
+Do-Timing "FastTrain in" {FastTrain $Text}
View
4 Appendix A/ProductivePowerShell.ps1
@@ -0,0 +1,4 @@
+set-alias npp "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe"
+set-alias tp "${env:ProgramFiles(x86)}\TextPad 5\TextPad.exe"
+
+function ql {$args} # quote list
View
15 Appendix A/RDP.ps1
@@ -0,0 +1,15 @@
+function rdp {
+ param (
+ [Switch]$ClientSQLBox,
+ [Switch]$ClientDev,
+ [Switch]$ClientIntegrationBox,
+ [Switch]$ClientQABox
+ )
+
+ if($ClientSQLBox) { $server = 'ClientSQLBox' }
+ if($ClientDev) { $server = 'ClientDev' }
+ if($ClientIntegrationBox) { $server = 'ClientIntegrationBox' }
+ if($ClientQABox) { $server = 'ClientQABox' }
+
+ if($server) { mstsc /v:$server }
+}
View
14 Appendix A/SearchGoogle.ps1
@@ -0,0 +1,14 @@
+function Search-Google {
+ param(
+ [Parameter(ValueFromPipeline=$true)]
+ [string]$query
+ )
+
+ Process {
+ Start "https://www.google.com/search?q=$query"
+ }
+}
+
+function ql {$args}
+
+ql win32_service win_bios powershell | Search-Google
View
11 Appendix A/StartPowerShell.ps1
@@ -0,0 +1,11 @@
+function Start-PowerShell {
+ param (
+ [Switch]$NoProfile
+ )
+
+ if($NoProfile) {
+ Start PowerShell -Args -NoProfile
+ } else {
+ Start PowerShell
+ }
+}
View
20 Appendix A/SubversionPrompt.ps1
@@ -0,0 +1,20 @@
+function prompt {
+ $host.ui.rawui.WindowTitle = $(get-location)
+
+ if(Test-Path .svn) {
+ switch -regex (svn st) {
+ "^\?" {$other+=1}
+ "^A" {$added+=1}
+ "^M" {$modified+=1}
+ default {}
+ }
+
+ $prompt_string = "SVN o:$other a:$added m:$modified >"
+ } else {
+ $prompt_string = "PS >"
+ }
+
+ Write-Host ($prompt_string) -nonewline -foregroundcolor yellow
+
+ return " "
+}
View
6 Appendix A/TimesConstruct.ps1
@@ -0,0 +1,6 @@
+filter times ([Scriptblock]$Block) {
+ 1..$_ | ForEach { & $Block }
+}
+
+
+3 | times {"Hello World"}
View
5,501 Appendix A/holmes.txt
5,501 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
11 LICENSE.md
@@ -0,0 +1,11 @@
+In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
+
+We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example:
+
+>*PowerShell for Developers*, by Douglas Finke (O’Reilly). Copyright 2012 O'Reilly Media, 978-1-4493-2270-0.
+
+If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [permissions@oreilly.com][].
+
+If you are interested in this code, please consider buying a copy of the book, which is available in many formats via oreilly.com:
+
+[oreilly.com/catalog/0636920024491] [book-link]
View
51 README.md
@@ -1,9 +1,42 @@
-<a href="http://shop.oreilly.com/product/0636920024491.do">PowerShell for Developers</a>
-========================================================================================
-
-<h2>Enhance your productivity and enable rapid application development.</h2><p>
-The PowerShell platform gives developers seamless integration with legacy .Net code while adding a range previously not seen in a language. With this book you will quickly learn the fundamentals, and move on to writing rich, sophisticated scripts to manage key tasks and processes in your development activities. PowerShell .Net for Developers begins with a cheat sheet of language primitives to get you on your feet with the language. You’ll see how to speed up nearly every aspect of the development process using PowerShell.
-<br><br><br><br>
-<center>
-<a href="http://shop.oreilly.com/product/0636920024491.do"><img height="550" width="400" src="http://dougfinke.com/images/PowerShellForDevelopers.png"></a>
-</center>
+# Overview
+This repository contains the latest definitive bug fixed source code for examples from [PowerShell for Developers][book-link].
+
+In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
+
+We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example:
+
+>*PowerShell for Developers*, by Douglas Finke (O’Reilly). Copyright 2012 O'Reilly Media, 978-1-4493-2270-0.
+
+If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [permissions@oreilly.com][].
+
+If you are interested in this code, please consider buying a copy of the book, which is available in many formats via oreilly.com:
+
+[oreilly.com/catalog/0636920024491] [book-link]
+
+You get lifetime access to ebooks you purchase through oreilly.com. Read more about O'Reilly's ebook program here: [oreilly.com/ebooks](http://oreilly.com/ebooks).
+
+[book-link]: http://oreilly.com/catalog/0636920024491
+[permissions@oreilly.com]: mailto:permissions@oreilly.com
+
+# Book Description
+
+![Book Cover][book-cover]
+
+The PowerShell platform gives developers seamless integration with legacy .Net code while adding a range previously not seen in a language. With this book you will quickly learn the fundamentals, and move on to writing rich, sophisticated scripts to manage key tasks and processes in your development activities. PowerShell .Net for Developers begins with a cheat sheet of language primitives to get you on your feet with the language. You’ll see how to speed up nearly every aspect of the development process using PowerShell.
+
+If you have general questions or comments, please visit [getsatisfaction.com/oreilly](http://getsatisfaction.com/oreilly).
+
+[book-cover]: http://covers.oreilly.com/images/0636920024491/lrg.jpg
+
+# Contact Us
+
+We'd like to hear from you!
+
+For more information about O'Reilly books, courses, conferences, and news, see our website
+at [oreilly.com](http://www.oreilly.com).
+
+Find us on Facebook: [facebook.com/oreilly](http://facebook.com/oreilly)
+
+Follow us on Twitter: [twitter.com/oreillymedia](http://twitter.com/oreillymedia)
+
+Watch us on YouTube: [youtube.com/oreillymedia](http://www.youtube.com/oreillymedia)
View
17 chapter04/InvokeTemplate/CodeAst.ps1
@@ -0,0 +1,17 @@
+. .\Invoke-Template.ps1
+
+Invoke-Template $pwd\etc {
+
+ $methodOverrides = Invoke-Template $pwd\etc {
+ [System.Management.Automation.Language.AstVisitor].GetMethods() |
+ Where { $_.Name -like 'Visit*' } |
+ ForEach {
+ $functionName = $_.Name
+ $parameterName = $_.GetParameters()[0].ParameterType.Name
+
+ Get-Template AstVisitAction.txt
+ }
+ }
+
+ Get-Template CommandMatcher.txt
+}
View
15 chapter04/InvokeTemplate/Invoke-Template.ps1
@@ -0,0 +1,15 @@
+function Invoke-Template {
+ param(
+ [string]$Path="$pwd",
+ [ScriptBlock]$ScriptBlock
+ )
+
+ function Get-Template {
+ param($TemplateFileName)
+
+ $content = [IO.File]::ReadAllText( (Join-Path $Path $TemplateFileName) )
+ Invoke-Expression "@`"`r`n$content`r`n`"@"
+ }
+
+ & $ScriptBlock
+}
View
14 chapter04/InvokeTemplate/Properties.xml
@@ -0,0 +1,14 @@
+<properties>
+ <property>
+ <type>string</type>
+ <name>City</name>
+ </property>
+ <property>
+ <type>string</type>
+ <name>State</name>
+ </property>
+ <property>
+ <type>string</type>
+ <name>Zip</name>
+ </property>
+</properties>
View
40 chapter04/InvokeTemplate/Test-CodeAST.ps1
@@ -0,0 +1,40 @@
+Add-Type (.\CodeAst.ps1)
+
+$m = New-Module -AsCustomObject {
+
+ $script:FunctionList = @()
+
+ function VisitFunctionDefinition ($ast) {
+ $script:FunctionList += New-Object PSObject -Property @{
+ Kind = "Function"
+ Name = $ast.Name
+ StartLineNumber = $ast.Extent.StartLineNumber
+ }
+ }
+
+ function GetFunctionList {$script:FunctionList}
+}
+
+function Get-Ast
+{
+ param([string]$script)
+ [System.Management.Automation.Language.Parser]::ParseInput(
+ $script,
+ [ref]$null,
+ [ref]$null
+ )
+}
+
+$matcher = new-object CommandMatcher $m
+
+$ast = Get-Ast @'
+ function test1 {"Say Hello"}
+ 1..10 | % {$_}
+ function test2 {"Say Goodbye"}
+ 1..10 | % {$_}
+ function test3 {"Another function"}
+ #function test3 {"This is a comment"}
+'@
+
+$ast.Visit($matcher)
+$m.GetFunctionList()
View
11 chapter04/InvokeTemplate/Test-ComplexLogicTemplate.ps1
@@ -0,0 +1,11 @@
+# dot source it
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+
+ Import-Csv $pwd\properties.csv | ForEach {
+
+ $type=$_.type; $name=$_.name
+ Get-Template properties.txt
+ }
+}
View
7 chapter04/InvokeTemplate/Test-HTMLTemplate.ps1
@@ -0,0 +1,7 @@
+# dot source it
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+ $name = "World"
+ Get-Template TestHtml.htm
+}
View
13 chapter04/InvokeTemplate/Test-MultipleTemplates.ps1
@@ -0,0 +1,13 @@
+# dot source it
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+
+ $type = "string"
+ $name = "FirstName"
+ Get-Template properties.txt
+
+ $type = "DateTime"
+ $name = "Date"
+ Get-Template privateSet.txt
+}
View
9 chapter04/InvokeTemplate/Test-MultipleVariableTemplate.ps1
@@ -0,0 +1,9 @@
+# dot source it
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+
+ $type = "string"
+ $name = "FirstName"
+ Get-Template properties.txt
+}
View
11 chapter04/InvokeTemplate/Test-ReadXMLTemplate.ps1
@@ -0,0 +1,11 @@
+# dot source it
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+
+ ([xml](Get-Content .\Properties.xml)).Properties.property |
+ ForEach {
+ $type=$_.type; $name=$_.name
+ Get-Template properties.txt
+ }
+}
View
17 chapter04/InvokeTemplate/Test-UMLSyntax.ps1
@@ -0,0 +1,17 @@
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+@"
+LastName : string
+FirstName : string
+Age : int
+City : string
+State : string
+Zip : int
+"@ | ConvertFrom-Csv -Header "Name","Type" -Delimiter ":" |
+ ForEach {
+ $name = $_.Name
+ $type = $_.Type
+ Get-Template properties.txt
+ }
+}
View
10 chapter04/InvokeTemplate/Test-UMLSyntaxWithFile.ps1
@@ -0,0 +1,10 @@
+. .\Invoke-Template.ps1
+
+Invoke-Template "$pwd\etc" {
+ Import-Csv -Path .\Uml.txt -Header "Name","Type" -Delimiter ":" |
+ ForEach {
+ $name = $_.Name
+ $type = $_.Type
+ Get-Template properties.txt
+ }
+}
View
6 chapter04/InvokeTemplate/Uml.txt
@@ -0,0 +1,6 @@
+LastName : string
+FirstName : string
+Age : int
+City : string
+State : string
+Zip : int
View
11 chapter04/InvokeTemplate/etc/AstVisitAction.txt
@@ -0,0 +1,11 @@
+
+ public override AstVisitAction $FunctionName($ParameterName ast)
+ {
+ var method = module.Methods["$FunctionName"];
+ if (method != null)
+ {
+ method.Invoke(ast);
+ }
+ return AstVisitAction.Continue;
+ }
+
View
14 chapter04/InvokeTemplate/etc/CommandMatcher.txt
@@ -0,0 +1,14 @@
+using System;
+using System.Management.Automation;
+using System.Management.Automation.Language;
+
+public class CommandMatcher : AstVisitor
+{
+ PSObject module;
+ public CommandMatcher(PSObject module)
+ {
+ this.module = module;
+ }
+
+ $methodOverrides
+}
View
1 chapter04/InvokeTemplate/etc/TestHtml.htm
@@ -0,0 +1 @@
+<h1>Hello $name</h1>
View
1 chapter04/InvokeTemplate/etc/privateSet.txt
@@ -0,0 +1 @@
+public $type $name {get; private set;}
View
1 chapter04/InvokeTemplate/etc/properties.txt
@@ -0,0 +1 @@
+public $type $name {get; set;}
View
47 chapter04/InvokeTemplate/githubViewer.ps1
@@ -0,0 +1,47 @@
+ipmo showui
+
+New-Window -WindowStartupLocation CenterScreen -Width 1000 -Height 700 -Show -On_Loaded{
+ $Search.Focus()
+} {
+ Grid -Rows 35, 100*, 100* -Columns 200*, Auto, 300* {
+ TextBox -Name Search -Row 0 -Column 0 -Margin 5 -On_PreviewKeyUp {
+ if($_.key -eq "Enter") {
+ $OwnerRepo.DataContext = $null
+ $SearchResults.DataContext = (Invoke-RestMethod "http://github.com/api/v2/json/repos/search/$($this.Text)").repositories
+ }
+ }
+
+ GridSplitter -RowSpan 3 -Row 0 -Column 1 -Width 4 -Background Gray -VerticalAlignment Stretch -HorizontalAlignment Center
+
+ ListView -Name SearchResults -Margin 5 -Row 1 -Column 0 -RowSpan 2 -DataBinding @{ItemsSource="."} -On_SelectionChanged {
+ $owner = ($this.Selecteditem).owner
+ $url = ($this.Selecteditem).url
+ #$Browser.Navigate($url)
+ $OwnerGroupBox.Header = " Repos for Owner: $owner "
+ #$OwnerRepo.DataContext = (Invoke-RestMethod "http://github.com/api/v2/json/repos/show/$($owner)").repositories
+ $OwnerRepo.DataContext = Invoke-RestMethod "https://api.github.com/users/$($owner)/repos"
+
+ } -View {
+ GridView -Columns {
+ GridViewColumn "name"
+ GridViewColumn "owner"
+ GridViewColumn "watchers"
+ GridViewColumn "url"
+ }
+ }
+
+ GroupBox -Name OwnerGroupBox -Header " Repos for Owner " -Margin 5 -Row 0 -Column 2 -RowSpan 2 -Content {
+ ListView -Margin 5 -Name OwnerRepo -DataBinding @{ItemsSource=New-Binding} -View {
+ GridView -Columns {
+ GridViewColumn "name"
+ GridViewColumn "watchers"
+ GridViewColumn "url"
+ }
+ }
+ }
+
+# WebBrowser -Name Browser -Row 2 -Column 2 -Margin 5 -On_Loaded {
+# $this.Navigate("about:blank")
+# }
+ }
+}
View
12 chapter04/InvokeTemplate/html/Test-HTML.ps1
@@ -0,0 +1,12 @@
+. ..\Invoke-Template.ps1
+
+Invoke-Template {
+ $name = "Test"
+
+ dir |
+ select Name, Length, LastWriteTime |
+ ConvertTo-Html -Head (Get-Template header.htm) -Body (Get-Template body.htm) -Title $name
+
+} | Set-Content .\test.htm
+
+Invoke-Item .\test.htm
View
1 chapter04/InvokeTemplate/html/body.htm
@@ -0,0 +1 @@
+<h1>$Name</h1><p>Generated on $(Get-Date) </p>
View
12 chapter04/InvokeTemplate/html/header.htm
@@ -0,0 +1,12 @@
+<style>
+ body { font-family:Segoe UI; background-color:white;}
+ table { border-width: 1px;border-style: solid;
+ border-color: black;border-collapse: collapse;width:100%;}
+ th { font-family:Segoe Print;font-size:1.0em; border-width: 1px;
+ padding: 2px;border-style: solid;border-color:black;
+ background-color:lightblue;
+ }
+ td { border-width: 1px;padding: 2px;border-style: solid;
+ border-color: black;background-color:white;
+ }
+</style>
View
26 chapter04/InvokeTemplate/html/test.htm
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<style>
+ body { font-family:Segoe UI; background-color:white;}
+ table { border-width: 1px;border-style: solid;
+ border-color: black;border-collapse: collapse;width:100%;}
+ th { font-family:Segoe Print;font-size:1.0em; border-width: 1px;
+ padding: 2px;border-style: solid;border-color:black;
+ background-color:lightblue;
+ }
+ td { border-width: 1px;padding: 2px;border-style: solid;
+ border-color: black;background-color:white;
+ }
+</style>
+</head><body>
+<h1>Test</h1><p>Generated on 12/29/2011 10:00:21 </p>
+<table>
+<colgroup><col/><col/><col/></colgroup>
+<tr><th>Name</th><th>Length</th><th>LastWriteTime</th></tr>
+<tr><td>body.htm</td><td>49</td><td>12/28/2011 7:30:25 PM</td></tr>
+<tr><td>header.htm</td><td>532</td><td>12/28/2011 5:40:18 PM</td></tr>
+<tr><td>Test-HTML.ps1</td><td>289</td><td>12/29/2011 10:00:19 AM</td></tr>
+<tr><td>test.htm</td><td>0</td><td>12/29/2011 10:00:21 AM</td></tr>
+</table>
+</body></html>
View
3 chapter04/InvokeTemplate/properties.csv
@@ -0,0 +1,3 @@
+Type, Name
+string, LastName
+int, Age
View
13 chapter04/ParseASingleFile.ps1
@@ -0,0 +1,13 @@
+$regex = "\s+const\s+\w+\s+(?<name>.*)\s+=\s+(?<value>.*);"
+
+Select-String $regex .\test.cs |
+ ForEach {
+ $fileName = $_.Path
+ ForEach($match in $_.Matches) {
+ New-Object PSObject -Property @{
+ FileName = $fileName
+ Name = $match.Groups["name"].Value
+ Value = $match.Groups["value"].Value
+ }
+ }
+ }
View
13 chapter04/ParseCSharpFiles.ps1
@@ -0,0 +1,13 @@
+$regex = "\s+const\s+\w+\s+(?<name>.*)\s+=\s+(?<value>.*);"
+
+dir *.cs | Select-String $regex |
+ ForEach {
+ $fileName = $_.Path
+ ForEach($match in $_.Matches) {
+ New-Object PSObject -Property @{
+ FileName = $fileName
+ Name = $match.Groups["name"].Value
+ Value = $match.Groups["value"].Value
+ }
+ }
+ }
View
34 chapter04/Test-GetParameter.ps1
@@ -0,0 +1,34 @@
+$code = @"
+ public class MyMath
+ {
+ public int MyAdd(int n1, int n2) { return n1 + n2; }
+ public int MySubtract(int n1, int n2) { return n1 - n2; }
+ public int MyMultiply(int n1, int n2) { return n1 * n2; }
+ public int MyDivide(int n1, int n2) { return n1 / n2; }
+ public void MyTest() {System.Console.WriteLine("Test");}
+ }
+"@
+
+Add-Type -TypeDefinition $code
+
+function Get-Parameter ($target) {
+ ($target.GetParameters() |
+ ForEach {
+ "`$$($_.Name)"
+ }
+ ) -join ", "
+}
+
+@"
+`$MyMath = New-Object MyMath
+$([MyMath].GetMethods() | Where {$_.Name -like "My*"} | ForEach {
+
+ $params = Get-Parameter $_
+
+@"
+
+function Invoke-$($_.Name) ($params) {`$MyMath.$($_.Name)($($params))}
+"@
+})
+
+"@
View
14 chapter04/Test-MyMath.ps1
@@ -0,0 +1,14 @@
+$code = @"
+ public class MyMath
+ {
+ public int MyAdd(int n1, int n2) { return n1 + n2; }
+ public int MySubtract(int n1, int n2) { return n1 - n2; }
+ public int MyMultiply(int n1, int n2) { return n1 * n2; }
+ public int MyDivide(int n1, int n2) { return n1 / n2; }
+ public void MyTest() {System.Console.WriteLine("Test");}
+ }
+"@
+
+Add-Type -TypeDefinition $code
+
+[MyMath].GetMethods() | Where {$_.Name -like "My*"} | Out-GridView
View
18 chapter04/test.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ConsoleApplication1
+{
+ class Program
+ {
+ public const string Test = "test";
+ public const int TestX = 1;
+
+ static void Main(string[] args)
+ {
+ const double PI = 3.14;
+ }
+ }
+}
View
18 chapter04/test1.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ConsoleApplication1
+{
+ class Program
+ {
+ public const string Color = "Red";
+ public const int Name = "Dog";
+
+ static void Main(string[] args)
+ {
+ const double Freezing = 32;
+ }
+ }
+}
View
29 chapter05/BeaverMusic/.gitignore
@@ -0,0 +1,29 @@
+*.[Oo]bj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*.vssscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.[Cc]ache
+*.ilk
+*.log
+*.lib
+*.sbr
+*.sdf
+ipch/
+obj/
+[Bb]in
+[Dd]ebug*/
+[Rr]elease*/
+_*/
+TestResults/
+*.docstates
View
16 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditDialogView.xaml
@@ -0,0 +1,16 @@
+<Window
+ x:Class="BeaverMusic.UI.Shell.AlbumEditDialogView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:bmui="http://beavermusic.com/client/ui"
+ xmlns:local="clr-namespace:BeaverMusic.UI.Shell"
+ WindowStartupLocation="CenterScreen"
+ Title="AlbumEditDialogView" Height="300" Width="300">
+ <DockPanel Margin="10,5">
+ <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
+ <Button Margin="5" Width="75" Content="OK" Command="{Binding CommitCommand}" IsDefault="True"/>
+ <Button Margin="5" Width="75" Content="Cancel" Command="{Binding CancelCommand}" IsCancel="True"/>
+ </StackPanel>
+ <bmui:ViewElement ViewType="local:AlbumEditView" ViewModel="{Binding AlbumEditViewModel}" ViewModelCreationStrategy="Inject"/>
+ </DockPanel>
+</Window>
View
26 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditDialogView.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace BeaverMusic.UI.Shell
+{
+ /// <summary>
+ /// Interaction logic for AlbumEditDialogView.xaml
+ /// </summary>
+ public partial class AlbumEditDialogView : Window
+ {
+ public AlbumEditDialogView()
+ {
+ InitializeComponent();
+ }
+ }
+}
View
69 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditDialogViewModel.cs
@@ -0,0 +1,69 @@
+using System;
+using System.ComponentModel.Composition;
+using System.Linq;
+using System.Windows.Input;
+
+namespace BeaverMusic.UI.Shell
+{
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ internal class AlbumEditDialogViewModel
+ {
+ private readonly IAlbumRepository _albumRepository;
+
+ public event EventHandler Completed = delegate { };
+
+ [ImportingConstructor]
+ public AlbumEditDialogViewModel(IAlbumRepository albumRepository, AlbumEditViewModel albumEditViewModel)
+ {
+ _albumRepository = albumRepository;
+ AlbumEditViewModel = albumEditViewModel;
+
+ InitializeCommands();
+ }
+
+ #region Commands
+
+ public ICommand CommitCommand { get; private set; }
+
+ public ICommand CancelCommand { get; private set; }
+
+ private void InitializeCommands()
+ {
+ CommitCommand = new DelegateCommand(Commit);
+ CancelCommand = new DelegateCommand(Cancel);
+ }
+
+ #endregion
+
+ public AlbumEditViewModel AlbumEditViewModel { get; private set; }
+
+ public void Initialize(Album album)
+ {
+ AlbumEditViewModel.AlbumId = album.Id;
+ AlbumEditViewModel.AlbumName = album.Name;
+ AlbumEditViewModel.Artist = album.Artist;
+
+ if (album.Songs != null)
+ foreach (var song in album.Songs)
+ AlbumEditViewModel.Songs.Add(new AlbumEditViewModel.SongViewModel() { SongName = song.Name, Length = song.Length });
+ }
+
+ public void Commit()
+ {
+ var album = AlbumEditViewModel.AlbumId == null ? new Album() : new Album(AlbumEditViewModel.AlbumId.Value);
+
+ album.Name = AlbumEditViewModel.AlbumName;
+ album.Artist = AlbumEditViewModel.Artist;
+ album.Songs = AlbumEditViewModel.Songs.Select(s => new Song { Name = s.SongName, Length = s.Length }).ToArray();
+
+ _albumRepository.SaveAlbum(album);
+
+ Completed(this, EventArgs.Empty);
+ }
+
+ public void Cancel()
+ {
+ Completed(this, EventArgs.Empty);
+ }
+ }
+}
View
53 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditView.xaml
@@ -0,0 +1,53 @@
+<UserControl
+ x:Class="BeaverMusic.UI.Shell.AlbumEditView"
+ x:ClassModifier="internal"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:bmui="http://beavermusic.com/client/ui"
+ mc:Ignorable="d"
+ d:DesignHeight="300" d:DesignWidth="300">
+ <DockPanel>
+ <StackPanel DockPanel.Dock="Top">
+ <bmui:WatermarkTextBox Text="{Binding AlbumName}" FontSize="24" FontWeight="Bold" Watermark="Album Name" Margin="0,0,0,5"/>
+ <DockPanel>
+ <TextBlock Text="By" FontStyle="Italic" Padding="4"/>
+ <bmui:WatermarkTextBox Text="{Binding Artist}" Watermark="Artist" FontStyle="Italic"/>
+ </DockPanel>
+ </StackPanel>
+ <GroupBox Header="Songs" Margin="0,5" VerticalAlignment="Top">
+ <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
+ <StackPanel>
+ <ItemsControl ItemsSource="{Binding Songs}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition/>
+ <ColumnDefinition Width="60"/>
+ <ColumnDefinition Width="20"/>
+ </Grid.ColumnDefinitions>
+ <bmui:WatermarkTextBox Grid.Column="0" Text="{Binding SongName}" Watermark="Song Name"/>
+ <bmui:WatermarkTextBox Grid.Column="1" Text="{Binding Length, StringFormat=t}" Watermark="Length"/>
+ <Button Grid.Column="2" Content="X" Command="{Binding DataContext.RemoveSongCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=ItemsControl}}" CommandParameter="{Binding}"/>
+ </Grid>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition/>
+ <ColumnDefinition Width="60"/>
+ <ColumnDefinition Width="20"/>
+ </Grid.ColumnDefinitions>
+ <bmui:WatermarkTextBox Grid.Column="0" Text="{Binding SongToAdd.SongName}" Watermark="Song Name"/>
+ <bmui:WatermarkTextBox Grid.Column="1" Text="{Binding SongToAdd.Length, StringFormat=t, TargetNullValue=0}" Watermark="Length"/>
+ <Button Grid.Column="2" Content="+" Command="{Binding AddSongCommand}"/>
+ </Grid>
+ </StackPanel>
+ </ScrollViewer>
+ </GroupBox>
+ </DockPanel>
+</UserControl>
View
12 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditView.xaml.cs
@@ -0,0 +1,12 @@
+using System.Windows.Controls;
+
+namespace BeaverMusic.UI.Shell
+{
+ internal partial class AlbumEditView : UserControl
+ {
+ public AlbumEditView()
+ {
+ InitializeComponent();
+ }
+ }
+}
View
90 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumEditViewModel.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.ObjectModel;
+using System.ComponentModel.Composition;
+using System.Windows.Input;
+
+namespace BeaverMusic.UI.Shell
+{
+ [Export, PartCreationPolicy(CreationPolicy.NonShared)]
+ internal class AlbumEditViewModel : BindableBase
+ {
+ [ImportingConstructor]
+ public AlbumEditViewModel()
+ {
+ Songs = new ObservableCollection<SongViewModel>();
+
+ InitializeCommands();
+ }
+
+ #region Commands
+
+ public ICommand AddSongCommand { get; private set; }
+ public ICommand RemoveSongCommand { get; private set; }
+
+ private void InitializeCommands()
+ {
+ AddSongCommand = new DelegateCommand(AddSong);
+ RemoveSongCommand = new DelegateCommand<SongViewModel>(RemoveSong);
+ }
+
+ #endregion
+
+ private int? _albumId;
+ public int? AlbumId
+ {
+ get { return _albumId; }
+ set { SetProperty(ref _albumId, value, "AlbumId"); }
+ }
+
+ private string _albumName;
+ public string AlbumName
+ {
+ get { return _albumName; }
+ set { SetProperty(ref _albumName, value, "AlbumName"); }
+ }
+
+ private string _artist;
+ public string Artist
+ {
+ get { return _artist; }
+ set { SetProperty(ref _artist, value, "Artist"); }
+ }
+
+ public ObservableCollection<SongViewModel> Songs { get; private set; }
+
+ private SongViewModel _songToAdd = new SongViewModel();
+ public SongViewModel SongToAdd
+ {
+ get { return _songToAdd; }
+ set { SetProperty(ref _songToAdd, value, "SongToAdd"); }
+ }
+
+ public void AddSong()
+ {
+ Songs.Add(_songToAdd);
+ SongToAdd = new SongViewModel();
+ }
+
+ public void RemoveSong(SongViewModel song)
+ {
+ Songs.Remove(song);
+ }
+
+ public class SongViewModel : BindableBase
+ {
+ private string _songName;
+ public string SongName
+ {
+ get { return _songName; }
+ set { SetProperty(ref _songName, value, "SongName"); }
+ }
+
+ private TimeSpan _length;
+ public TimeSpan Length
+ {
+ get { return _length; }
+ set { SetProperty(ref _length, value, "Length"); }
+ }
+ }
+ }
+}
View
31 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumListView.xaml
@@ -0,0 +1,31 @@
+<UserControl
+ x:Class="BeaverMusic.UI.Shell.AlbumListView"
+ x:ClassModifier="internal"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
+ <DockPanel>
+ <ToolBarTray DockPanel.Dock="Top">
+ <ToolBar>
+ <Button Content="New" Command="{Binding NewAlbumCommand}"/>
+ <Button Content="Edit" Command="{Binding EditAlbumCommand}"/>
+ <Button Content="Delete" Command="{Binding DeleteAlbumCommand}"/>
+ <Button Content="PowerShell Console" Command="{Binding PowerShellConsoleCommand}"/>
+ </ToolBar>
+ </ToolBarTray>
+ <Grid Background="white">
+ <Border Margin="10,35,10,10" Background="{DynamicResource BeaverBrush}" Opacity="0.25"/>
+ <ListView ItemsSource="{Binding Albums}" SelectedItem="{Binding SelectedAlbum}" Background="{x:Null}" d:LayoutOverrides="Width">
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="Artist" DisplayMemberBinding="{Binding Artist}"/>
+ <GridViewColumn Header="Album" DisplayMemberBinding="{Binding Name}"/>
+ <GridViewColumn Header="Tracks" DisplayMemberBinding="{Binding Songs.Length}"/>
+ </GridView>
+ </ListView.View>
+ </ListView>
+ </Grid>
+ </DockPanel>
+</UserControl>
View
14 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumListView.xaml.cs
@@ -0,0 +1,14 @@
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace BeaverMusic.UI.Shell
+{
+ internal partial class AlbumListView : UserControl
+ {
+
+ public AlbumListView()
+ {
+ InitializeComponent();
+ }
+ }
+}
View
84 chapter05/BeaverMusic/BeaverMusic.UI.Shell/AlbumListViewModel.cs
@@ -0,0 +1,84 @@
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.Windows.Input;
+using EmbeddedPSConsole;
+using System.ComponentModel.Composition.Hosting;
+using System.ComponentModel.Composition.Primitives;
+
+namespace BeaverMusic.UI.Shell
+{
+ [Export]
+ internal class AlbumListViewModel : BindableBase
+ {
+ private readonly IAlbumRepository _albumRepository;
+ private readonly IViewFactory _viewFactory;
+ private readonly IPowerShellConsoleLauncher _powerShellConsoleLauncher;
+
+ [ImportingConstructor]
+ public AlbumListViewModel(IAlbumRepository albumRepository, IViewFactory viewFactory, IPowerShellConsoleLauncher powerShellConsoleLauncher)
+ {
+ _albumRepository = albumRepository;
+ _viewFactory = viewFactory;
+ _powerShellConsoleLauncher = powerShellConsoleLauncher;
+
+ Albums = albumRepository.GetAlbums();
+
+ InitializeCommands();
+ }
+
+ public IEnumerable<Album> Albums { get; private set; }
+
+ private Album _selectedAlbum;
+ public Album SelectedAlbum
+ {
+ get { return _selectedAlbum; }
+ set { SetProperty(ref _selectedAlbum, value, "SelectedAlbum"); }
+ }
+
+ #region Commands
+
+ public ICommand NewAlbumCommand { get; private set; }
+ public ICommand DeleteAlbumCommand { get; private set; }
+ public ICommand EditAlbumCommand { get; private set; }
+ public ICommand PowerShellConsoleCommand { get; private set; }
+
+ private void InitializeCommands()
+ {
+ NewAlbumCommand = new DelegateCommand(NewAlbum);
+ DeleteAlbumCommand = new DelegateCommand(DeleteSelectedAlbum);
+ EditAlbumCommand = new DelegateCommand(EditSelectedAlbum);
+ PowerShellConsoleCommand = new DelegateCommand(_powerShellConsoleLauncher.Launch);
+ }
+
+ #endregion
+
+ public void NewAlbum()
+ {
+ EditAlbum(new Album());
+ }
+
+ public void DeleteSelectedAlbum()
+ {
+ if (_selectedAlbum != null)
+ _albumRepository.RemoveAlbum(_selectedAlbum.Id.Value);
+ }
+
+ public void EditSelectedAlbum()
+ {
+ if (_selectedAlbum != null)
+ EditAlbum(_selectedAlbum);
+ }
+
+ private void EditAlbum(Album album)
+ {
+ dynamic view = null;
+ AlbumEditDialogViewModel viewModel = null;
+ _viewFactory.CreateView<AlbumEditDialogView, AlbumEditDialogViewModel>(ref view, ref viewModel);
+
+ viewModel.Initialize(album);
+
+ view.Show();
+ viewModel.Completed += (s, e) => view.Close();
+ }
+ }
+}
View
137 chapter05/BeaverMusic/BeaverMusic.UI.Shell/App.xaml
137 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
39 chapter05/BeaverMusic/BeaverMusic.UI.Shell/App.xaml.cs
@@ -0,0 +1,39 @@
+using System.ComponentModel.Composition.Hosting;
+using System.IO;
+using System.Windows;
+using BeaverMusic.Composition;
+
+namespace BeaverMusic.UI.Shell
+{
+ public partial class App : Application
+ {
+ private readonly CompositionContainer _container;
+
+ public App()
+ {
+ var catalog = new AggregateCatalog(new DirectoryCatalog(Path.GetDirectoryName(typeof(App).Assembly.Location)), new AssemblyCatalog(typeof(App).Assembly));
+
+ _container = new CompositionContainer(catalog);
+
+ var batch = new CompositionBatch();
+ batch.AddPart(ExistingComposablePart.Create<ExportProvider>(_container));
+ batch.AddPart(ExistingComposablePart.Create(_container));
+
+ _container.Compose(batch);
+ }
+
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ base.OnStartup(e);
+
+ var viewFactory = _container.GetExportedValue<IViewFactory>();
+
+ dynamic mainWindow = null;
+ MainViewModel mainViewModel = null;
+
+ viewFactory.CreateView<MainWindow, MainViewModel>(ref mainWindow, ref mainViewModel);
+
+ mainWindow.Show();
+ }
+ }
+}
View
146 chapter05/BeaverMusic/BeaverMusic.UI.Shell/BeaverMusic.UI.Shell.csproj
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{969F22E4-393E-443B-98B6-B783F9453E5E}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>BeaverMusic.UI.Shell</RootNamespace>
+ <AssemblyName>BeaverMusic</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <WarningLevel>4</WarningLevel>
+ <Utf8Output>true</Utf8Output>
+ <ExpressionBlendVersion>4.0.20525.0</ExpressionBlendVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.Composition" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Xaml">
+ <RequiredTargetFramework>4.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="WindowsBase" />
+ <Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Compile Include="AlbumEditDialogView.xaml.cs">
+ <DependentUpon>AlbumEditDialogView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="AlbumEditDialogViewModel.cs" />
+ <Compile Include="AlbumEditView.xaml.cs">
+ <DependentUpon>AlbumEditView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="AlbumEditViewModel.cs" />
+ <Compile Include="AlbumListView.xaml.cs">
+ <DependentUpon>AlbumListView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="AlbumListViewModel.cs" />
+ <Compile Include="MainViewModel.cs" />
+ <Page Include="AlbumEditDialogView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="AlbumEditView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ <Page Include="MainWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="MainWindow.xaml.cs">
+ <DependentUpon>MainWindow.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Page Include="AlbumListView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="PowerShellConsoleLauncher.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\BeaverMusic.UI\BeaverMusic.UI.csproj">
+ <Project>{16B5931B-D1A5-40F7-85B3-C172AA3847B7}</Project>
+ <Name>BeaverMusic.UI</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\BeaverMusic\BeaverMusic.csproj">
+ <Project>{652C401A-A9C1-4037-87B1-CE57540B0B14}</Project>
+ <Name>BeaverMusic</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\EmbeddedPSConsole\EmbeddedPSConsole.csproj">
+ <Project>{68DC6A0A-4378-439F-8E82-BC5552CCEE79}</Project>
+ <Name>EmbeddedPSConsole</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="albums.csv">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Include="app.config" />
+ <None Include="BeaverMusicProfile.ps1">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Include="test.ps1">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ChinookData.xml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
1 chapter05/BeaverMusic/BeaverMusic.UI.Shell/BeaverMusicProfile.ps1
@@ -0,0 +1 @@
+. .\test.ps1
View
BIN chapter05/BeaverMusic/BeaverMusic.UI.Shell/ChinookData.xml
Binary file not shown.
View
9 chapter05/BeaverMusic/BeaverMusic.UI.Shell/MainViewModel.cs
@@ -0,0 +1,9 @@
+using System.ComponentModel.Composition;
+
+namespace BeaverMusic.UI.Shell
+{
+ [Export]
+ class MainViewModel
+ {
+ }
+}
View
11 chapter05/BeaverMusic/BeaverMusic.UI.Shell/MainWindow.xaml
@@ -0,0 +1,11 @@
+<Window x:Class="BeaverMusic.UI.Shell.MainWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:bmui="http://beavermusic.com/client/ui"
+ xmlns:local="clr-namespace:BeaverMusic.UI.Shell"
+ WindowStartupLocation="CenterScreen"
+ Title="BeaverMusic" Height="350" Width="525">
+ <DockPanel>
+ <bmui:ViewElement Grid.Column="0" ViewType="local:AlbumListView" ViewModelType="local:AlbumListViewModel"/>
+ </DockPanel>
+</Window>
View
12 chapter05/BeaverMusic/BeaverMusic.UI.Shell/MainWindow.xaml.cs
@@ -0,0 +1,12 @@
+using System.Windows;
+
+namespace BeaverMusic.UI.Shell
+{
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
View
72 chapter05/BeaverMusic/BeaverMusic.UI.Shell/PowerShellConsoleLauncher.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.ComponentModel.Composition.Hosting;
+using System.ComponentModel.Composition.Primitives;
+using EmbeddedPSConsole;
+using System.Windows;
+
+namespace BeaverMusic.UI.Shell
+{
+ public interface IPowerShellConsoleLauncher
+ {
+ void Launch();
+ }
+
+ [Export(typeof(IPowerShellConsoleLauncher))]
+ internal class PowerShellConsoleLauncher : IPowerShellConsoleLauncher
+ {
+ private readonly IAlbumRepository _albumRepository;
+ private readonly MefHelper _mefHelper;
+
+ private PSConsole _console;
+
+ [ImportingConstructor]
+ public PowerShellConsoleLauncher(IAlbumRepository albumRepository, MefHelper mefHelper)
+ {
+ _albumRepository = albumRepository;
+ _mefHelper = mefHelper;
+ }
+
+ public void Launch()
+ {
+ if (_console != null)
+ {
+ _console.Activate();
+ return;
+ }
+
+ PSConfig.AddVariable("MEFHelper", _mefHelper);
+ PSConfig.AddVariable("AlbumRepository", _albumRepository);
+ PSConfig.AddVariable("MainWindow", Application.Current.MainWindow);
+
+ PSConfig.Profile = "BeaverMusicProfile.ps1";
+ _console = new PSConsole();
+ _console.Closing += (s, e) => _console = null;
+
+ _console.Show();
+ }
+
+ [Export]
+ public class MefHelper
+ {
+ [Import]
+ public ExportProvider ExportProvider { get; set; }
+
+ public object GetExport(string contractName)
+ {
+ return ExportProvider.GetExport<object>(contractName).Value;
+ }
+
+ public ComposablePartCatalog GetMEFCatalog
+ {
+ get { return ((CompositionContainer)ExportProvider).Catalog; }
+ }
+
+ public IEnumerable<ComposablePartDefinition> GetMEFCatalogParts
+ {
+ get { return GetMEFCatalog.Parts; }
+ }
+ }
+ }
+}
View
55 chapter05/BeaverMusic/BeaverMusic.UI.Shell/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("BeaverMusic")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BeaverMusic")]
+[assembly: AssemblyCopyright("Copyright © 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
+//inside a <PropertyGroup>. For example, if you are using US english
+//in your source files, set the <UICulture> to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
27 chapter05/BeaverMusic/BeaverMusic.UI.Shell/albums.csv
@@ -0,0 +1,27 @@
+Artist,Name
+"Michael Jackson","Thriller"
+"AC/DC","Back in Black"
+"Pink Floyd","The Dark Side of the Moon"
+"Whitney Houston / Various artists","The Bodyguard"
+"Meat Loaf","Bat Out of Hell"
+"Eagles","Their Greatest Hits"
+"Various artists","Dirty Dancing"
+"Backstreet Boys","Millennium"
+"Bee Gees / Various artists","Saturday Night Fever"
+"Fleetwood Mac","Rumours"
+"Shania Twain","Come On Over"
+"Led Zeppelin","Led Zeppelin IV"
+"Alanis Morissette","Jagged Little Pill"
+"The Beatles","Sgt. Pepper's Lonely Hearts Club Band"
+"Celine Dion","Falling into You"
+"Mariah Carey","Music Box"
+"Michael Jackson","Dangerous"
+"Celine Dion","Let's Talk About Love"
+"Bee Gees","Spirits Having Flown"
+"Bruce Springsteen","Born in the U.S.A."
+"Dire Straits","Brothers in Arms"
+"James Horner","Titanic"
+"Madonna","The Immaculate Collection"
+"Michael Jackson","Bad"
+"Pink Floyd","The Wall"
+"Nirvana","Nevermind"
View
3 chapter05/BeaverMusic/BeaverMusic.UI.Shell/app.config
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
View
234 chapter05/BeaverMusic/BeaverMusic.UI.Shell/test.ps1
@@ -0,0 +1,234 @@
+function New-Album {
+ <#
+ .Synopsis
+ Creates a new album.
+ .Description
+ The New-Album function creates a new album and sets both the album name and artist.
+ .Example
+ New-Album "Sad Wings Of Destiny" "Judas Priest"
+ #>
+
+ param(
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [string]$Name,
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [string]$Artist
+ )
+
+ Process {
+ $album = New-Object BeaverMusic.Album
+
+ $album.Name = $Name
+ $album.Artist = $Artist
+
+ $album
+ }
+}
+
+function Clear-Album {
+ <#
+ .Synopsis
+ Deletes the albums in the Beaver Music list.
+ .Description
+ The Clear-Album deletes the contents of in the Beaver Music main window.
+ .Example
+ Clear-Album
+ #>
+
+ $AlbumRepository.Clear()
+}
+
+function Get-Album {
+ <#
+ .Synopsis
+ Gets a list of the albums currently in the repository session.
+ .Description
+ The Get-Album can get the list of albums or can filter on a
+ .Example
+ Get-Album
+ .Example
+ New-Album "Sad Wings Of Destiny" "Judas Priest" | Add-Album
+ Get-Album Wings
+ #>
+
+ param(
+ #
+ $name
+ )
+ $AlbumRepository.GetAlbums() |
+ Where {$_.Name -match $Name}
+}
+
+function Add-Album {
+ <#
+ .Synopsis
+ Appends ablums to the album repository.
+ .Description
+ The Add-Album function adds ablums to the end of the album repository. This results to it showing up in main window.
+ .Example
+ New-Album "Sad Wings Of Destiny" "Judas Priest" | Add-Album
+ .Example
+ Add-Album (New-Album "Stained Glass" "Judas Priest")
+ #>
+ param(
+ [Parameter(ValueFromPipeline=$true)]
+ $album
+ )
+
+ Process {
+ $AlbumRepository.SaveAlbum($album) | Out-Null
+ }
+}
+
+function Remove-Album {
+ <#
+ .Synopsis
+ Appends ablums to the album repository.
+ .Description
+ The Remove-Album function adds ablums to the end of the album repository. This results to it showing up in main window.
+ .Example
+ New-Album "Sad Wings Of Destiny" "Judas Priest" | Add-Album
+ Get-Album Wings | Remove-Album