本文整理汇总了C#中Mapper.SetAttributeMap方法的典型用法代码示例。如果您正苦于以下问题:C# Mapper.SetAttributeMap方法的具体用法?C# Mapper.SetAttributeMap怎么用?C# Mapper.SetAttributeMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper.SetAttributeMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ElementValueAndAttributeWithSameNameAreParsedCorrectly
public void ElementValueAndAttributeWithSameNameAreParsedCorrectly()
{
string input = "<TestClass TestElement=\"1\">" +
"<TestElement>2</TestElement>" +
"</TestClass>";
var mapper = new Mapper<TestClass>(input);
mapper.SetAttributeMap("TestElement", "DoubleProp");
mapper.SetElementMap("TestElement", "DecimalProp");
TestClass result = mapper.ParseNext();
Assert.AreEqual(1, result.DoubleProp);
Assert.AreEqual(2, result.DecimalProp);
}
示例2: FluentAttributeMappingWorksCorrectly
public void FluentAttributeMappingWorksCorrectly()
{
string input = "<TestClass TestAttr=\"5\" /> ";
var mapper = new Mapper<TestClass>(input);
mapper.SetAttributeMap("TestAttr", x => x.DoubleProp);
TestClass result = mapper.ParseNext();
Assert.AreEqual(null, result.NullableDoubleProp);
}
示例3: ParseOptionsOnAttributeValuesWorkCorrectly
public void ParseOptionsOnAttributeValuesWorkCorrectly()
{
string input = "<TestClass WeirdDate=\"2001-05;17\" />";
var mapper = new Mapper<TestClass>(input);
mapper.SetAttributeMap("WeirdDate", "Date", "yyyy-MM;dd");
TestClass t = mapper.ParseNext();
Assert.AreEqual(new DateTime(2001, 05, 17), t.Date);
}
示例4: PropertyUsedWithSetAttributeMapParsedCorrectly
public void PropertyUsedWithSetAttributeMapParsedCorrectly()
{
var mapper = new Mapper<TestClass>(_input, "SampleXml");
mapper.SetAttributeMap("BarFoo", "FooBar");
TestClass t = mapper.ParseNext();
Assert.AreEqual(1, t.FooBar);
}
示例5: ParseCFDCharges
private static void ParseCFDCharges(XContainer xml, IDBContext context, bool skipLastDateCheck, DateTime lastDate, Account account)
{
var cfdTransactionsMapper = new Mapper<CashTransaction>(xml.Descendants("CFDCharge"));
cfdTransactionsMapper.SetAttributeMap("total", "Amount");
cfdTransactionsMapper.SetAttributeMap("date", "TransactionDate", "yyyy-MM-dd");
List<CashTransaction> cfdCharges = cfdTransactionsMapper.ParseAll();
var instruments = context.Instruments.ToList();
var currencies = context.Currencies.ToList();
foreach (CashTransaction i in cfdCharges)
{
i.Type = "CFD Charge";
if (skipLastDateCheck || i.TransactionDate > lastDate)
{
i.Account = account;
i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
context.CashTransactions.Add(i);
}
}
context.SaveChanges();
//<CFDCharge accountId="U1066712F" currency="USD" assetCategory="CFD" fxRateToBase="1"
//symbol="--" description="--" conid="--" securityID="--" securityIDType="--" cusip="--"
//isin="--" underlyingConid="--" underlyingSymbol="--" issuer="--" date="2013-01-03" received="0"
//paid="-1.27" total="-1.27" transactionID="3283049378" />
}