コード例 #1
0
 private void RaiseDeletionEntityLoaded(EntityIdentifier entityId, TEntity entity)
 {
     this.eventDispatcher.DeletionEntityLoaded(
         new DeletionEntityLoadedArgs(
             this.operationExecutive.CurrentOperation.TimeStamp,
             entityId,
             entity));
 }
コード例 #2
0
 public DeletionEntityLoadedArgs(
     DateTimeOffset timeStamp,
     EntityIdentifier entityId,
     TEntity entity)
     : base(timeStamp, entityId)
 {
     this.entity = entity;
 }
コード例 #3
0
        private void RemoveMapping(
            IDictionary <EntityIdentifier, IMapping <TEntity> > mappings,
            TEntity entity)
        {
            EntityIdentifier sourceSystemEntityId =
                this.safeMetadataProvider.GetSourceSystemEntityId(entity);

            mappings.Remove(sourceSystemEntityId);
        }
コード例 #4
0
        public void Constructor_Sets_Int32_Identifier()
        {
            var identifier = new EntityIdentifier(-2125483448);

            identifier
            .Identifier
            .Should()
            .Be("-2125483448");
        }
コード例 #5
0
        public void Constructor_Sets_UInt32_Identifier()
        {
            var identifier = new EntityIdentifier(4234927293U);

            identifier
            .Identifier
            .Should()
            .Be("4234927293");
        }
コード例 #6
0
        public void Constructor_Sets_Int64_Identifier()
        {
            var identifier = new EntityIdentifier(-9222371036854555806L);

            identifier
            .Identifier
            .Should()
            .Be("-9222371036854555806");
        }
コード例 #7
0
        public void Constructor_Sets_UInt64_Identifier()
        {
            var identifier = new EntityIdentifier(18446724073709451651UL);

            identifier
            .Identifier
            .Should()
            .Be("18446724073709451651");
        }
コード例 #8
0
        public void GetHashCode_Returns_UpperCase_String_Representation_Hash_Code()
        {
            var identifier = new EntityIdentifier("AbCdEfG");

            identifier
            .GetHashCode()
            .Should()
            .Be("ABCDEFG".GetHashCode());
        }
コード例 #9
0
        public void Constructor_Sets_String_Identifier()
        {
            var identifier = new EntityIdentifier("This is a unique identifier!");

            identifier
            .Identifier
            .Should()
            .Be("This is a unique identifier!");
        }
コード例 #10
0
        public void Equal_Returns_True_If_Identifiers_Equal()
        {
            var identifierOne = new EntityIdentifier("Alpha");
            var identifierTwo = new EntityIdentifier("ALPHa");

            EntityIdentifier
            .Equal(identifierOne, identifierTwo)
            .Should()
            .BeTrue();
        }
コード例 #11
0
        public void Constructor_Sets_Guid_Identifier()
        {
            var identifier = new EntityIdentifier(
                Guid.Parse("A572507A-3876-4794-B515-5DCC0A0CF694"));

            identifier
            .Identifier
            .Should()
            .Be("a572507a-3876-4794-b515-5dcc0a0cf694");
        }
コード例 #12
0
        public void Equal_Returns_False_If_Identifiers_Differ()
        {
            var identifierOne = new EntityIdentifier("Bravo");
            var identifierTwo = new EntityIdentifier("Charlie");

            EntityIdentifier
            .Equal(identifierOne, identifierTwo)
            .Should()
            .BeFalse();
        }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 /// <param name="identifier">
 /// A case-insensitive string representation of the identifier.
 /// </param>
 public EntityIdentifier(string identifier)
 {
     ArgumentValidator.EnsureArgumentNotNull(identifier, nameof(identifier));
     if (identifier.Length > MaxLength)
     {
         throw new ArgumentException(
                   string.Format(Resources.EntityIdentifierTooLong, MaxLength),
                   nameof(identifier));
     }
     this.identifier = identifier;
 }
コード例 #14
0
 public DeletionProcessedArgs(
     DateTimeOffset timeStamp,
     IEnumerable <ILogMessage> logMessages,
     Exception exception,
     EntityIdentifier entityId,
     EntityDeletionOutcome outcome)
     : base(timeStamp, logMessages, exception)
 {
     this.entityId = entityId;
     this.outcome  = outcome;
 }
コード例 #15
0
 public void Equal_Returns_False_If_One_Identifier_Null()
 {
     EntityIdentifier
     .Equal(new EntityIdentifier(885), null)
     .Should()
     .BeFalse();
     EntityIdentifier
     .Equal(null, new EntityIdentifier(Guid.NewGuid()))
     .Should()
     .BeFalse();
 }
コード例 #16
0
 private void RaiseDeletionProcessed(
     EntityIdentifier entityId,
     EntityDeletionOutcome outcome,
     Exception exception)
 {
     this.eventDispatcher.DeletionProcessed(
         new DeletionProcessedArgs(
             this.operationExecutive.CurrentOperation.TimeStamp,
             this.operationExecutive.CurrentOperation.LogMessages,
             exception,
             entityId,
             outcome));
 }
コード例 #17
0
 /// <summary>
 /// Gets the specified entity instance from the destination system.
 /// </summary>
 /// <param name="id">The ID of the requested entity instance.</param>
 /// <returns>The requested entity instance.</returns>
 public TEntity Get(EntityIdentifier id)
 {
     return(this.Execute(
                () =>
     {
         TEntity entity = this.serviceProvider.Sink.Get(id);
         if (entity != null)
         {
             entity = this.Preprocess(entity);
         }
         return entity;
     }));
 }
コード例 #18
0
        public void Equals_Returns_False_If_Other_Object_Is_Different_Identifier()
        {
            var identifier = new EntityIdentifier("12345");

            identifier
            .Equals(new EntityIdentifier("123456"))
            .Should()
            .BeFalse();
            identifier
            .Equals(new EntityIdentifier("012345"))
            .Should()
            .BeFalse();
        }
コード例 #19
0
        public void Equals_Returns_False_If_Other_Object_Different_Type()
        {
            var identifier = new EntityIdentifier("88");

            identifier
            .Equals(int.MaxValue)
            .Should()
            .BeFalse();
            identifier
            .Equals(new Exception())
            .Should()
            .BeFalse();
        }
コード例 #20
0
        public void Equals_Returns_True_If_Other_Object_Is_Same_Identifier()
        {
            var identifier = new EntityIdentifier("AbCdEf");

            identifier
            .Equals(new EntityIdentifier("AbCdEf"))
            .Should()
            .BeTrue();
            identifier
            .Equals(new EntityIdentifier("aBcDeF"))
            .Should()
            .BeTrue();
        }
コード例 #21
0
ファイル: Processor.cs プロジェクト: Synnduit/Synnduit
        private EntityTransactionOutcome ProcessNewEntity()
        {
            this.DestinationSystemEntity = this.gateway.New();
            this.ValueChanges            = this.Merge();
            EntityIdentifier
                destinationSystemEntityId = this.CreateDestinationSystemEntity();

            this.Mapping = this.mappingRepository.CreateMapping(
                this.SourceSystemEntityId,
                destinationSystemEntityId,
                MappingOrigin.NewEntity,
                this.SourceSystemEntity);
            return(EntityTransactionOutcome.NewEntityCreated);
        }
コード例 #22
0
ファイル: Processor.cs プロジェクト: Synnduit/Synnduit
        private EntityIdentifier GetSourceSystemEntityId()
        {
            EntityIdentifier sourceSystemEntityId =
                this
                .safeMetadataProvider
                .GetSourceSystemEntityId(this.SourceSystemEntity);

            if (sourceSystemEntityId == null)
            {
                throw new InvalidOperationException(
                          Resources.EntityHasNoSourceSystemEntityId);
            }
            return(sourceSystemEntityId);
        }
コード例 #23
0
            public void UpdateIdentityCorrelationId(EntityIdentifier sourceSystemEntityId)
            {
                EntityIdentifier currentSourceSystemEntityId =
                    this.GetCorrelationIdUpdateSourceSystemEntityId();

                if (currentSourceSystemEntityId != null &&
                    currentSourceSystemEntityId != sourceSystemEntityId)
                {
                    throw new InvalidOperationException(
                              Resources.CannotChangeCorrelationIdUpdateSourceSystemEntityId);
                }
                this.Data[CorrelationIdUpdateSourceSystemEntityIdDataKey]
                    = sourceSystemEntityId;
            }
コード例 #24
0
        /// <summary>
        /// Determines whether two <see cref="EntityIdentifier" /> instances represent the
        /// same identifier.
        /// </summary>
        /// <param name="identifierOne">
        /// The first <see cref="EntityIdentifier" /> instance to compare, or null.
        /// </param>
        /// <param name="identifierTwo">
        /// The second <see cref="EntityIdentifier" /> instance to compare, or null.
        /// </param>
        /// <returns>
        /// True, if the two instances represent the same identifier (or they're both
        /// null); otherwise, false.
        /// </returns>
        public static bool Equal(
            EntityIdentifier identifierOne, EntityIdentifier identifierTwo)
        {
            bool equal = false;

            if ((object)identifierOne != null && (object)identifierTwo != null)
            {
                equal = identifierOne.Equals(identifierTwo);
            }
            else if ((object)identifierOne == null && (object)identifierTwo == null)
            {
                equal = true;
            }
            return(equal);
        }
コード例 #25
0
            private void PerformIdentityCorrelationIdUpdate()
            {
                EntityIdentifier correlationIdUpdateSourceSystemEntityId
                    = this.GetCorrelationIdUpdateSourceSystemEntityId();

                if (correlationIdUpdateSourceSystemEntityId != null)
                {
                    this.parent
                    .safeRepository
                    .UpdateIdentityCorrelationId(
                        new OperationIdIdentity(
                            this.Id,
                            this.parent.context.EntityType.Id,
                            this.parent.context.SourceSystem.Id,
                            correlationIdUpdateSourceSystemEntityId));
                }
            }
コード例 #26
0
        /// <summary>
        /// Creates an <see cref="EntityIdentifier" /> instance by converting the specified
        /// <see cref="object" /> instance.
        /// </summary>
        /// <param name="value"></param>
        /// <returns>
        /// A <see cref="EntityIdentifier" /> instance created by converting the specified
        /// <see cref="object" /> instance.
        /// </returns>
        public EntityIdentifier FromValue(object value)
        {
            EntityIdentifier identifier = null;

            if (value != null)
            {
                Func <object, EntityIdentifier> valueConverter =
                    this.GetFromValueConverter(value.GetType());
                if (valueConverter == null)
                {
                    throw new InvalidOperationException(string.Format(
                                                            Resources.ConversionFromNotSupported,
                                                            value.GetType().FullName));
                }
                identifier = valueConverter(value);
            }
            return(identifier);
        }
コード例 #27
0
        /// <summary>
        /// Converts the specified <see cref="EntityIdentifier" /> instance to an instance
        /// of the specified type.
        /// </summary>
        /// <param name="identifier">
        /// The <see cref="EntityIdentifier" /> instance to convert.
        /// </param>
        /// <param name="type">The target type.</param>
        /// <returns>
        /// The specified <see cref="EntityIdentifier" /> converted to the specified type.
        /// </returns>
        public object ToValue(EntityIdentifier identifier, Type type)
        {
            // validate the type parameter
            ArgumentValidator.EnsureArgumentNotNull(type, nameof(type));

            // convert the identifier and return the value
            object value = null;

            if (identifier != null)
            {
                Func <EntityIdentifier, object>
                valueConverter = this.GetToValueConverter(type);
                if (valueConverter == null)
                {
                    throw new InvalidOperationException(string.Format(
                                                            Resources.ConversionToNotSupported,
                                                            type.FullName));
                }
                value = valueConverter(identifier);
            }
            return(value);
        }
コード例 #28
0
        public void Implicit_Conversion_From_UInt64_Creates_Expected_Identifier()
        {
            EntityIdentifier identifier = 777548UL;

            identifier.Identifier.Should().Be("777548");
        }
コード例 #29
0
        public void ToString_Returns_String_Representation_Of_Identifier()
        {
            var identifier = new EntityIdentifier("Dodo");

            identifier.ToString().Should().Be("Dodo");
        }
コード例 #30
0
        public void Implicit_Conversion_To_String_Creates_Expected_String()
        {
            string identifier = new EntityIdentifier("Tango");

            identifier.Should().Be("Tango");
        }