Public/Coding/New-EdenServiceComponent.ps1
function New-EdenServiceComponent { [CmdletBinding()] param( [Alias("n")] [String] $Name, [Alias("svn")] [String] $ServiceName, [Alias("sln")] [String] $SolutionName, [Alias("ty")] [String] $Type, [Alias("t")] [String] $Template, [Alias("f")] [Switch] $Force, # The name of the local or global settins file to pass to the Eden script. [Alias("sn")] [String]$SettingsName ) $location = Get-Location try { $settings = Get-EdenSettings -Name $SettingsName $loggingPrefix = "$($settings.SolutionName) $($settings.ServiceName) Eden Coding" if (!$ServiceName) { $ServiceName = Split-Path $location -Leaf } if (!$SolutionName) { $SolutionName = Split-Path (Split-Path $location -Parent) -Leaf } if($Template) { Write-EdenInfo "Creating a new Eden service component '$SolutionName.$ServiceName.$Name' from template '$Template'." $loggingPrefix [string] $tempDirectory = "./Eden/.temp" if (Test-Path "./Eden/.temp") { Remove-Item "./Eden/.temp" -Recurse -Force } else { New-Item -Path "./Eden/.temp" -ItemType Directory -Force } [string] $sourceDirectory = "./Eden/Templates/$Template/*" if (!(Test-Path $sourceDirectory)) { Write-EdenError "The template does not exist." $loggingPrefix } Copy-Item $sourceDirectory -Destination $tempDirectory -Force -Recurse -Verbose Set-StringReplacement $tempDirectory "MyEdenSolution" $SolutionName Set-StringReplacement $tempDirectory "MyEdenService" $ServiceName Set-StringReplacement $tempDirectory "MyEdenComponent" $Name Write-Verbose Get-Location Copy-Item "$tempDirectory/*" -Destination $location -Recurse -Verbose Write-EdenInfo "Finished creating a new Eden service component." $loggingPrefix } else { Write-EdenInfo "Creating a new Eden service component '$SolutionName.$ServiceName.$Name' from type '$Type'." $loggingPrefix $additionalParams = @{ Name = $Name ServiceName = $ServiceName SolutionNAme = $SolutionName Type = $Type } Invoke-EdenLocalCommand "Coding/New-ServiceComponent" $null $loggingPrefix $additionalParams Write-EdenInfo "Finished creating a new Eden service component." $loggingPrefix } } catch { Write-EdenError "Error creating a new Eden service component. Message: '$($_.Exception.Message)'" $loggingPrefix } finally { Set-Location $location } } New-Alias ` -Name e-cc ` -Value New-EdenServiceComponent ` -Force |