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
@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
{
@felipeslongo
felipeslongo / UITableViewCell+GetTableView.cs
Created March 22, 2019 21:24
Xamarin.IOS extension that gets the parent UITableView from the UITableViewCell
namespace UIKit
{
/// <summary>
/// Xamarin.IOS extension that gets the parent <see cref="UITableView"/> from the <see cref="UITableViewCell"/>
/// </summary>
/// <seealso cref="https://stackoverflow.com/questions/15711645/how-to-get-uitableview-from-uitableviewcell"/>
public static class UITableViewCell_GetTableView
{
/// <summary>
/// Gets the parent <see cref="UITableView"/>
@felipeslongo
felipeslongo / UITableView+SelectCell.cs
Created March 22, 2019 17:01
Xamarin.IOS extension method that performs a click/tap event into a UITableViewCell
namespace UIKit
{
public static class UITableView_SelectCell
{
public static void SelectCell(this UITableView @this, UITableViewCell cell)
{
var index = @this.IndexPathForCell(cell);
@this.SelectRow(index, true, UITableViewScrollPosition.None);
@this.Delegate.RowSelected(@this, index);
}