예제 #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);
        }
예제 #2
0
        /// <summary>
        /// Validate that Parameterized Modifiers have the same parameters as list of Required types.
        /// </summary>
        /// <param name="entityDescriptions"></param>
        public virtual void CheckModifiersParams(
            Dictionary <Type, IEntityDescription> entityDescriptions)
        {
            foreach (IEntityDescription entity in entityDescriptions.Values)
            {
                List <Type>      requiredEntitiesTypes = entity.Required.Select(x => x.Type).ToList();
                List <IModifier> modifiers             = _generatorSetup.GetModifiers(entity);
                modifiers.Where(x => x is IDelegateParameterizedModifier)
                .ToList();

                for (int i = 0; i < modifiers.Count; i++)
                {
                    IModifier modifier       = modifiers[i];
                    Type      modifierType   = modifier.GetType();
                    Type[]    modifierParams = (modifier as IDelegateParameterizedModifier)
                                               .GetRequiredEntitiesFuncParameters()
                                               .ToArray();

                    CheckDuplicates(modifierParams, entity, modifierType);
                    CompareToRequiredParams(requiredEntitiesTypes, modifierParams, entity, modifierType);
                }
            }
        }