Skip to content

Instantly share code, notes, and snippets.

View felipeslongo's full-sized avatar
🌴
Having Fun With Threads

Felipe de Souza Longo felipeslongo

🌴
Having Fun With Threads
View GitHub Profile
using System;
using UIKit;
namespace App.iOS.Extensions
{
public static class UIViewController_AddSearchController
{
public static UISearchController AddSearchController(this UIViewController @this)
{
var searchController = new UISearchController(null as UIViewController);
@felipeslongo
felipeslongo / CancellationTokenSourceRenew
Last active April 24, 2019 16:44
Utility to renew a cancellation token correctly
using System.Threading;
namespace Core.Extensions
{
public static class CancellationTokenSourceRenew
{
public static CancellationTokenSource Renew(this CancellationTokenSource @this)
{
Cancel(@this);
return new CancellationTokenSource();
@felipeslongo
felipeslongo / StringCaseInsensitiveUnaccented.cs
Created April 12, 2019 17:50
Encapsulates a string that is case insensitive and dont care about accents
using Core.Extensions;
namespace Core.ValueTypes
{
public class StringCaseInsensitiveUnaccented
{
public static bool Compare(string a, string b)
=> a.RemoveDiacritics().ToUpper().Equals(b.RemoveDiacritics().ToUpper());
}
}
using System.Globalization;
using System.Linq;
using System.Text;
namespace Core.Extensions
{
public static class String_RemoveDiacritics
{
public static string RemoveDiacritics(this string @this)
=> string.Concat(
@felipeslongo
felipeslongo / AdapterView.ItemClickEventArgs+GetItem.cs
Created April 10, 2019 17:59
Gets the selected/clicked item
using Android.Widget;
using Java.Lang;
namespace App.Droid.Extensions
{
/// <summary>
/// Extension method GetItem for <see cref="AdapterView.ItemClickEventArgs"/>
/// </summary>
/// <seealso cref="https://stackoverflow.com/questions/4819813/how-to-get-text-from-autocomplete-textview-android"/>
public static class AdapterView_ItemClickEventArgs_GetItem
@felipeslongo
felipeslongo / JavaLangObject+Cast.cs
Last active April 10, 2019 17:38
Extension method Cast for <see cref="Java.Lang.Object"/>.
using Java.Lang;
namespace App.Droid.Extensions
{
/// <summary>
/// Extension method Cast for <see cref="Java.Lang.Object"/>.
/// </summary>
/// <seealso cref="https://stackoverflow.com/questions/6594250/type-cast-from-java-lang-object-to-native-clr-type-in-monodroid"/>
public static class JavaLangObject_Cast
{
@felipeslongo
felipeslongo / AutoCompleteTextView+ShowSuggestions.cs
Last active April 11, 2019 16:37
Extension method ShowSuggestions to AutoCompleteTextView
using Android.Widget;
namespace App.Droid.Extensions
{
/// <summary>
/// Extension method ShowSuggestions to AutoCompleteTextView
/// </summary>
/// <seealso cref="https://stackoverflow.com/questions/2126717/android-autocompletetextview-show-suggestions-when-no-text-entered"/>
public static class AutoCompleteTextView_ShowSuggestions
{
@felipeslongo
felipeslongo / UITableViewCell+GetUITableView.cs
Created April 2, 2019 16:05
Get the UITableView from a UITableViewCell
using UIKit;
namespace UIKit
{
public static class UITableViewCell_GetUITableView
{
/// <summary>
/// Get the <see cref="UITableView"/> associated with this cell.
/// </summary>
/// <param name="this"></param>
@felipeslongo
felipeslongo / EmbeddedResource.cs
Created March 28, 2019 20:25
Loads files with Build Action set to EmbeddedResource.
using System.IO;
using System.Reflection;
namespace Core.Utils
{
public static class EmbeddedResource
{
public static string ReadString(Assembly assembly, string @namespace ,string filename)
{
var stream = assembly.GetManifestResourceStream($"{@namespace}.{filename}");
@felipeslongo
felipeslongo / IDictionary+WhereToDictionary.cs
Created March 25, 2019 20:55
Filtering out values from a C# Generic Dictionary
using System.Collections.Generic;
namespace System.Linq
{
/// <summary>
/// Filtering out values from a C# Generic Dictionary
/// </summary>
/// <seealso cref="https://stackoverflow.com/questions/2131648/filtering-out-values-from-a-c-sharp-generic-dictionary"/>
public static class IDictionary_WhereToDictionary
{