public void MergeFrom(UserSession from) { if (UserId != from.UserId) { throw new InvalidOperationException("UserSession UserId is immutable."); } if (CreatedUtc != from.CreatedUtc) { throw new InvalidOperationException("UserSession CreatedUtc is immutable."); } if (UserTimeZoneOffsetMinutes != from.UserTimeZoneOffsetMinutes) { throw new InvalidOperationException("UserSession UserTimeZoneOffsetMinutes is immutable"); } if (TypingSessionId != from.TypingSessionId) { throw new InvalidOperationException("UserSession TypingSessionId is immutable."); } foreach (var result in from.TextTypingResults) { var existing = TextTypingResults.FirstOrDefault(t => t.Id == result.Id); if (existing != null) { // TODO: Check that if any of the fields differ - throw. continue; } TextTypingResults.Add(result); } }
public Typing.UserSession.State ToState() { return(new Typing.UserSession.State( Id, UserId, TypingSessionId, CreatedUtc, UserTimeZoneOffsetMinutes, TextTypingResults.Select(ttr => ttr.ToState()) .ToList())); }