Skip to content

Instantly share code, notes, and snippets.

💭
🧗🏻‍♂️

Matthew Robbins matthewrdev

Block or report user

Report or block matthewrdev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@matthewrdev
matthewrdev / PeerConnectionHelper.cs
Last active Jun 30, 2016
Utility class to detect severed peer connections in Xamarin.Android.
View PeerConnectionHelper.cs
/// <summary>
/// Helper class to detect when .NET objects with a Java peer object have been "severed".
///
/// Peer objects are .NET types which implement IJavaObject , e.g. all Java.Lang.Object and Java.Lang.Throwable subclasses.
/// Instances of these types have two "halfs" a managed peer and a native peer.
/// - The managed peer is an instance of the C# class.
/// - The native peer is an instance of a Java class within the Android runtime VM, and the C# IJavaObject.Handle property contains a JNI global reference to the native peer.
///
/// There are two types of native peers:
///
@matthewrdev
matthewrdev / AndroidEnvironment.txt
Created Nov 17, 2017
Is Mono's logging cluttering up your Android apps logs? Drop this into your project to snuff out those logs!
View AndroidEnvironment.txt
# See: http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/#Configuration
MONO_GC_PARAMS=bridge-implementation=old,nursery-size=32m,soft-heap-limit=512m,evacuation-threshold=80
# See: http://www.mono-project.com/docs/advanced/runtime/logging-runtime-events/#trace-levels
MONO_LOG_LEVEL=info
# See: http://www.mono-project.com/docs/advanced/runtime/logging-runtime-events/#trace-filters
MONO_LOG_MASK=gc
View ILocalise.cs
using System;
using System.Globalization;
namespace MyApp.il8n
{
public interface ILocalize
{
CultureInfo GetCurrentCultureInfo();
void SetLocale();
View TranslateExtension.cs
using System;
using System.Globalization;
using System.Reflection;
using System.Resources;
using Xamarin.Forms.Xaml;
using Xamarin.Forms;
namespace MyApp.il8n
{
// You exclude the 'Extension' suffix when using in Xaml markup
@matthewrdev
matthewrdev / Profiler.cs
Last active Mar 12, 2018
A simple and lean profiler that measures a code section using the IDisposable pattern.
View Profiler.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
namespace MFractor.Utilities
{
public class Profiler : IDisposable
{
readonly string Message;
@matthewrdev
matthewrdev / iOS.Localise.cs
Last active Apr 2, 2018
iOS - Localise.cs
View iOS.Localise.cs
using System;
using System.Globalization;
using System.Threading;
using Foundation;
using MyApp.il8n;
using MyApp.iOS;
using Xamarin.Forms;
[assembly: Dependency(typeof(Localize))]
View Android.Localise.cs
using System;
using System.Globalization;
using System.Linq;
using System.Threading;
using Java.Util;
using MyApp.Droid;
using MyApp.il8n;
using Xamarin.Forms;
[assembly: Dependency(typeof(Localize))]
View DesignTimeBindingContextAttribute.cs
using System;
namespace MyApp.Attributes
{
/// <summary>
/// Apply the design time binding context attribute to your code-behind class to inform tools of your intended runtime binding context.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class DesignTimeBindingContextAttribute : Attribute
{
You can’t perform that action at this time.