Monday, January 24, 2011

posh, the graphical powershell cli

일본어 윈도우를 사용하는데, 우연히 그래픽컬 파워쉘 cli인 posh를 사용해보니 한글 입출력이 문제없이 잘 된다.
그래서 한글로 클래스 등록해봤음.


$source = @"
public class 산수
{
public static int 더해라(int a, int b)
{
return (a + b);
}

public int 곱해라(int a, int b)
{
return (a * b);
}
}
"@
$CompParam = New-Object System.CodeDom.Compiler.CompilerParameters
$CompParam.CompilerOptions = "/codepage:65001"

Add-Type $source -Language VisualBasic -CompilerParameters $CompParam


----------------------------------결과

[53]: New-Object 산수 | gm



TypeName: 산수

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
곱해라 Method int 곱해라(int a, int b)


[54]: $a = New-Object 산수


[55]: $a.곱해라(4, 5)

20

No comments: