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.
Silverlight/Serialization/CustomerContact.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CustomerContact.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Implementation of a test business object using CSLA managed properties backed by</summary>
7//-----------------------------------------------------------------------
8using System;
9using Csla;
10using Csla.Core;
13
15{
21 [Serializable()]
22 public sealed class CustomerContact : BusinessBase<CustomerContact>, IEquatable<CustomerContact>
23 {
24 #region Constructors
25
27 {
28 // Nothing
29 }
30
31 #endregion
32
33 #region System.Object Method Overrides
34
35 public override bool Equals(object obj)
36 {
37 return Equals(obj as CustomerContact);
38 }
39
40 public override int GetHashCode()
41 {
42 int hashCode = 0;
43
44 if (FirstName != null) hashCode ^= FirstName.GetHashCode();
45 if (LastName != null) hashCode ^= LastName.GetHashCode();
46
47 return hashCode;
48 }
49
50 #endregion
51
52 #region IEquatable<CustomerContact> Members
53
54 public bool Equals(CustomerContact other)
55 {
56 if (other != null)
57 {
58 return (StringComparer.OrdinalIgnoreCase.Equals(FirstName, other.FirstName) &&
59 StringComparer.OrdinalIgnoreCase.Equals(LastName, other.LastName));
60 }
61 else
62 {
63 return false;
64 }
65 }
66
67 #endregion
68
69 #region Custom Serialization Methods
70
71 protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
72 {
73 base.OnGetChildren(info, formatter);
74 }
75
76 protected override void OnSetChildren(SerializationInfo info, MobileFormatter formatter)
77 {
78 base.OnSetChildren(info, formatter);
79 }
80
81 protected override void OnGetState(SerializationInfo info, StateMode mode)
82 {
83 info.AddValue("FirstName", FirstName);
84 info.AddValue("LastName", LastName);
85
86 base.OnGetState(info, mode);
87 }
88
89 protected override void OnSetState(SerializationInfo info, StateMode mode)
90 {
91 this.FirstName = info.GetValue<string>("FirstName");
92 this.LastName = info.GetValue<string>("LastName");
93
94 base.OnSetState(info, mode);
95 }
96
97 #endregion
98
99 #region Properties
100
101 private static PropertyInfo<string> Property_FirstName = RegisterProperty<string>(c => c.FirstName, "First Name", "", RelationshipTypes.PrivateField);
102 private string _firstName = Property_FirstName.DefaultValue;
103
107 public string FirstName
108 {
109 get { return GetProperty(Property_FirstName, _firstName); }
110 set { SetProperty(Property_FirstName, ref _firstName, value); }
111 }
112
113 private static PropertyInfo<string> Property_LastName = RegisterProperty<string>(c => c.LastName, "Last Name", "", RelationshipTypes.PrivateField);
114 private string _lastName = Property_LastName.DefaultValue;
115
119 public string LastName
120 {
121 get { return GetProperty(Property_LastName, _lastName); }
122 set { SetProperty(Property_LastName, ref _lastName, value); }
123 }
124
125 #endregion
126 }
127}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
virtual T DefaultValue
Gets the default initial value for the property.
Serializes and deserializes objects at the field level.
Object containing the serialization data for a specific object.
void AddValue(string name, object value)
Adds a value to the serialization stream.
Implementation of a test business object using CSLA managed properties backed by fields,...
override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
override void OnGetState(SerializationInfo info, StateMode mode)
string FirstName
Gets or sets the first name of the contact.
string LastName
Gets or sets the last name of the contact.
override void OnSetState(SerializationInfo info, StateMode mode)
override void OnSetChildren(SerializationInfo info, MobileFormatter formatter)
StateMode
Indicates the reason the MobileFormatter functionality has been invoked.
Definition: StateMode.cs:20
RelationshipTypes
List of valid relationship types between a parent object and another object through a managed propert...
@ Serializable
Prevents updating or inserting until the transaction is complete.