CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ActivityBase.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ActivityBase.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>CSLA helper to be used in place of the normal Xamarin Android activity that contains a reference to a CSLA ViewModel and a BindingManager</summary>
7//-----------------------------------------------------------------------
8
9using Android.App;
10using Android.OS;
11using Csla.Axml.Binding;
14
15namespace Csla.Axml
16{
22 public abstract class ActivityBase<T, Z> : Activity where T : ViewModel<Z>
23 {
24 private ApplicationContext CslaApplicationContext { get; set; }
25
30 protected ActivityBase(ApplicationContext applicationContext)
31 {
32 CslaApplicationContext = applicationContext ?? throw new System.ArgumentNullException(nameof(applicationContext));
33 }
34
38 protected T viewModel = null;
39
43 protected BindingManager Bindings = null;
44
49 protected override void OnCreate(Bundle bundle)
50 {
51 base.OnCreate(bundle);
52 Bindings = new BindingManager(this);
53 }
54
59 protected byte[] SerializeModelForParameter()
60 {
61 return this.SerializeModelForParameter(this.viewModel.Model);
62 }
63
69 protected byte[] SerializeModelForParameter(object model)
70 {
71 return SerializationFormatterFactory.GetFormatter(CslaApplicationContext).Serialize(model);
72 }
73
79 protected object DeserializeFromParameter(byte[] parameter)
80 {
81 return SerializationFormatterFactory.GetFormatter(CslaApplicationContext).Deserialize(parameter);
82 }
83 }
84}
Provides consistent context information between the client and server DataPortal objects.
CSLA helper to be used in place of the normal Xamarin Android activity that contains a reference to a...
Definition: ActivityBase.cs:23
byte[] SerializeModelForParameter(object model)
Serialized the provided model using the SerializationFormatterFactory.GetFormatter().
Definition: ActivityBase.cs:69
ActivityBase(ApplicationContext applicationContext)
Creates an instance of the type.
Definition: ActivityBase.cs:30
object DeserializeFromParameter(byte[] parameter)
Takes a byte array and uses the MobileFormatter to reconstitute it into a model reference.
Definition: ActivityBase.cs:79
BindingManager Bindings
The BindingManager for this Activity.
Definition: ActivityBase.cs:43
T viewModel
A reference to the view model.
Definition: ActivityBase.cs:38
byte[] SerializeModelForParameter()
Serializes the ViewModel's model property using the SerializationFormatterFactory....
Definition: ActivityBase.cs:59
override void OnCreate(Bundle bundle)
Event that occurs when the activity is created.
Definition: ActivityBase.cs:49
Provides the ability to bing properties on Axml controls to properties on CSLA objects.