/// <summary> /// It is better to implement ReplicateToAll and ReplicateToPeer instead of this method /// </summary> /// <param name="JoinInProgressPeerId">The ID of any peer that is currently joining or -1 if none is</param> /// <param name="IsIntervalReplicationTime">True if it is time for us to do interval replication</param> public virtual void Replicate(int JoinInProgressPeerId, bool IsIntervalReplicationTime) { Node Instance = NodeRef.GetRef() as Node; object CurrentValue = Member.GetValue(Instance); if (GetReplicatedType() == MDReplicatedType.Interval && IsIntervalReplicationTime || GetReplicatedType() == MDReplicatedType.OnChange && DataConverter.ShouldObjectBeReplicated(LastValue, CurrentValue)) { ReplicateToAll(CurrentValue); } else if (JoinInProgressPeerId != -1) { ReplicateToPeer(CurrentValue, JoinInProgressPeerId); } }
public object[] ConvertForSending(object Item, bool Complete) { ExtractMembers(); if (Item == null) { return(new object[] { null }); } List <object> ObjectArray = new List <object>(); List <object> newLastValues = new List <object>(); for (int i = 0; i < Members.Count; i++) { object value = Members[i].GetValue(Item); IMDDataConverter Converter = DataConverters[i]; if (Complete || LastValues.Count == 0 || Converter.ShouldObjectBeReplicated(LastValues[i], value)) { object[] dataArray = Converter.ConvertForSending(value, Complete); if (dataArray != null) { ObjectArray.Add($"{i}{SEPARATOR}{dataArray.Length}"); ObjectArray.AddRange(dataArray); } else { ObjectArray.Add($"{i}{SEPARATOR}{1}"); ObjectArray.Add(null); } } newLastValues.Add(value); } MDLog.Trace(LOG_CAT, $"MDCustomClass converting for sending ({MDStatics.GetParametersAsString(ObjectArray.ToArray())})"); LastValues = newLastValues; return(ObjectArray.ToArray()); }