Beispiel #1
0
        public IEnumerable <Schema> MapFrom(SimpleProtocol simpleProtocol)
        {
            var container = new Container();
            var schema    = _schemaFactory.Create(container);

            container.Add(schema);

            if (simpleProtocol.DosingInterval == DosingIntervals.Single)
            {
                schema.NumberOfRepetitions.Value = 1;
                schema.AddSchemaItem(createSchemaItem(simpleProtocol.StartTime.Value, simpleProtocol, schema));
                return(container.GetChildren <Schema>());
            }

            var protocolDuration   = simpleProtocol.EndTimeParameter.Value;
            int numberOfRepetition = (int)Math.Floor(protocolDuration / simpleProtocol.DosingInterval.IntervalLength);

            schema.NumberOfRepetitions.Value = numberOfRepetition;

            addDosingIntevalSchemaItemTo(schema, simpleProtocol);

            if (schema.Duration == protocolDuration)
            {
                return(container.GetChildren <Schema>());
            }

            //now we might need to add another schema if the time specified could not fit an entire repetition, or just add
            //another repetition if the created schema has the same length as the default schema

            var schemaSingular = _schemaFactory.Create(container);

            schemaSingular.NumberOfRepetitions.Value = 1;
            schemaSingular.StartTime.Value           = schema.Duration;
            addSingularSchemaItemTo(schemaSingular, simpleProtocol);
            if (schemaSingular.SchemaItems.Any())
            {
                if (schema.SchemaItems.Count() != schemaSingular.SchemaItems.Count())
                {
                    container.Add(schemaSingular);
                }
                else
                {
                    schema.NumberOfRepetitions.Value++;
                }
            }
            return(container.GetChildren <Schema>());
        }
        public GraphSchemaProvider(ISchemaFactory schemaFactory, IGraphServiceDiscoverer serviceDiscoverer)
        {
            Guard.ArgumentNotNull(schemaFactory, nameof(schemaFactory));
            Guard.ArgumentNotNull(serviceDiscoverer, nameof(serviceDiscoverer));

            _schemaAccessor = new Lazy <IGraphSchema>(() =>
            {
                return(schemaFactory.Create(serviceDiscoverer.Services));
            });
        }
Beispiel #3
0
        public override async Task <ModelSchema> MapToModel(SnapshotSchema snapshot)
        {
            var schema = _schemaFactory.Create();

            MapSnapshotPropertiesToModel(snapshot, schema);
            await UpdateParametersFromSnapshot(snapshot, schema, PKSimConstants.ObjectTypes.Schema);

            var schemaItems = await _schemaItemMapper.MapToModels(snapshot.SchemaItems);

            schemaItems?.Each(schema.AddSchemaItem);
            return(schema);
        }