예제 #1
0
 /// <summary>
 ///     将 <see cref="SourceInfo" /> 的字符串表示形式转换为它的等效的 <see cref="SourceInfo" />。一个指示转换是否成功的返回值。
 /// </summary>
 public static bool TryParse(string input, out SourceInfo result)
 {
     try
     {
         result = Parse(input);
         return(true);
     }
     catch (Exception)
     {
         result = null;
         return(false);
     }
 }
예제 #2
0
        private static Envelope <IEvent> Convert(IVersionedEvent @event, SourceInfo sourceInfo,
                                                 Envelope <ICommand> command)
        {
            var envelope = new Envelope <IEvent>(@event,
                                                 MD5(string.Format("{0}&{1}", sourceInfo.Id, command.MessageId)));

            if (command.Items.ContainsKey(StandardMetadata.TraceInfo))
            {
                envelope.Items[StandardMetadata.TraceInfo] = command.Items[StandardMetadata.TraceInfo];
            }
            envelope.Items[StandardMetadata.SourceInfo]  = sourceInfo;
            envelope.Items[StandardMetadata.CommandInfo] = new SourceInfo(command.MessageId, command.Body.GetType());

            return(envelope);
        }
 public virtual int GetPublishedVersion(SourceInfo sourceInfo)
 {
     return(0);
 }
 public virtual void AddOrUpdatePublishedVersion(SourceInfo sourceInfo, int version)
 {
 }
 void IEventPublishedVersionStore.AddOrUpdatePublishedVersion(SourceInfo sourceInfo, int version)
 {
     AddOrUpdatePublishedVersionToMemory(sourceInfo, version);
     AddOrUpdatePublishedVersion(sourceInfo, version);
 }
예제 #6
0
 private static bool IsEqual(SourceInfo left, SourceInfo right)
 {
     return(string.Equals(left.Id, right.Id, StringComparison.CurrentCultureIgnoreCase) &&
            left.Type == right.Type);
 }
예제 #7
0
        public bool Save(SourceInfo sourceInfo, IEnumerable <IVersionedEvent> events, string correlationId)
        {
            var set = collection.GetOrAdd(sourceInfo, () => new HashSet <EventCollection>());

            return(set.Add(new EventCollection(correlationId, events)));
        }