//prepare settings protected virtual void SetDataAmounts(GeneratorSetup setup, Dictionary <Type, long> dataAmmounts) { foreach (Type type in dataAmmounts.Keys) { IEntityDescription entityDescription = GetEntityDescription(setup, type); long ammount = dataAmmounts[type]; PropertyInfo quantityPropInfo = entityDescription.GetType() .GetProperty(nameof(entityDescription.QuantityProvider)); quantityPropInfo.SetValue(entityDescription, new StrictQuantityProvider(ammount)); PropertyInfo flushTriggerPropInfo = entityDescription.GetType() .GetProperty(nameof(entityDescription.FlushTrigger)); flushTriggerPropInfo.SetValue(entityDescription, new LimitedCapacityFlushStrategy(ammount)); } }
//Get registered entity public virtual EntityDescription <TEntity> GetEntityDescription <TEntity>() where TEntity : class { Type entityType = typeof(TEntity); IEntityDescription entityDescription = GetEntityDescription(entityType); if (!(entityDescription is EntityDescription <TEntity>)) { Type descriptionActualType = entityDescription.GetType(); Type descriptionBaseType = typeof(EntityDescription <>); throw new TypeAccessException($"Entity type [{entityType.FullName}] was registered with description of type [{descriptionActualType.FullName}]. Not able to cast description to type [{descriptionBaseType.FullName}]. Use {nameof(EntityDescriptions)} property instead."); } return((EntityDescription <TEntity>)entityDescription); }