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


C# List.Concat方法代码示例

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


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

示例1: BasicExamples

        public void BasicExamples()
        {
            var schtick = new Schtick();
            Exception taskEx = null;
            schtick.OnTaskException += (task, exception) => taskEx = exception;

            var allRecords = new List<RunRecord>();
            var all = schtick.AddTask("all", "sec(*)", (task, run) => { allRecords.Add(new RunRecord(DateTimeOffset.UtcNow, run)); });

            var evenRecords = new List<RunRecord>();
            var even = schtick.AddTask("even", "sec(*%2)", (task, run) => { evenRecords.Add(new RunRecord(DateTimeOffset.UtcNow, run)); });

            // give them a chance to run
            Thread.Sleep(4000);

            // look at the results
            all.StopSchedule();
            even.StopSchedule();

            Assert.IsNull(taskEx);

            Assert.GreaterOrEqual(allRecords.Count, 3);
            Assert.LessOrEqual(allRecords.Count, 5);
            Assert.GreaterOrEqual(evenRecords.Count, 1);
            Assert.LessOrEqual(evenRecords.Count, 3);

            // make sure all of the events are within 100 milliseconds of the intended time
            foreach (var r in allRecords.Concat(evenRecords))
            {
                Assert.LessOrEqual(r.MillisecondsDifference, 100);
            }
        }
开发者ID:schyntax,项目名称:cs-schtick,代码行数:32,代码来源:SchtickTests.cs

示例2: AddMany_CollectionIsNotEmptyItemsToAddIsNotEmpty_AddsItemsToAdd

 public void AddMany_CollectionIsNotEmptyItemsToAddIsNotEmpty_AddsItemsToAdd()
 {
     var originalCollectionContent = new List<object> { new object() };
     var collection = new List<object>(originalCollectionContent);
     var itemsToAdd = new[] { new object() };
     collection.AddMany(itemsToAdd);
     CollectionAssert.AreEqual(originalCollectionContent.Concat(itemsToAdd), collection);
 }
开发者ID:hudo,项目名称:SwissKnife,代码行数:8,代码来源:CollectionExtensionsTests.cs

示例3: ConcatQueryReuse

        public void ConcatQueryReuse()
        {
            List<int> first = new List<int> { 1, 2 };
            List<int> second = new List<int> { 4, 5 };
            IEnumerable<int> enumerable = first.Concat(second);

            enumerable.AssertEqual(1, 2, 4, 5);

            first.Add(3);
            second.Add(6);
            enumerable.AssertEqual(1, 2, 3, 4, 5, 6);
        }
开发者ID:barisertekin,项目名称:LINQlone,代码行数:12,代码来源:ConcatTests.cs

示例4: recover_from_dropped_subscription_state_using_last_known_position

        public void recover_from_dropped_subscription_state_using_last_known_position()
        {
            const string stream = "read_all_events_forward_should_recover_from_dropped_subscription_state_using_last_known_position";
            using (var store = EventStoreConnection.Create())
            {
                store.Connect(Node.TcpEndPoint);
                var catched = new List<RecordedEvent>();
                Position lastKnonwPosition = null;
                var dropped = new AutoResetEvent(false);

                var create = store.CreateStreamAsync(stream, false, new byte[0]);
                Assert.DoesNotThrow(create.Wait);

                store.SubscribeAsync(stream,
                                     (@event, position) =>
                                     {
                                         catched.Add(@event);
                                         lastKnonwPosition = position;
                                     },
                                     () => dropped.Set());

                var testEvents = Enumerable.Range(1, 5).Select(x => new TestEvent(x.ToString())).ToArray();

                var write = store.AppendToStreamAsync(stream, ExpectedVersion.EmptyStream, testEvents);
                Assert.That(write.Wait(Timeout));

                store.UnsubscribeAsync(stream);
                Assert.That(dropped.WaitOne(Timeout));

                var write2 = store.AppendToStreamAsync(stream, testEvents.Length, testEvents);
                Assert.That(write2.Wait(Timeout));

                var missed = store.ReadAllEventsForwardAsync(lastKnonwPosition, int.MaxValue);
                Assert.That(missed.Wait(Timeout));

                var expected = testEvents.Concat(testEvents).ToArray();
                var actual = catched.Concat(missed.Result.Events.Skip(1)).ToArray();//skip 1 because readallforward is inclusive
                Assert.That(TestEventsComparer.Equal(expected, actual));
            }
        }
开发者ID:robashton,项目名称:EventStore,代码行数:40,代码来源:read_all_events_forward_should.cs

示例5: should_flush_collection_with_multiple_writers

        public void should_flush_collection_with_multiple_writers()
        {
            var collection = new FlushableBlockingCollection<int>();

            var consumedItems = new List<int>();
            var consume = Task.Run(() =>
            {
                var index = 0;
                foreach (var item in collection.GetConsumingEnumerable())
                {
                    consumedItems.Add(item);

                    // simulate consumption lag
                    if (index % 10000 == 0)
                        Thread.Sleep(20);

                    ++index;
                }

                Console.WriteLine("Consumer done");
            });

            const int writerItemCount = 300000;

            var t1 = Task.Run(() =>
            {
                foreach (var item in Enumerable.Range(0, writerItemCount).Select(x => 3 * x))
                {
                    collection.Add(item);
                    if ((item - 0) % 1000 == 0)
                        Thread.Sleep(10);
                    else
                        Thread.Yield();
                }
                Console.WriteLine("T1 done");
            });
            var t2 = Task.Run(() =>
            {
                foreach (var item in Enumerable.Range(0, writerItemCount).Select(x => 3 * x + 1))
                {
                    collection.Add(item);
                    if ((item  - 1) % 1000 == 0)
                        Thread.Sleep(10);
                    else
                        Thread.Yield();
                }
                Console.WriteLine("T2 done");
            });
            var t3 = Task.Run(() =>
            {
                foreach (var item in Enumerable.Range(0, writerItemCount).Select(x => 3 * x + 2))
                {
                    collection.Add(item);
                    if ((item - 2) % 1000 == 0)
                        Thread.Sleep(10);
                    else
                        Thread.Yield();
                }
                Console.WriteLine("T3 done");
            });

            Thread.Sleep(50);

            Console.WriteLine("Flush #1");
            var flushedItems1 = collection.Flush(true);
            Console.WriteLine("{0} flushed items", flushedItems1.Count);

            Thread.Sleep(50);

            Console.WriteLine("Flush #2");
            var flushedItems2 = collection.Flush(true);
            Console.WriteLine("{0} flushed items", flushedItems2.Count);

            Task.WaitAll(t1, t2, t3);

            collection.CompleteAdding();
            consume.Wait();

            var exectedItems = Enumerable.Range(0, writerItemCount * 3).ToHashSet();
            var items = consumedItems.Concat(flushedItems1).Concat(flushedItems2).ToList();
            items.Count.ShouldEqual(exectedItems.Count);
            foreach (var item in items)
            {
                exectedItems.Contains(item).ShouldBeTrue();
            }
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:86,代码来源:FlushableBlockingCollectionTests.cs

示例6: should_flush_collection_with_single_writer

        public void should_flush_collection_with_single_writer()
        {
            var collection = new FlushableBlockingCollection<int>();

            var consumedItems = new List<int>();
            var consume = Task.Run(() =>
            {
                foreach (var item in collection.GetConsumingEnumerable())
                {
                    consumedItems.Add(item);

                    // simulate very slow consumer
                    Thread.Sleep(10);
                }

                Console.WriteLine("Consumer done");
            });

            const int batchSize = 500000;

            foreach (var item in Enumerable.Range(0 * batchSize, batchSize))
            {
                collection.Add(item);
            }

            Thread.Sleep(100);
            Console.WriteLine("Flush #1");
            var flushedItems1 = collection.Flush(true);
            Console.WriteLine("{0} flushed items", flushedItems1.Count);

            foreach (var item in Enumerable.Range(1 * batchSize, batchSize))
            {
                collection.Add(item);
            }

            Thread.Sleep(100);
            Console.WriteLine("Flush #2");
            var flushedItems2 = collection.Flush(true);
            Console.WriteLine("{0} flushed items", flushedItems2.Count);

            foreach (var item in Enumerable.Range(2 * batchSize, batchSize))
            {
                collection.Add(item);
            }

            Thread.Sleep(100);
            Console.WriteLine("Flush #3");
            var flushedItems3 = collection.Flush(true);
            Console.WriteLine("{0} flushed items", flushedItems3.Count);

            collection.CompleteAdding();
            consume.Wait();

            var exectedItems = Enumerable.Range(0, 1500000).ToHashSet();
            var items = consumedItems.Concat(flushedItems1).Concat(flushedItems2).Concat(flushedItems3).ToList();
            items.Count.ShouldEqual(exectedItems.Count);
            foreach (var item in items)
            {
                exectedItems.Contains(item).ShouldBeTrue();
            }
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:61,代码来源:FlushableBlockingCollectionTests.cs

示例7: ShouldTruncateResponseAtEpochBoundary

        public void ShouldTruncateResponseAtEpochBoundary()
        {
            var c = new Controller();

            var e = new Epoch(UNUSED_PROTOCOL);
            var dev1 = new UnitConvertingExternalDevice("dev2", "co", c, new Measurement(0, "V"));

            var sampleRate = new Measurement(1, "Hz");

            var samples = new List<IMeasurement> { new Measurement(1, "V"), new Measurement(2, "V"), new Measurement(3, "V") };

            var data = new OutputData(samples,
                                      sampleRate, true);

            e.Stimuli[dev1] = new RenderedStimulus((string) "ID1",
                                                   (IDictionary<string, object>) new Dictionary<string, object>(),
                                                   (IOutputData) data);
            e.Responses[dev1] = new Response();

            c.EnqueueEpoch(e);
            c.NextEpoch();
            c.PushInputData(dev1, new InputData(samples.Concat(samples).ToList(),
                sampleRate,
                DateTimeOffset.Now)
                .DataWithStreamConfiguration(streamFake, new Dictionary<string, object>())
                .DataWithExternalDeviceConfiguration(devFake, new Dictionary<string, object>()));

            Assert.That(((TimeSpan)e.Responses[dev1].Duration), Is.EqualTo((TimeSpan)e.Duration));
        }
开发者ID:physion,项目名称:symphony-core,代码行数:29,代码来源:ControllerTests.cs

示例8: SetUp

        public void SetUp()
        {
            IPRangeRepositoryMock = new Mock<IRepository<IPRange>>();
            ProfileRepositoryMock = new Mock<IRepository<AwsProfile>>();
            ClientFactoryMock = new Mock<IAwsClientFactory>();
            Command = new RefreshIpRanges(ProfileRepositoryMock.Object, IPRangeRepositoryMock.Object, ClientFactoryMock.Object);

            _profileId = Guid.NewGuid();
            var profile = new AwsProfile
            {
                Id = _profileId
            };
            ProfileRepositoryMock.Setup(x => x.Find(_profileId)).Returns(profile);

            AwsClientMock = new Mock<IAwsClient>();
            NetworkServiceMock = new Mock<INetworkService>();

            AwsClientMock.Setup(x => x.NetworkService).Returns(NetworkServiceMock.Object);
            ClientFactoryMock.Setup(x => x.GetClient(profile)).Returns(AwsClientMock.Object);

            _ipsInRange = Enumerable.Range(8, 4)
                                    .Select(x => string.Format("255.255.255.{0}", x)).ToList();
            var allocatedIps = _ipsInRange.Concat(new List<string> { "192.168.1.1" });
            NetworkServiceMock.Setup(x => x.GetAllocatedIpAddresses()).Returns(allocatedIps);
        }
开发者ID:nelsonwellswku,项目名称:stack-it-net,代码行数:25,代码来源:RefreshIpRangesTests.cs

示例9: GetFourth

 private static void GetFourth(List<int> elements, List<List<int>> combinations, List<int> current, int ctr)
 {
     var n = elements.Count;
     var j = current[current.Count - 1];
     for (int k = j + 1; k < n; k++)
     {
         var c = current.Concat(new List<int> { k }).ToList();
         GetFifth(elements, combinations, c, ctr);
     }
 }
开发者ID:bgriswold,项目名称:CodeClub-Combinations,代码行数:10,代码来源:CombinationSpikes.cs

示例10: GetRect

        public IList<Point> GetRect(int[,] input)
        {
            //			var leftEdgeOnes = new List<Point>();
            //			var rightEdgeOnes = new List<Point>();
            //			var topEdgeOnes = new List<Point>();
            //			var bottomEdgeOnes = new List<Point>();
            //			var maxI = input.GetLength(0);
            //			var maxJ = input.GetLength(1);
            //			for (int i = 0; i < maxI; i++)
            //			{
            //				for (int j = 0; j < maxJ; j++)
            //				{
            //					if (input[i, j] == 1)
            //					{
            //						if (i == 0 || input[i - 1, j] == 0)
            //						{
            //							leftEdgeOnes.Add(new Point(i, j));
            //						}
            //						if (i == maxI - 1 || input[i + 1, j] == 0)
            //						{
            //							rightEdgeOnes.Add(new Point(i,j));
            //						}
            //						if (j == 0 || input[i,j - 1] == 0)
            //						{
            //							topEdgeOnes.Add(new Point(i,j));
            //						}
            //						if (j == maxJ -1 || input[i,j + 1] == 0)
            //						{
            //							bottomEdgeOnes.Add(new Point(i,j));
            //						}
            //					}
            //				}
            //			}
            //
            //			var allOnes = topEdgeOnes.Concat(bottomEdgeOnes).Concat(leftEdgeOnes).Concat(rightEdgeOnes).Distinct().ToList();

            var across = new List<List<Point>>{new List<Point>()};
            for (int i = 0; i < input.GetLength(0); i++)
            {
                for (int j = 0; j < input.GetLength(1); j++)
                {
                    if (input[i, j] == 1)
                    {
                        var list = across.Last();
                        list.Add(new Point(i, j));
                    }
                    else
                    {
                        across.Add(new List<Point>());
                    }
                }
                across.Add(new List<Point>());
            }

            var down = new List<List<Point>> { new List<Point>() };
            for (int j = 0; j < input.GetLength(1); j++)
            {
                for (int i = 0; i < input.GetLength(0); i++)
                {
                    if (input[i, j] == 1)
                    {
                        var list = down.Last();
                        list.Add(new Point(i, j));
                    }
                    else
                    {
                        down.Add(new List<Point>());
                    }
                }
                down.Add(new List<Point>());
            }

            var longest = down.Concat(across).OrderByDescending(x => x.Count).First();
            if (longest.Count == 1)
            {

                longest.Add(longest[0]);
            }
            if (longest.Count > 2)
            {
                longest = new List<Point> { longest.First(), longest.Last() };
            }
            return longest;
        }
开发者ID:BarakUgav61,项目名称:Scratch,代码行数:84,代码来源:Demo.cs

示例11: Concat_Linq

		public void Concat_Linq ()
		{
			// Concat all elements
			var groupOne = new List<int> (){ 1,2,3,4,5};
			var groupTwo = new List<int> (){4,5,6,7};
			
			var groupBoth = groupOne.Concat(groupTwo);
			var groupBothOrdered = from g in groupBoth
								   orderby g
								   select g;		
		
			Assert.AreEqual (9, groupBothOrdered.Count ());
			Assert.AreEqual (1, groupBothOrdered.First ());
			Assert.AreEqual (7, groupBothOrdered.Last ());
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:15,代码来源:Set.cs

示例12: Concat_LinqExt

		public void Concat_LinqExt ()
		{
			// Concat all elements
			var groupOne = new List<int> (){ 1,2,3,4,5};
			var groupTwo = new List<int> (){4,5,6,7};
			var groupExcept = groupOne.Concat (groupTwo).OrderBy( x=> x);
		
			Assert.AreEqual (9, groupExcept.Count ());
			Assert.AreEqual (1, groupExcept.First ());
			Assert.AreEqual (7, groupExcept.Last ());
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:11,代码来源:Set.cs

示例13: CacheLookup_MultipleUrisOneInCache_ReturnsVersion

        public void CacheLookup_MultipleUrisOneInCache_ReturnsVersion()
        {
            // Arrange

            var servers1 = new List<Uri>
            {
                Uri1
            };

            var servers2 = new List<Uri>
            {
                Uri2
            };

            var provider = new DefaultVersionProvider();

            provider.CacheStore(servers2, Version45);

            // Act

            var result = provider.CacheLookup(servers1.Concat(servers2));

            // Assert

            Assert.AreEqual(Version45, result);
        }
开发者ID:RossMerr,项目名称:CouchbaseNetLinq,代码行数:26,代码来源:DefaultVersionProviderTests.cs

示例14: recover_from_dropped_subscription_state_using_last_known_position

        public void recover_from_dropped_subscription_state_using_last_known_position()
        {
            Assert.Inconclusive("This tests has race condition in subscribe/first write sequence. And it is not clear what it tests...");

            const string stream = "read_all_events_forward_should_recover_from_dropped_subscription_state_using_last_known_position";
            using (var store = EventStoreConnection.Create())
            {
                store.Connect(_node.TcpEndPoint);
                store.CreateStream(stream, Guid.NewGuid(), false, new byte[0]);
                
                var catched = new List<RecordedEvent>();
                Position? lastKnownPosition = null;
                var dropped = new AutoResetEvent(false);

                var subscribed = new ManualResetEventSlim();
                bool wasSubscribed = false;
                using (var subscription = store.SubscribeToStream(stream,
                                                                  false,
                                                                  @event =>
                                                                  {
                                                                      catched.Add(@event.Event);
                                                                      lastKnownPosition = @event.OriginalPosition;
                                                                      wasSubscribed = true;
                                                                      subscribed.Set();
                                                                  },
                                                                  () =>
                                                                  {
                                                                      wasSubscribed = false;
                                                                      subscribed.Set();
                                                                      dropped.Set();
                                                                  }).Result)
                {
                    var testEvents = Enumerable.Range(1, 5).Select(x => TestEvent.NewTestEvent(x.ToString())).ToArray();
                    var write = store.AppendToStreamAsync(stream, ExpectedVersion.EmptyStream, testEvents);
                    Assert.That(write.Wait(Timeout));

                    Assert.IsTrue(subscribed.Wait(5000), "Subscription haven't happened in time.");
                    Assert.IsTrue(wasSubscribed, "Subscription failed.");
                    Assert.IsTrue(lastKnownPosition.HasValue, "Last know position should not be null.");

                    subscription.Unsubscribe();
                    Assert.That(dropped.WaitOne(Timeout), "Couldn't unsubscribe in time.");

                    var write2 = store.AppendToStreamAsync(stream, testEvents.Length, testEvents);
                    Assert.That(write2.Wait(Timeout));

                    var missed = store.ReadAllEventsForwardAsync(lastKnownPosition.Value, int.MaxValue, false);
                    Assert.That(missed.Wait(Timeout));

                    var expected = testEvents.Concat(testEvents).ToArray();
                    var actual = catched.Concat(missed.Result.Events.Skip(1).Select(x => x.Event)).ToArray();//skip 1 because readallforward is inclusive
                    Assert.That(EventDataComparer.Equal(expected, actual));
                }
            }
        }
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:55,代码来源:read_all_events_forward_should.cs

示例15: GenerateOpCodeClasses


//.........这里部分代码省略.........
                            typeof(Int32).GetCSharpRef(ToCSharpOptions.ForCodegen),
                            typeof(Enumerable).GetCSharpRef(ToCSharpOptions.ForCodegen),
                            emptyPrefixes);
                        buffer.AppendLine(", prefixes ?? " + emptyPrefixes + ")");
                        buffer.AppendLine("{".Indent().Indent());
                        buffer.AppendLine("// this is necessary for further verification".Indent().Indent().Indent());
                        buffer.AppendLine("var origPos = reader.BaseStream.Position;".Indent().Indent().Indent());
                        buffer.AppendLine();
                        fields.ForEach(field =>
                        {
                            buffer.AppendLine(("// initializing " + field.Name).Indent().Indent().Indent());
                            buffer.AppendLine(field.Initializer.Indent().Indent().Indent());
                        });
                        buffer.AppendLine("// verify that we've read exactly the amount of bytes we should".Indent().Indent().Indent());
                        buffer.AppendLine("var bytesRead = reader.BaseStream.Position - origPos;".Indent().Indent().Indent());
                        // this validation is partially redundant for switch, tho I'm cba to invent something better now
                        buffer.AppendLine(String.Format("{0}.AssertTrue(bytesRead == SizeOfOperand);",
                            typeof(AssertionHelper).GetCSharpRef(ToCSharpOptions.ForCodegen)).Indent().Indent().Indent());
                        buffer.AppendLine();
                        buffer.AppendLine("// now when the initialization is completed verify that we've got only prefixes we support".Indent().Indent().Indent());
                        buffer.AppendLine(String.Format("{0}.AssertAll(Prefixes, prefix => ".Indent().Indent().Indent(),
                            typeof(AssertionHelper).GetCSharpRef(ToCSharpOptions.ForCodegen)));
                        buffer.AppendLine("{".Indent().Indent().Indent());
                        var cond_vars = new List<String>();
                        foreach (var prefix in prefixes)
                        {
                            var var_name = prefix.PrefixName + "_ok";
                            cond_vars.Add(var_name);
                            buffer.AppendLine(String.Format("var {0} = prefix is {1}{2};".Indent().Indent().Indent().Indent(),
                                var_name, prefix.PrefixName.Capitalize(),
                                prefix.Filter.IsNullOrEmpty() ? "" : " && " + prefix.Filter));
                        }
                        buffer.AppendLine(String.Format("return {0};".Indent().Indent().Indent().Indent(),
                            cond_vars.Concat("false").StringJoin(" || ")));
                        buffer.AppendLine("});".Indent().Indent().Indent());
                        buffer.AppendLine("}".Indent().Indent());
                        buffer.AppendLine();

                        // 3. OpCode inference
                        buffer.AppendLine(String.Format("private static {0} AssertSupportedOpCode({1} reader)",
                            typeof(OpCode).GetCSharpRef(ToCSharpOptions.ForCodegen),
                            typeof(BinaryReader).GetCSharpRef(ToCSharpOptions.ForCodegen)).Indent().Indent());
                        buffer.AppendLine("{".Indent().Indent());

                        buffer.AppendLine(String.Format(
                            "var opcode = {0}.ReadOpCode(reader);",
                            typeof(OpCodeReader).GetCSharpRef(ToCSharpOptions.ForCodegen)).Indent().Indent().Indent());
                        buffer.AppendLine(String.Format(
                            "{0}.AssertNotNull(opcode);",
                            typeof(AssertionHelper).GetCSharpRef(ToCSharpOptions.ForCodegen)).Indent().Indent().Indent());
                        buffer.AppendLine(opCodesComment.Indent().Indent().Indent());
                        buffer.AppendLine(String.Format(
                            "{0}.AssertTrue({1}.Contains(new {2}[]{{{3}}}, ({4})opcode.Value.Value));",
                            typeof(AssertionHelper).GetCSharpRef(ToCSharpOptions.ForCodegen),
                            typeof(Enumerable).GetCSharpRef(ToCSharpOptions.ForCodegen),
                            typeof(UInt16).GetCSharpRef(ToCSharpOptions.ForCodegen),
                            fkb.OpCodes.Select(opcode => opcode.GetCSharpByteSequence()).StringJoin(),
                            typeof(UInt16).GetCSharpRef(ToCSharpOptions.ForCodegen))
                            .Indent().Indent().Indent());

                        buffer.AppendLine();
                        buffer.AppendLine("return opcode.Value;".Indent().Indent().Indent());
                        buffer.AppendLine("}".Indent().Indent());
                        buffer.AppendLine();

                        // 4. SizeOfOperands override (special case for Switch)
开发者ID:xeno-by,项目名称:truesight-lite,代码行数:67,代码来源:Generator.Classes.cs


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