Exemplo n.º 1
0
        //methods
        public virtual bool Execute()
        {
            IEntityDescription entityDescription = EntityContext.Description;
            IGenerator         generator         = _setup.GetGenerator(entityDescription);
            List <IModifier>   modifiers         = _setup.GetModifiers(entityDescription);

            var context = new GeneratorContext
            {
                Description      = entityDescription,
                EntityContexts   = _entityContexts,
                TargetCount      = EntityContext.EntityProgress.TargetCount,
                CurrentCount     = EntityContext.EntityProgress.CurrentCount,
                RequiredEntities = GetRequiredEntities(),
            };

            IList entities = generator.Generate(context);

            _setup.Validator.CheckGeneratedCount(entities, entityDescription.Type, generator);

            foreach (IModifier modifier in modifiers)
            {
                entities = modifier.Modify(context, entities);
                _setup.Validator.CheckModifiedCount(entities, entityDescription.Type, modifier);
            }

            _setup.TemporaryStorage.InsertToTemporary(EntityContext, entities);
            _setup.Supervisor.HandleGenerateCompleted(EntityContext, entities);

            return(true);
        }
Exemplo n.º 2
0
        //Generation prestart checks for Generators and Modifiers
        /// <summary>
        /// Validate that Parameterized Modifiers have the same parameters as list of Required types.
        /// </summary>
        /// <param name="entityDescriptions"></param>
        public virtual void CheckGeneratorsParams(
            Dictionary <Type, IEntityDescription> entityDescriptions)
        {
            foreach (IEntityDescription entity in entityDescriptions.Values)
            {
                List <Type> requiredEntitiesTypes = entity.Required
                                                    .Select(x => x.Type)
                                                    .ToList();
                IGenerator generator = _generatorSetup.GetGenerator(entity);

                Type generatorInstaceType = generator.GetType();
                if (!(generator is IDelegateParameterizedGenerator))
                {
                    continue;
                }

                Type[] generatorParams = (generator as IDelegateParameterizedGenerator)
                                         .GetRequiredEntitiesFuncParameters()
                                         .ToArray();

                CheckDuplicates(generatorParams, entity, generatorInstaceType);
                CompareToRequiredParams(requiredEntitiesTypes, generatorParams, entity, generatorInstaceType);
            }
        }