public static EventSourceKey get_event_source_key(EventSourceId event_source_id = null, ArtifactId artifact_id = null)
        {
            var es = event_source_id ?? EventSourceId.New();
            var a  = artifact_id ?? ArtifactId.New();

            return(new EventSourceKey(es, a));
        }
Example #2
0
 public static CommittedEvent single(uint event_log_sequence_number) => new CommittedEvent(
     event_log_sequence_number,
     DateTimeOffset.UtcNow,
     EventSourceId.New(),
     execution_contexts.create(),
     new Artifact(ArtifactId.New(), ArtifactGeneration.First),
     false,
     "{\"something\":42}");
Example #3
0
 public static CommittedEvent single() => new CommittedEvent(
     EventLogSequenceNumber.Initial,
     DateTimeOffset.UtcNow,
     EventSourceId.New(),
     execution_contexts.create(),
     new Artifact(ArtifactId.New(), ArtifactGeneration.First),
     false,
     "{\"something\":42}");
        int HandleArtifactOfType(ArtifactType artifactType, BoundedContextTopology boundedContextConfiguration, MutableAritfactsDictionary artifactsDictionary, List <string> nonMatchingArtifacts)
        {
            var targetProperty = artifactType.TargetPropertyExpression.GetPropertyInfo();

            var newArtifacts = 0;
            var artifacts    = _artifacts.Where(_ => artifactType.Type.IsAssignableFrom(_));

            foreach (var artifact in artifacts)
            {
                var feature = boundedContextConfiguration.FindMatchingFeature(artifact.Namespace, nonMatchingArtifacts);
                if (feature.Value != null)
                {
                    MutableArtifactsByTypeDictionary artifactsByType;
                    if (!artifactsDictionary.TryGetValue(feature.Key, out artifactsByType))
                    {
                        artifactsByType = artifactsDictionary[feature.Key] = new Dictionary <PropertyInfo, Dictionary <ArtifactId, ArtifactDefinition> >();
                    }

                    Dictionary <ArtifactId, ArtifactDefinition> mutableArtifacts;
                    if (!artifactsByType.TryGetValue(targetProperty, out mutableArtifacts))
                    {
                        mutableArtifacts = artifactsByType[targetProperty] = new Dictionary <ArtifactId, ArtifactDefinition>();
                    }

                    if (!mutableArtifacts.Any(_ => _.Value.Type.GetActualType() == artifact))
                    {
                        var artifactObject = new Dolittle.Artifacts.Artifact(ArtifactId.New(), ArtifactGeneration.First);
                        if (artifact.HasAttribute <ArtifactAttribute>())
                        {
                            artifactObject = (artifact.GetTypeInfo().GetCustomAttributes(typeof(ArtifactAttribute), false).First() as ArtifactAttribute).Artifact;
                        }

                        AddNewArtifact(artifactObject, artifact, mutableArtifacts, artifactType.TypeName);
                        newArtifacts++;
                    }
                    else
                    {
                        if (artifact.HasAttribute <ArtifactAttribute>())
                        {
                            var artifactObject = (artifact.GetTypeInfo().GetCustomAttributes(typeof(ArtifactAttribute), false).First() as ArtifactAttribute).Artifact;

                            var existingArtifact = mutableArtifacts.Single(_ => _.Value.Type.GetActualType() == artifact);
                            if (!existingArtifact.Key.Value.Equals(artifactObject.Id.Value))
                            {
                                mutableArtifacts.Remove(existingArtifact.Key);
                                AddNewArtifact(artifactObject, artifact, mutableArtifacts, artifactType.TypeName);
                                newArtifacts++;
                            }
                        }
                    }
                }
            }
            return(newArtifacts);
        }
 public static VersionedEventSource a_versioned_event_source_for(EventSourceId id)
 {
     return(new VersionedEventSource(id, ArtifactId.New()));
 }
        public static CommittedEvent build_committed_event(VersionedEventSource versionedEventSource, IEvent @event, CommittedEventVersion version)
        {
            var metadata = new EventMetadata(EventId.New(), versionedEventSource, CorrelationId.New(), new Artifact(ArtifactId.New(), 1), DateTime.UtcNow, GetOriginalContext());

            return(new CommittedEvent(version, metadata, @event));
        }
Example #7
0
 public static Artifact create() => new Artifact(ArtifactId.New(), 1);