Created
November 1, 2014 15:05
-
-
Save mgroves/6546786885107eb504ed to your computer and use it in GitHub Desktop.
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
using System; | |
using Android.Content; | |
using Newtonsoft.Json; | |
namespace LBMobileX | |
{ | |
public static class IntentExtensions | |
{ | |
/// <summary> | |
/// Serializes an object into the intent | |
/// </summary> | |
/// <param name="name">Name of the extra</param> | |
/// <param name="value">Object that will be serialized</param> | |
/// <typeparam name="T">Type of object being serialized.</typeparam> | |
public static void PutExtra<T>(this Intent @this, string name, T value) { | |
@this.PutExtra (name, JsonConvert.SerializeObject(value)); | |
} | |
public static Type GetExtra<T>(this Intent @this, string name) { | |
return JsonConvert.DeserializeObject<T> (@this.GetStringExtra (name)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment