/// <summary> /// Determines whether the specified <see cref="CSF.Entities.IEntity"/> is equal to the current /// <see cref="T:CSF.Entities.Entity{TIdentity}"/>. /// </summary> /// <param name="obj">The <see cref="CSF.Entities.IEntity"/> to compare with the current <see cref="T:CSF.Entities.Entity{TIdentity}"/>.</param> /// <returns> /// <c>true</c> if the specified <see cref="CSF.Entities.IEntity"/> is equal to the current /// <see cref="T:CSF.Entities.Entity{TIdentity}"/>; otherwise, <c>false</c>. /// </returns> public virtual bool Equals(IEntity obj) { bool output; if (Object.ReferenceEquals(this, obj)) { output = true; } else if ((object)obj == null) { output = false; } else if (!this.HasIdentity || !obj.HasIdentity) { output = false; } else { IIdentity myIdentity = this.GetRawIdentity(), theirIdentity = obj.GetRawIdentity(); output = myIdentity.Equals(theirIdentity); } return(output); }
public void Verify_equality_through_interface() { IIdentity id1 = (IIdentity) new SampleAggregateId(42); IIdentity id2 = (IIdentity) new SampleAggregateId(42); Assert.That(id1.Equals(id2)); Assert.That(object.Equals(id1, id2)); }
EventStream IEventStore.LoadEventStream(IIdentity id) { var events = Store.OfType <IEvent <IIdentity> >().Where(i => id.Equals(i.Id)).Cast <IEvent>().ToList(); return(new EventStream { Events = events, StreamVersion = events.Count }); }
/// <summary> /// Add events to an existing appender, events in order will be serialized as a single bytestream. /// </summary> /// <param name="dest">appender</param> /// <param name="source">events to add</param> /// <paramref name="serializer">serializer, default binary</paramref> public static void AddEvents(this IAppendOnlyStore dest, IEnumerable <IEvent> source, IEventSerializer serializer = null) { if (dest == null) { throw new ArgumentNullException("dest"); } if (source == null) { throw new ArgumentNullException("source"); } var es = new EventStore.EventStore(dest, serializer ?? new BinaryFormatterSerializer()); var events = source as IEvent[] ?? source.ToArray(); var versions = new Dictionary <IIdentity, int>(); List <IEvent> stack = new List <IEvent>(); Action savestack = () => { if (!versions.ContainsKey(stack[0].AggregateId)) { versions[stack[0].AggregateId] = 0; } es.AppendToStream(stack[0].AggregateId, versions[stack[0].AggregateId], stack); versions[stack[0].AggregateId]++; stack.Clear(); }; if (events.Any()) { IIdentity lastid = null; foreach (var e in events) { if (stack.Any() && !lastid.Equals(e.AggregateId)) { savestack(); } //else { stack.Add(e); lastid = e.AggregateId; } } } savestack(); }
public ProductInstance GetInstance(IIdentity identity) { ValidateHealthState(); if (identity == null) { throw new ArgumentNullException(nameof(identity)); } var instance = ProductManager .GetInstances <IIdentifiableObject>(i => identity.Equals(i.Identity)) .SingleOrDefault(); return((ProductInstance)instance); }
public EventStream LoadEventStream(IIdentity id, long skipEvents, int maxCount) { var stream = Store .Where(i => id.Equals(i.Item1)) .Skip((int)skipEvents) .Take(maxCount) .Select(i => i.Item2) .ToList(); return(new EventStream { Events = stream, Version = stream.Count }); }
public virtual void UpdateFromRecipient(IMessageRecipient recipient) { IIdentity identity = this.identity; this.displayName = recipient.DisplayName; this.emailAddress = recipient.EmailAddress; this.routingType = recipient.RoutingType; this.smtpAddress = recipient.SmtpAddress; this.sipUri = recipient.SipUri; this.alias = recipient.Alias; this.isDistributionList = recipient.IsDistributionList; this.recipientDisplayType = recipient.RecipientDisplayType; this.ComputeIdentity(); Util.ThrowOnConditionFailed(identity.Equals(this.Identity), "Updates of a recipient are not allowed to change the recipient identity"); }
public bool Equals(IRequestToken other) { if (other == null) { return(false); } return(token.Equals(other.Token) && secret.Equals(other.Secret) && status == other.Status && String.Equals(consumerKey, other.ConsumerKey) && ((parameters == null && other.AssociatedParameters == null) || (parameters != null && parameters.Equals(other.AssociatedParameters))) && ((user == null && other.AuthenticatedUser == null) || (user != null && user.Equals(other.AuthenticatedUser))) && RolesEquals(other.Roles)); }