Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to execute explicit conversions #34

Closed
MrDave1999 opened this issue Nov 5, 2023 · 0 comments · Fixed by #35
Closed

Add methods to execute explicit conversions #34

MrDave1999 opened this issue Nov 5, 2023 · 0 comments · Fixed by #35
Labels
feature New feature or request

Comments

@MrDave1999
Copy link
Owner

MrDave1999 commented Nov 5, 2023

Methods to be added in the Result class to perform the conversion from Result to:

public Result<T> ToResult<T>(T data);
public ListedResult<T> ToListedResult<T>(IEnumerable<T> data);
public PagedResult<T> ToPagedResult<T>(IEnumerable<T> data, PagedInfo pagedInfo);

These methods can go in a file named Result.Conversions.cs.
Note: Implicit operators can call these methods.

Usage

var person = new Person { Name = "Bob" };
Result invalidResult = Result.Invalid();
Result<Person> result = invalidResult.ToResult(person);

PD: These methods have been added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant