public static string GetConcurrencyToken <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entityType, object entity)
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            return(entityPropertyAccessor.GetConcurrencyToken(typeof(TEntity), entity));
        }
        public static void CommitEvents <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            entityPropertyAccessor.CommitEvents(typeof(TEntity), entity);
        }
        public static void SetRevision <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity, long revision)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            entityPropertyAccessor.SetRevision(typeof(TEntity), entity, revision);
        }
        public static void SetConcurrencyToken <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity, string concurrencyToken)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            entityPropertyAccessor.SetConcurrencyToken(typeof(TEntity), entity, concurrencyToken);
        }
        public static bool TrySetId <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity, string id)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            return(entityPropertyAccessor.TrySetId(typeof(TEntity), entity, id));
        }
        public static bool TryAddEvent <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity, object evt)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            return(entityPropertyAccessor.TryAddEvent(typeof(TEntity), entity, evt));
        }
        public static IEnumerable <object> GetUncommittedEvents <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            return(entityPropertyAccessor.GetUncommittedEvents(typeof(TEntity), entity));
        }
        public static long GetRevision <TEntity>(this IEntityPropertyAccessor entityPropertyAccessor, TEntity entity)
            where TEntity : class
        {
            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            return(entityPropertyAccessor.GetRevision(typeof(TEntity), entity));
        }
Ejemplo n.º 9
0
        public ProductDeleteModel ProjectToDeleteModel(Product product,
                                                       [Inject] IEntityPropertyAccessor propertyManager)
        {
            if (product == null)
            {
                return(null);
            }

            var concurrencyToken = propertyManager.GetConcurrencyToken(typeof(Product), product);

            return(new ProductDeleteModel
            {
                Id = product.Id,
                ConcurrencyToken = concurrencyToken
            });
        }
Ejemplo n.º 10
0
        public EntityMessageHandlerProcessor(IServiceProvider serviceProvider,
                                             IEntityStorageEngine entityStorageEngine,
                                             IEntityPropertyAccessor entityPropertyAccessor)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (entityStorageEngine == null)
            {
                throw new ArgumentNullException(nameof(entityStorageEngine));
            }

            if (entityPropertyAccessor == null)
            {
                throw new ArgumentNullException(nameof(entityPropertyAccessor));
            }

            _serviceProvider        = serviceProvider;
            _entityStorageEngine    = entityStorageEngine;
            _entityPropertyAccessor = entityPropertyAccessor;
        }