示例#1
0
        protected override void DoStart()
        {
            var allFormulationsContainer = _flatContainerRepository.All().Where(ContainerIsFormulation).ToList();

            // loop over FORMULATION ROUTES in order to get formulations in proper sequence
            foreach (var formulationRoute in _formulationRouteRepository.All())
            {
                string formulationName  = formulationRoute.Formulation;
                var    flatFormulations = allFormulationsContainer.Where(f => f.Name.Equals(formulationName)).ToList();

                if (!flatFormulations.Any())
                {
                    continue;
                }

                var flatFormulation = flatFormulations.First();

                var formulation = _formulationMapper.MapFrom(flatFormulation);

                // formulation may appear more than once
                if (_formulations.Contains(formulation.FormulationType))
                {
                    continue;
                }

                _formulations.Add(formulation);
            }
        }
        public Formulation MapFrom(FlatContainer flatContainer)
        {
            var formulation = _objectBaseFactory.Create <Formulation>();

            formulation.Root = _objectBaseFactory.Create <IRootContainer>();
            formulation.Name = flatContainer.Name;

            //save formulation name as formulation type too,
            //because name can be overwritten by user
            formulation.FormulationType = formulation.Name;
            foreach (var formulationRoute in _formulationRouteRepo.All().Where(fr => fr.Formulation.Equals(formulation.Name)))
            {
                formulation.AddRoute(formulationRoute.Route);
            }
            return(formulation);
        }