Skip to content

Instantly share code, notes, and snippets.

View MarcBruins's full-sized avatar
🏠
Working from home

Marc Bruins MarcBruins

🏠
Working from home
View GitHub Profile
@MarcBruins
MarcBruins / returnullfornull.cs
Created December 16, 2018 12:21
Returning null for null Uri
public static Uri EnsureTrailingSlash(Uri uri)
{
if (uri == null)
return null;
return new Uri(uri.ToString() + "/");
}
@MarcBruins
MarcBruins / fixreturningnull.cs
Created December 16, 2018 12:17
Fixing returning null
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2)
{
if (HasElements(list1))
return list1;
if (HasElements(list2))
return list2;
return new List<string>();
}
@MarcBruins
MarcBruins / returnnull.cs
Last active December 16, 2018 12:16
Returning null
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2)
{
if (HasElements(list1))
return list1;
if (HasElements(list2))
return list2;
return null;
}
@MarcBruins
MarcBruins / Pullrequestinitliazeproperty.cs
Created December 16, 2018 12:02
PullRequest initialize property explicitly
public class PullRequestRequest
{
public PullRequestRequest(string body)
{
Body = body;
}
public string Body { get; set; }
}
@MarcBruins
MarcBruins / pullrequestnullable.cs
Created December 16, 2018 11:59
PullRequest with nullable property
public string Body? { get; set; }
@MarcBruins
MarcBruins / pullrequestreqeust.cs
Created December 16, 2018 11:51
PullRequest not nullable property
public class PullRequestRequest
{
public PullRequestRequest()
{
}
public string Body { get; set; }
}
@MarcBruins
MarcBruins / fixnullablecontstructorparams.cs
Created December 16, 2018 11:45
Fix nullable constructor params
public class AuthSettings
{
public AuthSettings(Uri apiBase, string token, string? username)
{
Username = username;
//Handle other params
}
public string? Username { get; }
}
@MarcBruins
MarcBruins / nullablecontructorparam.cs
Last active December 16, 2018 11:38
Nullable contructor parameter
public class AuthSettings
{
public AuthSettings(Uri apiBase, string token, string username = null)
{
ApiBase = apiBase;
Token = token;
Username = username;
}
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@MarcBruins
MarcBruins / MyViewSource.cs
Created October 14, 2017 11:13
MyViewSource.cs
public class MyViewSource : MBAutoCompleteViewSource
{
private ICollection<string> _suggestions;
private string _cellIdentifier = "CellId";
public override void NewSuggestions(ICollection<string> suggestions)
{
_suggestions = suggestions;
}