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.
ContextDictionary.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ContextDictionary.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Dictionary type that is serializable</summary>
7//-----------------------------------------------------------------------
8using System;
10using System.Collections.Specialized;
11
12namespace Csla.Core
13{
18 [Serializable()]
19 public class ContextDictionary : HybridDictionary, IMobileObject
20 {
26 public object GetValueOrNull(string key)
27 {
28 if (this.Contains(key))
29 return this[key];
30 return null;
31 }
32
33 #region IMobileObject Members
34
36 {
37 foreach (string key in this.Keys)
38 {
39 object value = this[key];
40 if (!(value is IMobileObject))
41 info.AddValue(key, value);
42 }
43 }
44
46 {
47 foreach (string key in this.Keys)
48 {
49 object value = this[key];
50 IMobileObject mobile = value as IMobileObject;
51 if (mobile != null)
52 {
53 SerializationInfo si = formatter.SerializeObject(mobile);
54 info.AddChild(key, si.ReferenceId);
55 }
56 }
57 }
58
60 {
61 foreach (string key in info.Values.Keys)
62 {
63 Add(key, info.Values[key].Value);
64 }
65 }
66
68 {
69 foreach (string key in info.Children.Keys)
70 {
71 int referenceId = info.Children[key].ReferenceId;
72 this.Add(key, formatter.GetObject(referenceId));
73 }
74 }
75
76#endregion
77 }
78}
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
object GetValueOrNull(string key)
Get a value from the dictionary, or return null if the key is not found in the dictionary.
Serializes and deserializes objects at the field level.
IMobileObject GetObject(int referenceId)
Gets a deserialized object based on the object's reference id within the serialization stream.
SerializationInfo SerializeObject(object obj)
Serializes an object into a SerializationInfo object.
Object containing the serialization data for a specific object.
Dictionary< string, FieldData > Values
Dictionary containg field data.
int ReferenceId
Reference number for this object.
Dictionary< string, ChildData > Children
Dictionary containing child reference data.
void AddChild(string name, int referenceId)
Adds a child to the list of child references.
void AddValue(string name, object value)
Adds a value to the serialization stream.
Interface to be implemented by any object that supports serialization by the SerializationFormatterFa...
void GetChildren(SerializationInfo info, MobileFormatter formatter)
Method called by MobileFormatter when an object should serialize its child references.
void GetState(SerializationInfo info)
Method called by MobileFormatter when an object should serialize its data.
void SetChildren(SerializationInfo info, MobileFormatter formatter)
Method called by MobileFormatter when an object should deserialize its child references.
void SetState(SerializationInfo info)
Method called by MobileFormatter when an object should be deserialized.
@ Serializable
Prevents updating or inserting until the transaction is complete.