This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public partial class Range<T> : IRange<T>, IEquatable<string>, IFormattable | |
| where T : struct, IComparable | |
| { | |
| public Range() | |
| { | |
| } | |
| public Range(string value) | |
| { | |
| var parsed = Parse<T>(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProductFilter : FilterBase | |
| { | |
| [StringFilterOptions(StringFilterOption.Contains)] | |
| public string Name { get; set; } | |
| [StringFilterOptions(StringFilterOption.Contains)] | |
| public string Description { get; set; } | |
| public string Code { get; set; } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProductsController | |
| { | |
| private readonly MyDbContext context | |
| public ProductsController(MyDbContext context) | |
| { | |
| this.context = context; | |
| } | |
| [HttpGet] | |
| public async Task<IActionResult> GetAsync([FromQuery]ProductFilter filter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class QueryExtensions | |
| { | |
| public static IQueryable<T> ApplyFilter<T>(this IQueryable<T> source, IFilter filter) | |
| { | |
| return filter.ApplyFilterTo(source); | |
| } | |
| public static IQueryable<T> ApplyFilter<T>(this IOrderedQueryable<T> source, IFilter filter) | |
| { | |
| return filter.ApplyFilterTo(source); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ProductsController | |
| { | |
| private readonly MyDbContext context | |
| public ProductsController(MyDbContext context) | |
| { | |
| this.context = context; | |
| } | |
| [HttpGet] | |
| public async Task<IActionResult> GetAsync([FromQuery]ProductFilter filter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var message = "Welcome back " + user.Name + ". You're authenticated as " + user.Email; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var message = $"Welcome back {user.Email}. You're authenticated as {user.Email}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var message = string.Format("Welcome back {0}. You're authenticated as {1}", user.Name, user.Email); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The data which comes from db or something else. | |
| var user = new User { Name = "Enis", Email= "enis@domain.com" }; | |
| // The string template which comes from database or anywhere else: | |
| var template = "Welcome back {Name}. You're authenticated as {Email}." | |
| // Output: Welcome back Enis. You're authenticated as enis@domain.com. | |
| var message = template.Bind(user); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var data = new User { Name = "Enis", Email = "enis@domain.com" } | |
| var template = "<h1>Welcome back <strong>{Name}</strong></h1><p>You're authenticated as <a href=\"mailto:{Email}\"></a></p>"; | |
| var message = template.Bind(data); |