Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += delegate
            {
                var watch = System.Diagnostics.Stopwatch.StartNew();

#if Parcelable
                EmployeeParcelable myEmployeeParcelable           = new EmployeeParcelable(JobPosition.Operator, "Alan Lopez", "*****@*****.**");
                Intent             secondActivityIntentParcelable = new Intent(this, typeof(SecondActivity));
                secondActivityIntentParcelable.PutExtra("employee", myEmployeeParcelable);
                StartActivity(secondActivityIntentParcelable);
#endif

#if Serializable
                EmployeeSerializable myEmployeeSerializable = new EmployeeSerializable(JobPosition.Operator, "Alan Lopez", "*****@*****.**");
                Intent secondActivityIntentSerializable     = new Intent(this, typeof(SecondActivity));
                secondActivityIntentSerializable.PutExtra("employee", myEmployeeSerializable);
                StartActivity(secondActivityIntentSerializable);
#endif

#if Json
                EmployeeJson myEmployeeJson           = new EmployeeJson(JobPosition.Operator, "Alan Lopez", "*****@*****.**");
                Intent       secondActivityIntentJson = new Intent(this, typeof(SecondActivity));
                secondActivityIntentJson.PutExtra("employee", Newtonsoft.Json.JsonConvert.SerializeObject(myEmployeeJson));
                StartActivity(secondActivityIntentJson);
#endif



                watch.Stop();
                var elapsedMs = watch.ElapsedMilliseconds;
                Console.WriteLine("Time in PutExtra");
                Console.WriteLine($"{elapsedMs} ms");
            };
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var watch = System.Diagnostics.Stopwatch.StartNew();


#if Parcelable
            EmployeeParcelable myEmployeeParcelable = (EmployeeParcelable)Intent.GetParcelableExtra("employee");
#endif

#if Serializable
            EmployeeSerializable myEmployeeSerializable = (EmployeeSerializable)Intent.GetSerializableExtra("employee");
#endif

#if Json
            EmployeeJson myEmployeeJson = Newtonsoft.Json.JsonConvert.DeserializeObject <EmployeeJson>(Intent.GetStringExtra("employee"));
#endif

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            Console.WriteLine("Time in GetExtra");
            Console.WriteLine($"{elapsedMs} ms");
        }