Empeld
Empeld plugin documentation.
pluginbase.Objects.Syncable.Watchers.MutableSync< T > Class Template Reference

A special syncable type where the type (T) is not assumed eg. This can sync an interface, as long as the implementing type is also a syncable, and the type along with the values will be sync'd More...

Inheritance diagram for pluginbase.Objects.Syncable.Watchers.MutableSync< T >:

Public Member Functions

 MutableSync ()
 

Protected Member Functions

override void TouchRecurse ()
 
override void ResetWatch ()
 
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)
 
sealed override void Load (pluginbase.Objects.Libs.Persist.IReadPersistObject obj)
 

Properties

Value [get, set]
 
Type Type [get]
 

Detailed Description

A special syncable type where the type (T) is not assumed eg. This can sync an interface, as long as the implementing type is also a syncable, and the type along with the values will be sync'd

Type Constraints
T :class 
T :INetSyncable 

Constructor & Destructor Documentation

◆ MutableSync()

Member Function Documentation

◆ DecodeFrom()

sealed override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.DecodeFrom ( System.IO.BinaryReader  reader,
DecodeContext  context 
)
protected
107  {
108  string typeName = reader.ReadString();
109  if (typeName == NULLTYPE)
110  {
111  this.ClearValueInternal();
112  }
113  else
114  {
115  if (_typeName != typeName)
116  {
117  //Must be a new type, let's make it!
118  this.ClearValueInternal();
119  Type type = TypeSerializer.Deserialize(typeName);
120  _typeName = typeName;
121  _value = (T)Activator.CreateInstance(type);
122  _value.Watcher = this;
123  }
124  _value.DecodeFrom(reader, context);
125  }
126  context.Increment();
127  }
Type Type
Definition: MutableSync.cs:50

◆ EncodeTo()

sealed override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.EncodeTo ( System.IO.BinaryWriter  writer,
EncodeContext  context 
)
protected
93  {
94  if (_typeName == null)
95  {
96  writer.Write(NULLTYPE);
97  }
98  else
99  {
100  writer.Write(_typeName);
101  _value.EncodeTo(writer, context);
102  }
103  context.Increment();
104  }

◆ Load()

140  {
141  string typeString = obj.Get<string>("__type");
142  Type type = TypeSerializer.Deserialize(typeString);
143  if (type != null && obj.Has("item"))
144  {
145  _typeName = typeString;
146  _value = (T)Activator.CreateInstance(type);
147  _value.Watcher = this;
148  _value.Load(obj.GetObject("item"));
149  }
150  }
Type Type
Definition: MutableSync.cs:50

◆ Persist()

130  {
131  obj.Set("__type", _typeName ?? string.Empty);
132  if (_value != null)
133  {
134  var sub = obj.GetOrCreateObject("item");
135  _value.Persist(sub);
136  }
137  }

◆ ResetWatch()

override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.ResetWatch ( )
protected
81  {
82  base.ResetWatch();
83  if (_value != null)
84  {
85  _value.ResetWatch();
86  }
87  }

◆ TouchRecurse()

override void pluginbase.Objects.Syncable.Watchers.MutableSync< T >.TouchRecurse ( )
protected
72  {
73  base.TouchRecurse();
74  if (_value != null)
75  {
76  _value.TouchRecurse();
77  }
78  }

Property Documentation

◆ Type

◆ Value


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