当前位置: 首页>>代码示例>>C#>>正文


C# Mapper.SetAttributeMap方法代码示例

本文整理汇总了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);
        }
开发者ID:qusma,项目名称:NXmlMapper,代码行数:14,代码来源:NXmlMapperTests.cs

示例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);
 }
开发者ID:qusma,项目名称:NXmlMapper,代码行数:8,代码来源:NXmlMapperTests.cs

示例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);
 }
开发者ID:qusma,项目名称:NXmlMapper,代码行数:8,代码来源:NXmlMapperTests.cs

示例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);
 }
开发者ID:qusma,项目名称:NXmlMapper,代码行数:7,代码来源:NXmlMapperTests.cs

示例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" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:29,代码来源:FlexParser.cs


注:本文中的Mapper.SetAttributeMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。