UltraMapper.CommandLine
v0.2.35
직접 메소드 호출을 지원하는 명령 선 파서
Ultramapper.commandline은 .NET 명령 줄 파서 입니다. 명령 줄 텍스트 및 맵 (TRASFORM)을 강력하게 유형 된 객체로 구문 분석 (분석 및 해석)하는 도구입니다.
Ultramapper.commandline 코드를 크게 단순화합니다.
Ultramapper.commandline은 강력한 .NET 매퍼 인 Ultramapper로 구동됩니다!
좋아, 이것은 그것에 약간의 복잡성을 가질 것이지만, 나는 당신에게 깊은 인상을주고 싶습니다!
다음 예는 CommandLine 에서 AddTodatabase 메소드를 호출하는 방법 을 보여줍니다.
class Program
{
static void Main ( string [ ] args )
{
//--add ("John Smith" 26 account=(number=AC2903X balance=3500.00 creditcards=[(CRD01 1000.00) (CRD02 2000.00)]))
CommandLine . Instance . Parse < CommandLineSupportedCommands > ( args ) ;
}
public class CommandLineSupportedCommands
{
[ Option ( Name = "add" , HelpText = "Adds new customer to db" ) ]
public void AddToDatabase ( CustomerInfo customer )
{
Assert . IsTrue ( customer . Name == "John Smith" ) ;
Assert . IsTrue ( customer . Age == 26 ) ;
Assert . IsTrue ( customer . Account . AccountNumber == "AC2903X" ) ;
Assert . IsTrue ( customer . Account . Balance == 3500 ) ;
Assert . IsTrue ( customer . Account . CreditCards [ 0 ] . CardNumber == "CRD01" ) ;
Assert . IsTrue ( customer . Account . CreditCards [ 0 ] . MonthlyLimit == 1000 ) ;
Assert . IsTrue ( customer . Account . CreditCards [ 1 ] . CardNumber == "CRD02" ) ;
Assert . IsTrue ( customer . Account . CreditCards [ 1 ] . MonthlyLimit == 2000 ) ;
Console . WriteLine ( "New customer inserted!" ) ;
}
}
public class CustomerInfo
{
public class BankAccountInfo
{
public class CreditCardInfo
{
public string CardNumber { get ; set ; }
public double MonthlyLimit { get ; set ; }
}
[ Option ( Name = "number" ) ]
public string AccountNumber { get ; set ; }
public double Balance { get ; set ; }
public List < CreditCardInfo > CreditCards { get ; set ; }
}
public string Name { get ; set ; }
public int Age { get ; set ; }
public BankAccountInfo Account { get ; set ; }
}
}위의 예는 다음과 같은 몇 가지 기본 기능을 보여줍니다.
논쟁을 구문 분석하는 방법 :
T parsedArgs = CommandLine . Instance . Parse < T > ( args ) ; 위의 코드 줄은 모든 작업을 수행합니다.
일반적인 인수 t 는 '명령 클래스' 입니다.
'명령 클래스' 에서는 CommandLine 레벨에서 지원하려는 모든 작업을 정의합니다.
기본 구문 :
구문에 대해 알아야 할 전부는 아닙니다.
구문에 대한 자세한 내용은 여기를 참조하십시오
옵션 속성 :
옵션 속성에 대해 알아야 할 전부는 아닙니다.
옵션 속성에 대한 자세한 내용은 여기를 참조하십시오
Ultramapper.commandline 에 대해 알아야 할 몇 가지와 몇 가지 말이 있습니다.
자세한 내용은 위키에 확인하십시오
모든 피드백을 환영합니다