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


C# Collection.Last方法代码示例

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


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

示例1: GetLast

 static Instruction GetLast(Collection<Instruction> instructions)
 {
     var tail = instructions.LastOrDefault(x => x.OpCode == OpCodes.Tail);
     if (tail != null)
     {
         return tail;
     }
     var last = instructions.Last();
     if (last.OpCode == OpCodes.Ret)
     {
         return last;
     }
     last = Instruction.Create(OpCodes.Ret);
     instructions.Add(last);
     return last;
 }
开发者ID:chantsunman,项目名称:PropertyChanged,代码行数:16,代码来源:ReturnFixer.cs

示例2: AddCatchBlock

        private void AddCatchBlock(Instruction tryStartInstr, Instruction tryEndInstr)
        {
            var methodCode = method.Body.Instructions;

            methodCode.Insert (methodCode.LastIndexOf (tryEndInstr), Instruction.Create (OpCodes.Leave, tryEndInstr)); // needed to jump correctly to catch section

            // catch (Exception ex)
            // {
            //    methodExecInfo.Exception = ex;
            //    BaseAspectAttribute.OnException (methodExecInfo);
            //    throw;
            // }
            var exceptionVar = new VariableDefinition (method.Module.Import (typeof (Exception)));
            method.Body.Variables.Add (exceptionVar);
            var catchCode = new Collection<Instruction>();
            catchCode.Add (OpCodes.Stloc, exceptionVar);
            catchCode.Add (OpCodes.Ldloc, methodExecInfoVar);
            catchCode.Add (OpCodes.Ldloc, exceptionVar);
            catchCode.Add (OpCodes.Callvirt, method.Module.Import (typeof (MethodExecInfo).GetProperty ("Exception").SetMethod));
            catchCode.Add (BuildOnExceptionCall());
            var rethrowInstr = Instruction.Create (OpCodes.Rethrow);
            catchCode.Add (BuildCheckExecFlow (rethrowInstr));
            catchCode.Add (rethrowInstr);

            methodCode.Insert (methodCode.LastIndexOf (tryEndInstr), catchCode);

            method.Body.ExceptionHandlers.Add (new ExceptionHandler (ExceptionHandlerType.Catch)
            {
                CatchType = method.Module.Import (typeof (Exception)),
                TryStart = tryStartInstr,
                TryEnd = catchCode.First(),
                HandlerStart = catchCode.First(),
                HandlerEnd = catchCode.Last().Next
            });
        }
开发者ID:mshmelev,项目名称:Shaspect,代码行数:35,代码来源:MethodAspectInjector.cs

示例3: InsertRangeShouldAddExpectedSubsetOfItems

        public void InsertRangeShouldAddExpectedSubsetOfItems()
        {
            // arrange
            var item = new object();
            var expected = new[] { item, new object(), new object() };
            var target = new Collection<object>() { new object(), new object(), new object() };

            // act
            target.InsertRange( expected, 3, 1 );

            // assert
            Assert.Equal( 4, target.Count );
            Assert.Equal( item, target.Last() );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:14,代码来源:IListExtensionsTest.cs

示例4: AddFinallyBlock

        private void AddFinallyBlock(Instruction tryStartInstr, Instruction tryEndInstr)
        {
            var methodCode = method.Body.Instructions;

            methodCode.Insert (methodCode.LastIndexOf (tryEndInstr), Instruction.Create (OpCodes.Leave, tryEndInstr)); // needed to jump correctly to finally section

            var finallyCode = new Collection<Instruction>();
            finallyCode.Add (BuildOnExitCall());
            finallyCode.Add (OpCodes.Endfinally);
            methodCode.Insert (methodCode.LastIndexOf (tryEndInstr), finallyCode);

            method.Body.ExceptionHandlers.Add (new ExceptionHandler (ExceptionHandlerType.Finally)
            {
                TryStart = tryStartInstr,
                TryEnd = finallyCode.First(),
                HandlerStart = finallyCode.First(),
                HandlerEnd = finallyCode.Last().Next
            });
        }
开发者ID:mshmelev,项目名称:Shaspect,代码行数:19,代码来源:MethodAspectInjector.cs

示例5: OpenClick

        private void OpenClick(object sender, RoutedEventArgs e)
        {
            if (IsSaved ? true : (MessageBox.Show("Current font is not saved. Continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes))
            {
                FontOpenWindow fow = new FontOpenWindow();
                fow.Owner = this;

                if (fow.ShowDialog() == true)
                {
                    if (fow.Type == 0)
                    {
                        CreateSymbolTable();

                        Stream stream = File.Open(fow.Path, FileMode.Open);
                        BinaryFormatter bformatter = new BinaryFormatter();
                        Collection<SymbolStorage> tmp = (Collection<SymbolStorage>)bformatter.Deserialize(stream);
                        stream.Close();

                        SymbolTable.Children.Clear();
                        SymbolButtons = new Collection<SymbolTableButton>();

                        for (int i = 0; i < tmp.Count; ++i)
                        {
                            SymbolButtons.Add(new SymbolTableButton(tmp[i]));
                            SymbolButtons.Last().Click += new RoutedEventHandler(SymbolClicked);
                            SymbolButtons.Last().Title = "0x" + (i / 16).ToString("X") + (i % 16).ToString("X");
                            Grid.SetColumn(SymbolButtons.Last(), (i % 16) * 2);
                            Grid.SetRow(SymbolButtons.Last(), (i / 16) * 2);
                            SymbolTable.Children.Add(SymbolButtons.Last());
                        }
                    }

                    SaveFile = fow.Path;
                    IsSaved = true;
                }
            }
        }
开发者ID:ochykysh,项目名称:ekselcom-pixel,代码行数:37,代码来源:MainWindow.xaml.cs


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