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


C# System.Linq.ToArray方法代码示例

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


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

示例1: Update_ItemPassed_ShouldReplaceLinks

    public void Update_ItemPassed_ShouldReplaceLinks([Substitute] LinkDatabase linkDb, Db db)
    {
      var datasourceItemId = ID.NewID;

      db.Add(new DbItem("source")
      {
        Children =
        {
          new DbItem("_Local")
          {
            new DbItem("DatasourceItem")
          }
        },
        Fields =
        {
          "testField"
        }
      });
      ;
      db.Add(new DbItem("target")
      {
        Children =
        {
          new DbItem("_Local")
          {
            new DbItem("DatasourceItem")
          }
        },
        Fields =
        {
          "testField"
        }
      });
      ;


      var sourceItem = db.GetItem("/sitecore/content/source");
      var targetItem = db.GetItem("/sitecore/content/target");
      var datasourceItem = db.GetItem("/sitecore/content/source/_Local/DatasourceItem");
      var targetDatasourceItem = db.GetItem("/sitecore/content/target/_Local/DatasourceItem");
      var itemLinks = new[]
      {
        new ItemLink(sourceItem, FieldIDs.LayoutField, datasourceItem, string.Empty)
      };

      linkDb.GetReferences(sourceItem).Returns(itemLinks.ToArray());
      using (new LinkDatabaseSwitcher(linkDb))
      {
        using (new EditContext(targetItem))
        {
          targetItem["__Renderings"] = datasourceItem.ID.ToString();
        }
        var referenceReplacer = new UpdateLocalDatasourceReferencesService(sourceItem, targetItem);

        referenceReplacer.Update();

        var expectedValue = targetDatasourceItem.ID.ToString();
        targetItem["__Renderings"].Should().Be(expectedValue);
      }
    }
开发者ID:alinulms,项目名称:Habitat,代码行数:60,代码来源:UpdateLocalDatasourceReferencesService.cs

示例2: SimulateKeyPress

        /// <summary>
        ///   Simulate that a given key is pressed. (Down and up)
        /// </summary>
        public static void SimulateKeyPress( Key key )
        {
            var virtualKey = (ushort)KeyInterop.VirtualKeyFromKey( key );
            var keyPress = new []
            {
                new User32.Input
                {
                    Type = User32.InputEventType.Keyboard,
                    KeyboardInput = new User32.KeyboardInput
                    {
                        VirtualKey = virtualKey,
                    }
                },
                new User32.Input
                {
                    Type = User32.InputEventType.Keyboard,
                    KeyboardInput = new User32.KeyboardInput
                    {
                        VirtualKey = virtualKey,
                        Flags = User32.KeyboardInputFlags.KeyUp
                    }
                }
            };

            User32.SendInput( (uint)keyPress.Length, keyPress.ToArray(), User32.Input.Size );
        }
开发者ID:snakshax,项目名称:Framework-Class-Library-Extension,代码行数:29,代码来源:KeyHelper.cs

示例3: then_derived_types_add_children_command_are_provided

        public void then_derived_types_add_children_command_are_provided()
        {
            var collectionAddCommandTitles =
                commandContainer.ChildCommands.OfType<DefaultCollectionElementAddCommand>().Select(c => c.Title);

            var expectedCommandTitles =
                new[] { typeof(TestHandlerAnotherDerivedData).Name, typeof(TestHandlerSonOfDerivedData).Name }.Select(
                    s => "Add " + s);

            CollectionAssert.IsSubsetOf(expectedCommandTitles.ToArray(),
                                        collectionAddCommandTitles.ToArray());
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:12,代码来源:when_seeking_collection_add_commands.cs

示例4: Should_Create_Success_Json_And_Append_Messages

        public void Should_Create_Success_Json_And_Append_Messages()
        {
            using (var container = ContextScopeProvider.CreateChildContainer())
            {
                var controller = PrepareController(container);
                var messages = new[] { "Message 1" };
                var json = new WireJson { Success = true, Messages = messages.ToArray() };
                var jsonResult = controller.Json(json);

                Assert.AreEqual(jsonResult.Data, json);
                AssertJson(messages, jsonResult);
            }
        }
开发者ID:remyblok,项目名称:BetterModules,代码行数:13,代码来源:CoreControllerBaseTests.cs

示例5: Scripting_Shape_Text_Set

        public void Scripting_Shape_Text_Set()
        {
            var page1 = this.GetNewPage();
            var stencil = "basic_u.vss";

            short flags = (short)IVisio.VisOpenSaveArgs.visOpenRO | (short)IVisio.VisOpenSaveArgs.visOpenDocked;
            var app = page1.Application;
            var documents = app.Documents;
            var stencil_doc = documents.OpenEx(stencil, flags);

            var masters1 = stencil_doc.Masters;
            var masters = new[] { masters1["Rounded Rectangle"], masters1["Ellipse"] };
            var point0 = new VA.Drawing.Point(1, 2);
            var point1 = new VA.Drawing.Point(3, 4);
            var points = new[] { point0, point1 };
            Assert.AreEqual(0, page1.Shapes.Count);

            var shapeids = page1.DropManyU(masters, points);
            Assert.AreEqual(2, page1.Shapes.Count);
            Assert.AreEqual(2, shapeids.Length);

            var shapes = page1.Shapes.GetShapesFromIDs(shapeids);
            var client = this.GetScriptingClient();
            var names = new[] { "TestName", "TestName2" };
            var texts = names.ToArray();

            client.Text.Set(shapes, texts);
            client.ShapeSheet.SetName(shapes, names);

            for (int i = 0; i < page1.Shapes.Count; i++)
            {
                var shape = shapes[i];
                var name = names[i];
                var text = texts[i];
                Assert.AreEqual(name, shape.Name);
                Assert.AreEqual(text, shape.Text);
            }

            page1.Delete(0);
        }
开发者ID:shekharssorot2002,项目名称:VisioAutomation2.0,代码行数:40,代码来源:ScriptingShapeTextTests.cs

示例6: OutputGameState

        private void OutputGameState(Game game)
        {
            Csl.Header(string.Format("Game state {0}, next to move is {1}", game.States.Count, game.GetActivePlayer().Name));

            Csl.StartTable(18, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 10);

            var headers = new[] {"Player"}.Concat(Enumerable.Range(1, 8).Select(x => x.ToString())).Concat(new [] { "Sum" });

            Csl.TableHead(headers.ToArray());

            var white = new[] {game.White.Name}.Concat(game.GetCurrentState().WhiteCells.Select(x => (x is Die) ? ((Die) x).Value.ToString() : "." )).ToList();
            white.Add(game.GetCurrentState().WhiteCells.OfType<Die>().Sum(x => x.Value).ToString());

            Csl.TableRow(white.ToArray());

            var black = new[] { game.Black.Name }.Concat(game.GetCurrentState().BlackCells.Select(x => (x is Die) ? ((Die) x).Value.ToString() : "." )).ToList();
            black.Add(game.GetCurrentState().BlackCells.OfType<Die>().Sum(x => x.Value).ToString());

            Csl.TableRow(black.ToArray());

            Csl.Break(2);
        }
开发者ID:kparkov,项目名称:Formation,代码行数:22,代码来源:GameConsole.cs

示例7: Test

        public void Test()
        {
            var asssembly1src =
                @"
            using System;
            using System.Runtime.CompilerServices;

            public class A
            {
            public void Fine() {}
            unsafe public void NotFine(IntPtr* a) {}
            }

            unsafe public class B
            {
            IntPtr* bad;

            public void Fine() {}
            public void AlsoFine(IntPtr* a) {}

            [MethodImpl(MethodImplOptions.InternalCall)]
            public extern void AlsoFine2();
            }

            public class C
            {
            public void NotFine(B b) {}
            public void Fine() {}
            }

            public class SubB : B
            {
            }

            public class D
            {
            SubB b;
            }
            public class E
            {
            public void NotFine(D d) {}
            }

            ";

            var assembly = CSharpCompiler.CompileTempAssembly(asssembly1src);

            var ad = AssemblyFactory.GetAssembly(assembly);
            var cdf = new CecilDefinitionFinder(ad);
            MethodPrivilegeDetector.CriticalTypes = new[]
                                                        {
                                                            "B",
                                                            "SubB",
                                                            "D",
                                                        }.Select(s => cdf.FindType(s)).Cast<TypeReference>().ToList();
            var results = MethodPrivilegeDetector.MethodsRequiringPrivilegesThemselvesOn(ad).Select(kvp => kvp.Key);

            var expectedresults = new[]
                                  	{
                                  		"System.Void A::NotFine(System.IntPtr*)",
                                  		"System.Void C::NotFine(B)",
                                  		"System.Void E::NotFine(D)",
                                  	}.Select(s => cdf.FindMethod(s));

            CollectionAssert.AreEquivalent(expectedresults.ToArray(),results.ToArray());
        }
开发者ID:tigerhu67,项目名称:monobuildtools,代码行数:66,代码来源:MethodPrivilegeDetectorTest.cs


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