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


C# Mapper.ParseAll方法代码示例

本文整理汇总了C#中Mapper.ParseAll方法的典型用法代码示例。如果您正苦于以下问题:C# Mapper.ParseAll方法的具体用法?C# Mapper.ParseAll怎么用?C# Mapper.ParseAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mapper的用法示例。


在下文中一共展示了Mapper.ParseAll方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseSecuritiesInfo

        private static void ParseSecuritiesInfo(XContainer xml, IDBContext context)
        {
            var instrumentMapper = new Mapper<Instrument>(xml.Descendants("SecurityInfo"));
            List<Instrument> instruments = instrumentMapper.ParseAll();

            foreach (Instrument i in instruments)
            {
                if (context.Instruments.Count(x => x.ConID == i.ConID) == 0)
                {
                    context.Instruments.Add(i);
                    context.SaveChanges();
                }
            }

            //<SecurityInfo @assetCategoryassetCategory="STK" symbol="AAPL" description="APPLE INC"
            //conid="265598" securityID="" securityIDType="" cusip="" isin="" underlyingConid=""
            //underlyingSymbol="" issuer="" multiplier="1" expiry="" strike="" maturity="-" issueDate="" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:18,代码来源:FlexParser.cs

示例2: ParseAllReturnsAllElementsCorrectly

        public void ParseAllReturnsAllElementsCorrectly()
        {
            string input = "<Collection>" +
                                "<TestClass IntProp=\"0\" /> " +
                                "<TestClass IntProp=\"1\" /> " +
                                "<TestClass IntProp=\"2\" /> " +
                                "<TestClass IntProp=\"3\" /> " +
                                "<TestClass IntProp=\"4\" /> " +
                                "<TestClass IntProp=\"5\" /> " +
                            "</Collection>";

            var mapper = new Mapper<TestClass>(input);
            List<TestClass> result = mapper.ParseAll();
            Assert.AreEqual(6, result.Count);
            for (int i = 0; i < 6; i++)
            {
                Assert.AreEqual(i, result[i].IntProp);
            }
        }
开发者ID:qusma,项目名称:NXmlMapper,代码行数:19,代码来源:NXmlMapperTests.cs

示例3: 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

示例4: ParseCashTransactions

        private static void ParseCashTransactions(XContainer xml, IDBContext context, bool skipLastDateCheck, DateTime lastDate, Account account)
        {
            var cashTransactionsMapper = new Mapper<CashTransaction>(xml.Descendants("CashTransaction"));
            List<CashTransaction> cashTransactions = cashTransactionsMapper.ParseAll();

            var instruments = context.Instruments.ToList();
            var currencies = context.Currencies.ToList();

            foreach (CashTransaction i in cashTransactions)
            {
                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();

            //<CashTransaction accountId="U1066712" currency="CAD" assetCategory="STK" fxRateToBase="0.99717"
            //symbol="XRE" description="XRE() DIVIDEND .0615 CAD PER SHARE - CA TAX" conid="74580643" securityID=""
            //securityIDType="" cusip="" isin="" underlyingConid="" underlyingSymbol="" issuer="" dateTime="2012-07-31"
            //amount="-6.92" type="Withholding Tax" tradeID="" code="" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:25,代码来源:FlexParser.cs

示例5: ParseExecutions

        private static void ParseExecutions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            if (!xml.Descendants("Trades").Any()) return;

            var tradesMapper = new Mapper<Execution>(xml.Descendants("Trades").First().Descendants("Trade"));
            List<Execution> executions = tradesMapper.ParseAll();

            DateTime lastDate = context.Executions.Any(x => x.AccountID == account.ID)
                ? context.Executions.Where(x => x.AccountID == account.ID).Max(x => x.TradeDate)
                : new DateTime(1, 1, 1);

            var currencies = context.Currencies.ToList();
            var instruments = context.Instruments.ToList();
            var orderReferenceSet = new List<long>(); //used to keep track of which orders we have set the order reference for, so we don't do it multiple times

            //then add the new ones
            foreach (Execution i in executions)
            {
                if (i.TradeDate > lastDate || skipLastDateCheck)
                {
                    i.Account = account;
                    i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.CommissionCurrency = currencies.FirstOrDefault(x => x.Name == i.CommissionCurrencyString);
                    var order = context.Orders.FirstOrDefault(x => x.IBOrderID == i.IBOrderID);
                    i.Order = order;
                    if (!string.IsNullOrEmpty(i.OrderReference) && !orderReferenceSet.Contains(i.IBOrderID))
                    {
                        orderReferenceSet.Add(i.IBOrderID);
                        order.OrderReference = i.OrderReference;

                        ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(order, EntityState.Modified);
                    }
                    context.Executions.Add(i);
                }
            }
            context.SaveChanges();

            //<Trade accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="VGK"
            //description="VANGUARD MSCI EUROPEAN ETF" conid="27684070" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" tradeID="812956946" reportDate="20121231" tradeDate="20121231"
            //tradeTime="160000" settleDateTarget="20130104" transactionType="ExchTrade" exchange="ARCA" quantity="-60" tradePrice="48.84"
            //multiplier="1" tradeMoney="-2930.4" proceeds="2930.4" taxes="0" ibCommission="-1" ibCommissionCurrency="USD" closePrice="48.84"
            //openCloseIndicator="C" notes="P;" cost="-2869.2" fifoPnlRealized="60.2" mtmPnl="0" origTradePrice="0" origTradeDate=""
            //origTradeID="" origOrderID="0" strike="" expiry="" putCall="" buySell="SELL" ibOrderID="415554439"
            //ibExecID="0000d3de.50e1a59d.01.01" brokerageOrderID="" orderReference="" volatilityOrderLink=""
            //orderPlacementTime="" clearingFirmID="" exchOrderId="N/A" extExecID="AD_5629512420665350" orderTime="20121231;142412"
            //openDateTime="--" holdingPeriodDateTime="--" whenRealized="--" whenReopened="--" levelOfDetail="EXECUTION"
            //changeInPrice="0" changeInQuantity="0" netCash="2929.4" orderType="MOC" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:50,代码来源:FlexParser.cs

示例6: ParseOrders

        private static void ParseOrders(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            if (!xml.Descendants("Trades").Any()) return;

            var ordersMapper = new Mapper<Order>(xml.Descendants("Trades").First().Descendants("Order"));
            List<Order> orders = ordersMapper.ParseAll();

            DateTime lastDate = context.Orders.Any(x => x.AccountID == account.ID)
                ? context.Orders.Where(x => x.AccountID == account.ID).Max(x => x.TradeDate)
                : new DateTime(1, 1, 1);

            var instruments = context.Instruments.ToList();
            var currencies = context.Currencies.ToList();

            //then add the new ones
            foreach (Order order in orders)
            {
                if (order.TradeDate > lastDate || skipLastDateCheck)
                {
                    order.IsReal = true;
                    if(order.AssetCategory == AssetClass.Cash)
                    {
                        //These are currency trades. But currencies aren't provided in the SecuritiesInfos
                        //So we have to hack around it and add the currency as an instrument "manually" if it's not in yet
                        order.Instrument = TryAddAndGetCurrencyInstrument(order, context);
                    }
                    else
                    {
                        order.Instrument = instruments.FirstOrDefault(x => x.ConID == order.ConID);
                    }

                    order.Account = account;
                    order.Currency = currencies.FirstOrDefault(x => x.Name == order.CurrencyString);
                    order.CommissionCurrency = currencies.FirstOrDefault(x => x.Name == order.CommissionCurrencyString);
                    context.Orders.Add(order);
                }
            }
            context.SaveChanges();

            //<Order accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="AAPL"
            //description="APPLE INC" conid="265598" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" tradeID="--" reportDate="20140325" tradeDate="20140325"
            //tradeTime="093002" settleDateTarget="20140328" transactionType="--" exchange="--" quantity="-48"
            //tradePrice="541.37" multiplier="1" tradeMoney="-25985.76" proceeds="25985.76" taxes="0" ibCommission="-1.574285"
            //ibCommissionCurrency="USD" closePrice="544.99" openCloseIndicator="C" notes="C" cost="-25877.8" fifoPnlRealized="106.385715"
            //mtmPnl="-173.76" origTradePrice="--" origTradeDate="--" origTradeID="--" origOrderID="--" strike="" expiry="" putCall=""
            //buySell="SELL" ibOrderID="537171278" ibExecID="--" brokerageOrderID="--" orderReference="--" volatilityOrderLink="--"
            //orderPlacementTime="--" clearingFirmID="--" exchOrderId="--" extExecID="--" orderTime="20140325;093002" openDateTime="--"
            //holdingPeriodDateTime="--" whenRealized="--" whenReopened="--" levelOfDetail="ORDER" changeInPrice="--" changeInQuantity="--"
            //netCash="25984.185715" orderType="LMT" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:51,代码来源:FlexParser.cs

示例7: ParseOpenPositions

        private static void ParseOpenPositions(XContainer xml, IDBContext context, Account account)
        {
            if (!xml.Descendants("OpenPositions").Any()) return;
            var openPositionsMapper = new Mapper<OpenPosition>(xml.Descendants("OpenPosition").Where(x => x.Attribute("levelOfDetail").Value == "SUMMARY"));
            List<OpenPosition> openPositions = openPositionsMapper.ParseAll();

            //start by deleting the old ones
            context.OpenPositions.RemoveRange(context.OpenPositions.Where(x => x.AccountID == account.ID).ToList());
            context.SaveChanges();

            //then add the new ones
            foreach (OpenPosition i in openPositions)
            {
                i.Account = account;
                i.Instrument = context.Instruments.FirstOrDefault(x => x.ConID == i.ConID);
                i.Currency = context.Currencies.FirstOrDefault(x => x.Name == i.CurrencyString);

                context.OpenPositions.Add(i);
            }
            context.SaveChanges();

            //<OpenPosition accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="ACWV"
            //description="ISHARES MSCI ALL COUNTRY WOR" conid="96090060" securityID="" securityIDType="" cusip=""
            //isin="" underlyingConid="" underlyingSymbol="" issuer="" reportDate="20130131" position="18" multiplier="1"
            //markPrice="58.01" positionValue="1044.18" openPrice="55.877777778" costBasisPrice="55.877777778"
            //costBasisMoney="1005.8" percentOfNAV="1.61" fifoPnlUnrealized="38.38" side="Long" @levelOfDetaillevelOfDetail="SUMMARY"
            //openDateTime="" holdingPeriodDateTime="" code="" originatingOrderID="" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:28,代码来源:FlexParser.cs

示例8: ParseEquitySummaries

        private static void ParseEquitySummaries(XContainer xml, IDBContext context, Account account)
        {
            var equitySummaryMapper = new Mapper<EquitySummary>(xml.Descendants("EquitySummaryByReportDateInBase"));
            List<EquitySummary> equitySummaries = equitySummaryMapper.ParseAll();

            foreach (EquitySummary i in equitySummaries)
            {
                if (context.EquitySummaries.Count(x => x.Date == i.Date && x.AccountID == account.ID) == 0)
                {
                    i.Account = account;
                    context.EquitySummaries.Add(i);
                    context.SaveChanges();
                }
            }

            //<EquitySummaryByReportDateInBase accountId="U1066712" reportDate="2012-07-18" cash="-8839.601715" cashLong="0"
            //cashShort="-8839.601715" slbCashCollateral="0" slbCashCollateralLong="0" slbCashCollateralShort="0"
            //stock="38134.228955" stockLong="38134.228955" stockShort="0" slbDirectSecuritiesBorrowed="0"
            //slbDirectSecuritiesBorrowedLong="0" slbDirectSecuritiesBorrowedShort="0" slbDirectSecuritiesLent="0"
            //slbDirectSecuritiesLentLong="0" slbDirectSecuritiesLentShort="0" options="235.75" optionsLong="235.75"
            //optionsShort="0" commodities="0" commoditiesLong="0" commoditiesShort="0" bonds="0" bondsLong="0" bondsShort="0"
            //notes="0" notesLong="0" notesShort="0" interestAccruals="-7.2318305" interestAccrualsLong="0"
            //interestAccrualsShort="-7.2318305" softDollars="0" softDollarsLong="0" softDollarsShort="0" dividendAccruals="0"
            //dividendAccrualsLong="0" dividendAccrualsShort="0" total="29523.1454095" totalLong="38369.978955" totalShort="-8846.8335455" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:25,代码来源:FlexParser.cs

示例9: ParseFXRates

        private static void ParseFXRates(XContainer xml, IDBContext context)
        {
            var fxRatesMapper = new Mapper<FXRate>(xml.Descendants("ConversionRate"));
            List<FXRate> fxRates = fxRatesMapper.ParseAll();

            var currencies = context.Currencies.ToList();

            foreach (FXRate i in fxRates)
            {
                i.FromCurrency = currencies.FirstOrDefault(x => x.Name == i.FromCurrencyString);
                i.ToCurrency = currencies.FirstOrDefault(x => x.Name == i.ToCurrencyString);

                if (!context.FXRates.Any(x =>
                    x.FromCurrency.ID == i.FromCurrency.ID &&
                    x.ToCurrency.ID == i.ToCurrency.ID &&
                    x.Date == i.Date))
                {
                    context.FXRates.Add(i);
                }
            }
            context.SaveChanges();

            //<ConversionRate reportDate="2012-12-28" fromCurrency="CHF" toCurrency="USD" rate="1.0947" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:24,代码来源:FlexParser.cs

示例10: ParsePriorPeriodPositions

        private static void ParsePriorPeriodPositions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            var priorPeriodPositionsMapper = new Mapper<PriorPosition>(xml.Descendants("PriorPeriodPosition"));
            List<PriorPosition> priorPeriodPositions = priorPeriodPositionsMapper.ParseAll();

            DateTime lastDate = context.PriorPositions.Any(x => x.AccountID == account.ID)
                ? context.PriorPositions.Where(x => x.AccountID == account.ID).Max(x => x.Date)
                : new DateTime(1, 1, 1);

            var currencies = context.Currencies.ToList();
            var instruments = context.Instruments.ToList();

            foreach (PriorPosition i in priorPeriodPositions)
            {
                if (skipLastDateCheck || i.Date > lastDate)
                {
                    i.Account = account;
                    i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    context.PriorPositions.Add(i);
                }
            }
            context.SaveChanges();

            //<PriorPeriodPosition accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="ACWV"
            //description="ISHARES MSCI ALL COUNTRY WOR" conid="96090060" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" date="2012-12-28" price="55.23" priorMtmPnl="-9" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:28,代码来源:FlexParser.cs

示例11: ParseOpenDividendAccruals

        private static void ParseOpenDividendAccruals(XContainer xml, IDBContext context, Account account)
        {
            var openDividendAccrualsMapper = new Mapper<DividendAccrual>(xml.Descendants("OpenDividendAccrual"));
            List<DividendAccrual> dividendAccruals = openDividendAccrualsMapper.ParseAll();

            //delete all of them
            context.DividendAccruals.RemoveRange(context.DividendAccruals.Where(x => x.AccountID == account.ID).ToList());

            //then add the new ones
            foreach (DividendAccrual i in dividendAccruals)
            {
                i.Currency = context.Currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                i.Instrument = context.Instruments.FirstOrDefault(x => x.ConID == i.ConID);
                i.Account = account;
                if (i.Instrument == null)
                {
                    var logger = LogManager.GetCurrentClassLogger();
                    logger.Log(LogLevel.Error, "Could not find instrument for dividend accrual with conid: " + i.ConID);
                }
                else
                {
                    context.DividendAccruals.Add(i);
                }
            }
            context.SaveChanges();

            //<OpenDividendAccrual accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="PICB"
            //description="POWERSHARES INT CORP BOND" conid="75980548" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" exDate="2013-01-15" payDate="2013-01-31" quantity="19" tax="0.44"
            //fee="0" grossRate="0.07613" grossAmount="1.45" netAmount="1.01" code="" fromAcct="" toAcct="" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:31,代码来源:FlexParser.cs

示例12: ParseFXPositions

        private static void ParseFXPositions(XContainer xml, IDBContext context, Account account)
        {
            var fxPositionsMapper = new Mapper<FXPosition>(xml.Descendants("FxPosition"));
            List<FXPosition> fxPositions = fxPositionsMapper.ParseAll();

            //delete all of them
            context.FXPositions.RemoveRange(context.FXPositions.Where(x => x.AccountID == account.ID).ToList());

            //then add the new ones
            foreach (FXPosition i in fxPositions)
            {
                i.FunctionalCurrency = context.Currencies.FirstOrDefault(x => x.Name == i.FunctionalCurrencyString);
                i.FXCurrency = context.Currencies.FirstOrDefault(x => x.Name == i.FXCurrencyString);
                i.Account = account;
                context.FXPositions.Add(i);
            }
            context.SaveChanges();

            //<FxPosition accountId="U1066712" acctAlias="" assetCategory="CASH" reportDate="20140325"
            //functionalCurrency="USD" fxCurrency="CAD" quantity="22.379966" costPrice="0.890970031" costBasis="-19.939879"
            //closePrice="0.89552" value="20.041707" unrealizedPL="0.101828" code="" lotDescription="" lotOpenDateTime="" levelOfDetail="SUMMARY" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:22,代码来源:FlexParser.cs

示例13: ParseFXTransactions

        private static void ParseFXTransactions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            var fxTransactionMapper = new Mapper<FXTransaction>(xml.Descendants("FxTransaction"));
            List<FXTransaction> fxTransactions = fxTransactionMapper.ParseAll();

            DateTime lastDate = context.FXTransactions.Any(x => x.AccountID == account.ID)
                ? context.FXTransactions.Where(x => x.AccountID == account.ID).Max(x => x.DateTime)
                : new DateTime(1, 1, 1);

            var currencies = context.Currencies.ToList();

            //then add the new ones
            foreach (FXTransaction i in fxTransactions)
            {
                if (i.DateTime > lastDate || skipLastDateCheck)
                {
                    i.FunctionalCurrency = currencies.FirstOrDefault(x => x.Name == i.FunctionalCurrencyString);
                    i.FXCurrency = currencies.FirstOrDefault(x => x.Name == i.FXCurrencyString);
                    context.FXTransactions.Add(i);
                }
            }
            context.SaveChanges();

            //<FxTransaction accountId="U1066712" acctAlias="" assetCategory="CASH" reportDate="20130401"
            //functionalCurrency="USD" fxCurrency="CAD" activityDescription="XRE() DIVIDEND .06726 CAD PER SHARE"
            //dateTime="20130328;202000" quantity="16.29" proceeds="16.034084" cost="-16.034084" realizedPL="0"
            //code="O" levelOfDetail="TRANSACTION" />
        }
开发者ID:QANTau,项目名称:QPAS,代码行数:28,代码来源:FlexParser.cs


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