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


C# IList.LastOrDefault方法代码示例

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


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

示例1: GetAnchorMember

 private static ICSharpTypeMemberDeclaration GetAnchorMember(IList<ICSharpTypeMemberDeclaration> members)
 {
     var anchor = members.LastOrDefault(member =>
         member.DeclaredElement is IProperty && !member.IsStatic &&
         member.GetAccessRights() == AccessRights.PRIVATE) ??
                  members.LastOrDefault(member =>
                      member.DeclaredElement is IField && !member.IsStatic &&
                      member.GetAccessRights() == AccessRights.PRIVATE);
     return anchor;
 }
开发者ID:nrjohnstone,项目名称:mr-eric,代码行数:10,代码来源:IntroduceAndInitializePrivateAutoPropertyExectutor.cs

示例2: GetAnchorMember

            protected override ICSharpTypeMemberDeclaration GetAnchorMember(IList<ICSharpTypeMemberDeclaration> members)
            {
                var anchor = members.LastOrDefault(member =>
                       member.DeclaredElement is IProperty && member.IsStatic == IsStatic) ??
                     members.LastOrDefault(member =>
                       member.DeclaredElement is IField && member.IsStatic == IsStatic);
                if (anchor == null && IsStatic)
                {
                  return members.LastOrDefault(m => m.DeclaredElement is IProperty) ??
                 members.LastOrDefault(m => m.DeclaredElement is IField);
                }

                return anchor;
            }
开发者ID:Nangal,项目名称:resharper-postfix,代码行数:14,代码来源:IntroducePropertyTemplate.cs

示例3: EventPage

 public EventPage(long lastEncountered, IList<long> sequences, IList<IEvent> events)
 {
     Sequences = sequences;
     From = lastEncountered;
     To = Sequences.LastOrDefault();
     Streams = ToStreams(events);
 }
开发者ID:phillip-haydon,项目名称:marten,代码行数:7,代码来源:EventPage.cs

示例4: GetNodePathState

		/// <summary>
		/// Gets the state of <c>node</c> within the passed <c>currentPath</c>, which is the navigation breadcrumb.
		/// </summary>
		/// <param name="node">The node to get the state for</param>
		/// <param name="currentPath">The current path/breadcrumb</param>
		/// <returns>
		///		<see cref="NodePathState" /> enumeration indicating whether the node is in the current path (<c>Selected</c> or <c>Expanded</c>)
		///		and whether it has children (<c>Parent</c>)
		///	</returns>
		public static NodePathState GetNodePathState(this TreeNode<MenuItem> node, IList<MenuItem> currentPath)
		{
			Guard.ArgumentNotNull(() => currentPath);
			
			var state = NodePathState.Unknown;

			if (node.HasChildren)
			{
				state = state | NodePathState.Parent;
			}

			if (currentPath.Count > 0)
			{
				if (node.Value.Equals(currentPath.LastOrDefault()))
				{
					state = state | NodePathState.Selected;
				}
				else
				{
					if (node.Depth < currentPath.Count)
					{
						if (currentPath[node.Depth].Equals(node.Value))
						{
							state = state | NodePathState.Expanded;
						}
					}
				}
			}

			return state;
		}
开发者ID:boatengfrankenstein,项目名称:SmartStoreNET,代码行数:40,代码来源:MenuExtensions.cs

示例5: EventPage

 public EventPage(long @from, IList<long> sequences, IList<IEvent> events)
 {
     Sequences = sequences;
     From = @from;
     To = Sequences.LastOrDefault();
     Streams = ToStreams(events);
 }
开发者ID:JasperFx,项目名称:marten,代码行数:7,代码来源:EventPage.cs

示例6: ComplexLens

        /// <summary>
        /// Creates and initializes a new instance of a complex lens.
        /// </summary>
        /// <param name="surfaces">List of element surfaces, ordered from
        /// back to front.</param>
        public ComplexLens(IList<ElementSurface> surfaces)
        {
            ElementSurfaces = surfaces;

            ElementSurface frontSurface = surfaces.LastOrDefault((surface) => surface.Surface is Sphere);
            frontSphericalSurface = (Sphere)frontSurface.Surface;
            frontSurfaceSinTheta = frontSphericalSurface.GetCapElevationAngleSine(frontSurface.ApertureRadius);
            frontSurfaceApertureRadius = frontSurface.ApertureRadius;

            ElementSurface backSurface = surfaces.FirstOrDefault((surface) => surface.Surface is Sphere);
            backSphericalSurface = (Sphere)backSurface.Surface;
            backSurfaceSinTheta = backSphericalSurface.GetCapElevationAngleSine(backSurface.ApertureRadius);
            backSurfaceApertureRadius = backSurface.ApertureRadius;

            MediumRefractiveIndex = Materials.Fixed.AIR;
            frontSurface.NextRefractiveIndex = MediumRefractiveIndex;
        }
开发者ID:bzamecnik,项目名称:bokehlab,代码行数:22,代码来源:ComplexLens.cs

示例7: AddOrSimplify

 public static void AddOrSimplify(IList<Transform> transformList, Transform transform)
 {
     var last = transformList.LastOrDefault();
     if (transform.CanSimplify(last))
     {
         var simplified = transform.Simplify(last);
         if (simplified.IsNull)
         {
             transformList.RemoveAt(transformList.Count - 1);
         }
         else
         {
             transformList[transformList.Count - 1] = transform.Simplify(last);
         }
     }
     else if (!transform.IsNull)
     {
         transformList.Add(transform);
     }
 }
开发者ID:rprenhol,项目名称:naps2,代码行数:20,代码来源:Transform.cs

示例8: GetSqlFunction

        public virtual SqlStatement GetSqlFunction(SqlFunctionType functionType, bool forceIgnoreCase, IList<SqlStatement> parameters)
        {
            var pLast = parameters.LastOrDefault();
            switch (functionType) //
            {
            case SqlFunctionType.IsNull:
                return GetLiteralIsNull(parameters[0]);
            case SqlFunctionType.IsNotNull:
                return GetLiteralIsNotNull(parameters[0]);
            case SqlFunctionType.EqualNullables:
                return GetEqualNullables(parameters[0], parameters[1]);
            case SqlFunctionType.Concat:
                return GetLiteralStringConcat(parameters[0], parameters[1]);
            case SqlFunctionType.Count:
                return GetLiteralCount(parameters[0]);
            case SqlFunctionType.Exists:
                return GetLiteralExists(parameters[0]);
            case SqlFunctionType.Like:
                return GetLiteralLike(parameters[0], parameters[1], forceIgnoreCase);
            // RI: changed index to 1 (from 0) for Min, Max, Avg, Sum
            case SqlFunctionType.Min:
                return GetLiteralMin(pLast);
            case SqlFunctionType.Max:
                return GetLiteralMax(pLast);
            case SqlFunctionType.Sum:
                return GetLiteralSum(pLast);
            case SqlFunctionType.Average:
                return GetLiteralAverage(pLast);

            case SqlFunctionType.StringLength:
                return GetLiteralStringLength(parameters[0]);
            case SqlFunctionType.ToUpper:
                return GetLiteralStringToUpper(parameters[0]);
            case SqlFunctionType.ToLower:
                return GetLiteralStringToLower(parameters[0]);
            case SqlFunctionType.In:
                return GetLiteralIn(parameters[0], parameters[1]);
            case SqlFunctionType.InArray:
                return GetLiteralInArray(parameters[0], parameters[1]);
            case SqlFunctionType.StringEqual:
                return GetLiteralStringEqual(parameters[0], parameters[1], forceIgnoreCase);
            case SqlFunctionType.Substring:
                if (parameters.Count > 2)
                    return GetLiteralSubString(parameters[0], parameters[1], parameters[2]);
                else
                    return GetLiteralSubString(parameters[0], parameters[1]);
            case SqlFunctionType.Trim:
            case SqlFunctionType.LTrim:
            case SqlFunctionType.RTrim:
                return GetLiteralTrim(parameters[0]);
            case SqlFunctionType.StringInsert:
                return GetLiteralStringInsert(parameters[0], parameters[1], parameters[2]);
            case SqlFunctionType.Replace:
                return GetLiteralStringReplace(parameters[0], parameters[1], parameters[2]);
            case SqlFunctionType.Remove:
                if (parameters.Count > 2)
                    return GetLiteralStringRemove(parameters[0], parameters[1], parameters[2]);
                return GetLiteralStringRemove(parameters[0], parameters[1]);
            case SqlFunctionType.IndexOf:
                if (parameters.Count == 2)
                    return GetLiteralStringIndexOf(parameters[0], parameters[1]);
                else if (parameters.Count == 3)
                    return GetLiteralStringIndexOf(parameters[0], parameters[1], parameters[2]);
                else if (parameters.Count == 4)
                    return GetLiteralStringIndexOf(parameters[0], parameters[1], parameters[2], parameters[3]);
                break;
            case SqlFunctionType.Year:
            case SqlFunctionType.Month:
            case SqlFunctionType.Day:
            case SqlFunctionType.Hour:
            case SqlFunctionType.Minute:
            case SqlFunctionType.Second:
            case SqlFunctionType.Millisecond:
            case SqlFunctionType.Date:
            case SqlFunctionType.Time:
            case SqlFunctionType.Week:
              return GetLiteralDateTimePart(parameters[0], functionType);
            case SqlFunctionType.DateDiffInMilliseconds:
                return GetLiteralDateDiff(parameters[0], parameters[1]);
            case SqlFunctionType.Abs:
                return GetLiteralMathAbs(parameters[0]);
            case SqlFunctionType.Exp:
                return GetLiteralMathExp(parameters[0]);
            case SqlFunctionType.Floor:
                return GetLiteralMathFloor(parameters[0]);
            case SqlFunctionType.Ln:
                return GetLiteralMathLn(parameters[0]);

            case SqlFunctionType.Log:
                if (parameters.Count == 1)
                    return GetLiteralMathLog(parameters[0]);
                else
                    return GetLiteralMathLog(parameters[0], parameters[1]);
            case SqlFunctionType.Pow:
                return GetLiteralMathPow(parameters[0], parameters[1]);
            case SqlFunctionType.Round:
                return GetLiteralMathRound(parameters[0]);
            case SqlFunctionType.Sign:
                return GetLiteralMathSign(parameters[0]);
            case SqlFunctionType.Sqrt:
//.........这里部分代码省略.........
开发者ID:yuanfei05,项目名称:vita,代码行数:101,代码来源:LinqSqlProvider.cs

示例9: LevelsEntitiesController

 public LevelsEntitiesController()
 {
     Entities = new List<LevelsEntity>();
     for (int i = 1; i <= 10; i++)
     {
         if (i % 2 == 1)
         {
             var newEntity = new LevelsEntity
             {
                 ID = i,
                 Name = "Name " + i,
                 Parent = Entities.LastOrDefault(),
                 BaseEntities = Entities.Concat(new[]
                     {
                         new LevelsBaseEntity
                         {
                             ID = i + 10,
                             Name = "Name " + (i + 10)
                         }
                     }).ToArray(),
                 DerivedAncestors = Entities.OfType<LevelsDerivedEntity>().ToArray()
             };
             Entities.Add(newEntity);
         }
         else
         {
             var newEntity = new LevelsDerivedEntity
             {
                 ID = i,
                 Name = "Name " + i,
                 DerivedName = "DerivedName " + i,
                 Parent = Entities.LastOrDefault(),
                 BaseEntities = Entities.Concat(new[]
                     {
                         new LevelsBaseEntity
                         {
                             ID = i + 10,
                             Name = "Name " + (i + 10)
                         }
                     }).ToArray(),
                 DerivedAncestors = Entities.OfType<LevelsDerivedEntity>().ToArray(),
                 AncestorsInDerivedEntity = Entities.ToArray()
             };
             Entities.Add(newEntity);
         }
     }
     Entities[8].Parent = Entities[9];
     Entities[1].DerivedAncestors = new LevelsDerivedEntity[] { (LevelsDerivedEntity)Entities[3] }; 
 }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:49,代码来源:ODataLevelsTest.cs

示例10: GetAnchorMember

 protected override ICSharpTypeMemberDeclaration GetAnchorMember(IList<ICSharpTypeMemberDeclaration> members)
 {
     return members.LastOrDefault(member =>
       member.DeclaredElement is IField && member.IsStatic == IsStatic);
 }
开发者ID:Nangal,项目名称:resharper-postfix,代码行数:5,代码来源:IntroduceFieldTemplate.cs

示例11: AppendEndMarker

        private void AppendEndMarker(IList<MidiEvent> eventList)
        {
            long absoluteTime = 0;

            if (eventList.Count > 0)
                absoluteTime = eventList[eventList.Count - 1].AbsoluteTime;

            if (!IsEndTrack(eventList.LastOrDefault()))
                eventList.Add(new MetaEvent(MetaEventType.EndTrack, 0, absoluteTime));
        }
开发者ID:KarimLUCCIN,项目名称:NAudio,代码行数:10,代码来源:MidiConverter.cs

示例12: CreateSymbol

        /// <summary>
        /// Creates the symbol token from matched string.
        /// </summary>
        /// <param name="match">The matched string.</param>
        /// <param name="tokens">The list of tokens.</param>
        /// <exception cref="LexerException">
        /// The specified symbol is not supported.
        /// </exception>
        private void CreateSymbol(string match, IList<IToken> tokens)
        {
            if (match == "(")
            {
                tokens.Add(new SymbolToken(Symbols.OpenBracket));
            }
            else if (match == ")")
            {
                var lastToken = tokens.LastOrDefault() as SymbolToken;
                if (lastToken != null && lastToken.Symbol == Symbols.Comma)
                    throw new LexerException(Resource.NotEnoughParams);

                tokens.Add(new SymbolToken(Symbols.CloseBracket));
            }
            else if (match == "{")
            {
                if (!(tokens.LastOrDefault() is FunctionToken))
                    tokens.Add(new FunctionToken(Functions.Vector));

                tokens.Add(new SymbolToken(Symbols.OpenBrace));
            }
            else if (match == "}")
            {
                tokens.Add(new SymbolToken(Symbols.CloseBrace));
            }
            else if (match == ",")
            {
                tokens.Add(new SymbolToken(Symbols.Comma));
            }
            else
            {
                throw new LexerException(string.Format(Resource.NotSupportedSymbol, match));
            }
        }
开发者ID:sys27,项目名称:xFunc,代码行数:42,代码来源:Lexer.cs

示例13: CreateOperations

        /// <summary>
        /// Creates the operation token from matched string.
        /// </summary>
        /// <param name="match">The matched string.</param>
        /// <param name="tokens">The list of tokens.</param>
        /// <exception cref="LexerException">
        /// The specified operation is not supported.
        /// </exception>
        private void CreateOperations(string match, IList<IToken> tokens)
        {
            if (match == "+=")
            {
                tokens.Add(new OperationToken(Operations.AddAssign));
            }
            else if (match == "-=" || match == "−=")
            {
                tokens.Add(new OperationToken(Operations.SubAssign));
            }
            else if (match == "*=" || match == "×=")
            {
                tokens.Add(new OperationToken(Operations.MulAssign));
            }
            else if (match == "*" || match == "×")
            {
                tokens.Add(new OperationToken(Operations.Multiplication));
            }
            else if (match == "/")
            {
                tokens.Add(new OperationToken(Operations.Division));
            }
            else if (match == "^")
            {
                tokens.Add(new OperationToken(Operations.Exponentiation));
            }
            else if (match == "!")
            {
                var lastToken = tokens.LastOrDefault();
                if (lastToken != null)
                {
                    var symbol = lastToken as SymbolToken;
                    if ((symbol != null && symbol.Symbol == Symbols.CloseBracket) || lastToken is NumberToken || lastToken is VariableToken)
                    {
                        tokens.Add(new OperationToken(Operations.Factorial));
                        return;
                    }
                }

                throw new LexerException(string.Format(Resource.NotSupportedSymbol, match));
            }
            else if (match == "%" || match == "mod")
            {
                tokens.Add(new OperationToken(Operations.Modulo));
            }
            else if (match == "&&")
            {
                tokens.Add(new OperationToken(Operations.ConditionalAnd));
            }
            else if (match == "||")
            {
                tokens.Add(new OperationToken(Operations.ConditionalOr));
            }
            else if (match == "==")
            {
                tokens.Add(new OperationToken(Operations.Equal));
            }
            else if (match == "!=")
            {
                tokens.Add(new OperationToken(Operations.NotEqual));
            }
            else if (match == "<=")
            {
                tokens.Add(new OperationToken(Operations.LessOrEqual));
            }
            else if (match == "<")
            {
                tokens.Add(new OperationToken(Operations.LessThan));
            }
            else if (match == ">=")
            {
                tokens.Add(new OperationToken(Operations.GreaterOrEqual));
            }
            else if (match == ">")
            {
                tokens.Add(new OperationToken(Operations.GreaterThan));
            }
            else if (match == "++")
            {
                tokens.Add(new OperationToken(Operations.Increment));
            }
            else if (match == "--" || match == "−−")
            {
                tokens.Add(new OperationToken(Operations.Decrement));
            }
            else if (match == "+")
            {
                var lastToken = tokens.LastOrDefault();
                if (lastToken == null)
                {
                    return;
                }
//.........这里部分代码省略.........
开发者ID:sys27,项目名称:xFunc,代码行数:101,代码来源:Lexer.cs

示例14: Write

 private static void Write( StringBuilder sb, MethodInfo method, IList<ParameterInfo> parameters )
 {
     sb.AppendFormat( "{0} ", method.ReturnType.Name() );
     sb.AppendFormat( "{0}{1}( ", method.Name, GetGenericParameterText( method ) );
     ParameterInfo first = parameters.FirstOrDefault();
     ParameterInfo last = parameters.LastOrDefault();
     bool addPrefix = method.IsStatic && method.DeclaringType.Name.EndsWith( "Extensions" );
     parameters.ForEach( p => sb.AppendFormat( "{0}{1} {2}{3}",
                                               p == first && addPrefix ? "this " : "",
                                               GetType( p ), p.Name, p == last ? "" : ", " ) );
     sb.AppendFormat( " );{0}", Environment.NewLine );
 }
开发者ID:nintorii,项目名称:Zenject,代码行数:12,代码来源:AssemblyInfoWriter.cs

示例15: UpdateCandlesWithLiveData

        /// <summary>
        /// Updates a list of candles with the most recent data from a given exchange (Called when ticker refreshes)
        /// </summary>
        /// <param name="from">The from date</param>
        /// <param name="candlesDurationInMin">The period' duration in minutes</param>
        /// <param name="existingCandles">A list of existing candles</param>
        /// <returns>True if the update was successful</returns>
        public static bool UpdateCandlesWithLiveData(DateTime from, int candlesDurationInMin, IList<OHLC> existingCandles, CurrencyPair pair)
        {
            try
            {
                var proxy = ExchangeProxyFactory.GetProxy(pair.Exchange.InternalCode);

                //We first get the transactions for the last minute
                var transactionsRes = proxy.GetTransactions(true, pair);//
                if (!transactionsRes.Success)
                {
                    return false;
                }

                var transactions = transactionsRes.Result.Transactions;
                transactions.Reverse();//Make sure they are in ASC order

                transactions = transactions.Where(t => t.Date >= from).ToList();
                // Create trade list (required to calculate OHLC)
                IList<BitcoinCharts.Models.Trade> list = (from trade in transactions
                                                          select new BitcoinCharts.Models.Trade()
                                                          {
                                                              Datetime = trade.Date,
                                                              Price = trade.Price,
                                                              Quantity = trade.Amount,
                                                              Symbol = pair.Item2
                                                          }).ToList();

                //Check if we need to create another candle
                var lastCandle = existingCandles.LastOrDefault();
                if (list.Count == 0 && lastCandle != null)
                {
                    if (lastCandle.Date.Subtract(DateTime.MinValue).TotalMinutes / candlesDurationInMin
                        != DateTime.Now.Subtract(DateTime.MinValue).TotalMinutes / candlesDurationInMin)
                    {
                        list.Add(new BitcoinCharts.Models.Trade
                                                              {
                                                                  Datetime = lastCandle.Date.AddMilliseconds(candlesDurationInMin),
                                                                  Price = lastCandle.Close,
                                                                  Quantity = 0,
                                                                  Symbol = pair.Item2
                                                              });
                    }
                }
                // Calculate trades
                IList<OHLC> recentCandles = CandlesProvider.CalculateOHLCFromTrades(list, candlesDurationInMin, TradeSource.Bitstamp);


                foreach (OHLC newCandle in recentCandles)
                {
                    var existingCandle = existingCandles.FirstOrDefault(e => e.Date == newCandle.Date);
                    if (existingCandle != null)
                    {
                        existingCandle.High = newCandle.High > existingCandle.High ? newCandle.High : existingCandle.High;
                        existingCandle.Low = newCandle.Low < existingCandle.Low ? newCandle.Low : existingCandle.Low;
                        existingCandle.Close = newCandle.Close;
                        existingCandle.TradeSource = TradeSource.Bitstamp;
                        //recentCandles = recentCandles.Skip(1).ToList();
                    }
                    else
                    {
                        existingCandles.Add(newCandle);
                    }
                }

                return recentCandles.Count() > 0;
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                MessageBox.Show(ex.ToString());
            }
            return false;
        }
开发者ID:erdincay,项目名称:CoinTNet,代码行数:80,代码来源:CandlesProvider.cs


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