项目作者: thzinc

项目描述 :
Destructuring extension methods for awesome C#
高级语言: C#
项目地址: git://github.com/thzinc/DestructureExtensions.git
创建时间: 2017-09-28T16:21:00Z
项目社区:https://github.com/thzinc/DestructureExtensions

开源协议:MIT License

下载


DestructureExtensions

Destructuring extension methods for awesome C#

Quickstart

In C# 7.0:

  1. using DestructureExtensions;
  2. /*...*/
  3. var stringToSplit = "foo,bar,bam,baz";
  4. var (first, _, third, rest) = stringToSplit.Split(',');
  5. // first == "foo"
  6. // third == "bam"
  7. // rest == IEnumerable<string> containing "baz"
  8. var one = Task.FromResult(1);
  9. var two = Task.FromResult("foo");
  10. var three = Task.FromResult(DateTimeOffset.Now);
  11. var (first, second, third) = await (one, two, three).WhenAll();
  12. var tasks = Enumerable.Range(1, 10).Select(Task.FromResult);
  13. var results = await tasks.WhenAll();
  14. var dictionary = new Dictionary<string, int>()
  15. {
  16. { "one", 1 },
  17. { "two", 2 },
  18. { "three", 3 },
  19. }
  20. foreach (var (key, value) in dictionary)
  21. {
  22. // ...
  23. }

More examples in the unit tests.

Building

Travis
NuGet

Ensure you have installed .NET Core

To build a local/development NuGet package, run the following:

  1. dotnet restore
  2. dotnet build
  3. dotnet pack

This will produce bin/Debug/DestructureExtensions.0.0.0.nupkg.

Code of Conduct

We are committed to fostering an open and welcoming environment. Please read our code of conduct before participating in or contributing to this project.

Contributing

We welcome contributions and collaboration on this project. Please read our contributor’s guide to understand how best to work with us.

License and Authors

Daniel James logo Daniel James

license
GitHub contributors

This software is made available by Daniel James under the MIT license.