public void SetDataFrom(RailCommandDataSerializer other) { if (command.GetType() != other.command.GetType()) { throw new ArgumentException( $"The instance to copy from is not for the same event type. Expected {command.GetType()}, got {other.command.GetType()}.", nameof(other)); } for (int i = 0; i < members.Count; ++i) { members[i].ApplyFrom(other.members[i]); } }
public RailCommandDataSerializer(RailCommand instance) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } command = instance; foreach (PropertyInfo prop in instance .GetType() .GetProperties( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { if (Attribute.IsDefined(prop, typeof(CommandDataAttribute))) { members.Add(RailSynchronizedFactory.Create(instance, prop)); } } }