PoshCode Archive  Artifact [2b9d36a149]

Artifact 2b9d36a149414cd10d02aeb5a5a4fa05c520325844f658561d54bf154881d6ba:

  • File Invoke-Inline.ps1 — part of check-in [d62ad63f2a] at 2018-06-10 13:06:33 on branch trunk — From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes (user: Lee Holmes size: 939)

# encoding: ascii
# api: powershell
# title: Invoke-Inline.ps1
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 0.1
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2180
# x-archived: 2016-03-19T00:32:32
# x-published: 2011-09-09T21:41:00
#
#
#############################################################################
##
## Invoke-Inline
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
#############################################################################

<#

.SYNOPSIS

Demonstrates the Add-Type cmdlet to invoke in-line C#

#>

Set-StrictMode -Version Latest

$inlineType = Add-Type -Name InvokeInline_Inline -PassThru `
    -MemberDefinition @'
    public static int RightShift(int original, int places)
    {
        return original >> places;
    }
'@

$inlineType::RightShift(1024, 3)