Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.Syncable.Watchers.MutableSync< T > Class Template Reference
Inheritance diagram for pluginbase.Objects.Syncable.Watchers.MutableSync< T >:
pluginbase.Objects.Syncable.SyncableBase< T > pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.INetWatcher

Public Member Functions

 MutableSync ()
 

Protected Member Functions

override void TouchRecurse ()
 Touch the instance More...
 
override void ResetWatch ()
 Reset the touched state More...
 
sealed override void EncodeTo (System.IO.BinaryWriter writer, EncodeContext context)
 
sealed override void DecodeFrom (System.IO.BinaryReader reader, DecodeContext context)
 
sealed override void Persist (pluginbase.Objects.Libs.Persist.IPersistObject obj)
 Persist the instance to a persist object More...
 
sealed override void Load (pluginbase.Objects.Libs.Persist.IReadPersistObject obj)
 Load the instance from a persist object More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableBase< T >
void Touch ()
 Touch the instance, notifying something has changed More...
 
virtual void OnChanged ()
 Raises the changed event. More...
 
abstract void EncodeTo (BinaryWriter writer, EncodeContext context)
 Encode changes to binary data More...
 
abstract void DecodeFrom (BinaryReader reader, DecodeContext context)
 Decode changes from binary data More...
 

Properties

Value [get, set]
 
Type Type [get]
 
- Properties inherited from pluginbase.Objects.Syncable.INetSyncable
INetWatcher Watcher [get, set]
 Who is watching (who to inform of a change) More...
 
bool Modified [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.INetSyncable is modified. More...
 

Additional Inherited Members

- Events inherited from pluginbase.Objects.Syncable.SyncableBase< T >
Action< T > Changed
 Event triggered when any change occurs on this object, either locally or over the network More...
 
Action< T > NetUpdate
 Event triggered when a change occurs resulting from a change over the network More...
 
Action< T > Touched
 Event occurs only when an object is first touched. Usually the first instance of a local-change More...
 

Constructor & Destructor Documentation

pluginbase.Objects.Syncable.Watchers.MutableSync< T >.MutableSync ( )
53  {
54  }

Member Function Documentation

sealed override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.DecodeFrom ( System.IO.BinaryReader  reader,
DecodeContext  context 
)
protected
102  {
103  string typeName = reader.ReadString();
104  if (typeName == NULLTYPE)
105  {
106  this.ClearValueInternal();
107  }
108  else
109  {
110  if (_typeName != typeName)
111  {
112  //Must be a new type, let's make it!
113  this.ClearValueInternal();
114  Type type = TypeSerializer.Deserialize(typeName);
115  _typeName = typeName;
116  _value = (T)Activator.CreateInstance(type);
117  _value.Watcher = this;
118  }
119  _value.DecodeFrom(reader, context);
120  }
121  context.Increment();
122  }
sealed override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.EncodeTo ( System.IO.BinaryWriter  writer,
EncodeContext  context 
)
protected
88  {
89  if (_typeName == null)
90  {
91  writer.Write(NULLTYPE);
92  }
93  else
94  {
95  writer.Write(_typeName);
96  _value.EncodeTo(writer, context);
97  }
98  context.Increment();
99  }
sealed override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.Load ( pluginbase.Objects.Libs.Persist.IReadPersistObject  obj)
protectedvirtual

Load the instance from a persist object

Parameters
objObject.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

135  {
136  string typeString = obj.Get<string>("__type");
137  Type type = TypeSerializer.Deserialize(typeString);
138  if (type != null && obj.Has("item"))
139  {
140  _typeName = typeString;
141  _value = (T)Activator.CreateInstance(type);
142  _value.Watcher = this;
143  _value.Load(obj.GetObject("item"));
144  }
145  }
sealed override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.Persist ( pluginbase.Objects.Libs.Persist.IPersistObject  obj)
protectedvirtual

Persist the instance to a persist object

Parameters
objObject.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

125  {
126  obj.Set("__type", _typeName ?? string.Empty);
127  if (_value != null)
128  {
129  var sub = obj.GetOrCreateObject("item");
130  _value.Persist(sub);
131  }
132  }
override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.ResetWatch ( )
protectedvirtual

Reset the touched state

Reimplemented from pluginbase.Objects.Syncable.SyncableBase< T >.

76  {
77  base.ResetWatch();
78  if (_value != null)
79  {
80  _value.ResetWatch();
81  }
82  }
override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.TouchRecurse ( )
protectedvirtual

Touch the instance

Reimplemented from pluginbase.Objects.Syncable.SyncableBase< T >.

67  {
68  base.TouchRecurse();
69  if (_value != null)
70  {
71  _value.TouchRecurse();
72  }
73  }

Property Documentation

Type pluginbase.Objects.Syncable.Watchers.MutableSync< T >.Type
get
T pluginbase.Objects.Syncable.Watchers.MutableSync< T >.Value
getset

The documentation for this class was generated from the following file: