Esempio n. 1
0
        private void ProcessProperty(
            IPreprocessorEntity <TEntity> entity,
            ReferenceIdentifierProperty property)
        {
            EntityIdentifier sourceSystemEntityId =
                this.entityIdentifierConverter.FromValue(
                    property.SourceSystemIdentifierProperty.GetValue(entity.Entity));

            if (sourceSystemEntityId != null)
            {
                EntityIdentifier destinationSystemEntityId =
                    this.GetDestinationSystemEntityId(
                        property.ReferencedEntityType,
                        sourceSystemEntityId,
                        property.DestinationSystemIdentifierProperty.Name);
                if (destinationSystemEntityId != null)
                {
                    object typedDestinationSystemEntityId =
                        this.entityIdentifierConverter.ToValue(
                            destinationSystemEntityId,
                            property.DestinationSystemIdentifierProperty.PropertyType);
                    property.DestinationSystemIdentifierProperty.SetValue(
                        entity.Entity, typedDestinationSystemEntityId);
                }
                else
                {
                    throw new ReferenceIdentifierResolverException(
                              string.Format(
                                  Resources.UnableToResolveReferenceIdentifier,
                                  property.DestinationSystemIdentifierProperty.Name,
                                  sourceSystemEntityId),
                              this.ShouldRejectEntity(entity, property));
                }
            }
        }
Esempio n. 2
0
 private bool ShouldRejectEntity(
     IPreprocessorEntity <TEntity> entity,
     ReferenceIdentifierProperty property)
 {
     return
         ((entity.MappingExists == false && property.IsRequiredOnCreation) ||
          (entity.MappingExists == true && property.IsRequiredOnUpdate));
 }