static IReadOnlyCollection <Consideration> LoadConsiderations(this IntelligenceDatabase database, IEnumerable <Guid> ids)
 {
     return(ids
            .DefaultToEmptyIfNull()
            .Select(database.LoadConsideration)
            .Where(item => item != null)
            .ToList());
 }
        static Input LoadInput(this IntelligenceDatabase database, Guid id)
        {
            var record = database.Inputs.FirstOrDefault(x => x.Id == id)
                         ?? throw new ItemNotFoundException <Input>(id);

            return(new Input(
                       record.Id,
                       record.Name));
        }
        public static IntelligenceDefinition LoadIntelligenceDefinition(this IntelligenceDatabase database, Guid id)
        {
            var record = database.IntelligenceDefinitions.FirstOrDefault(x => x.Id == id)
                         ?? throw new ItemNotFoundException <IntelligenceDefinition>(id);

            return(new IntelligenceDefinition(
                       record.Id,
                       record.Name,
                       database.LoadDecisionMakers(record.DecisionMakerIds)));
        }
        static Consideration LoadConsideration(this IntelligenceDatabase database, Guid id)
        {
            var record = database.Considerations.FirstOrDefault(x => x.Id == id)
                         ?? throw new ItemNotFoundException <Consideration>(id);

            return(new Consideration(
                       record.Id,
                       record.Name,
                       database.LoadInput(record.InputId),
                       record.ResponseCurve));
        }
        static ActionSet LoadActionSet(this IntelligenceDatabase database, Guid id)
        {
            var record = database.ActionSets.FirstOrDefault(x => x.Id == id)
                         ?? throw new ItemNotFoundException <ActionSet>(id);

            return(new ActionSet(
                       record.Id,
                       record.Name,
                       record.SelectionStrategy,
                       database.LoadActions(record.ActionIds)));
        }
        static DecisionMaker LoadDecisionMaker(this IntelligenceDatabase database, Guid id)
        {
            var record = database.DecisionMakers.FirstOrDefault(x => x.Id == id)
                         ?? throw new ItemNotFoundException <DecisionMaker>(id);

            return(new DecisionMaker(
                       record.Id,
                       record.Name,
                       record.SelectionStrategy,
                       database.LoadActionSets(record.ActionSetIds)));
        }
        static Action LoadAction(this IntelligenceDatabase database, Guid id)
        {
            var record = database.Actions.FirstOrDefault(x => x.Id == id)
                         ?? throw new ItemNotFoundException <Action>(id);

            return(new Action(
                       record.Id,
                       record.Name,
                       record.Weight,
                       record.ScoringStrategy,
                       database.LoadConsiderations(record.ConsiderationIds)));
        }
コード例 #8
0
 public static string Serialize(IntelligenceDatabase database) =>
 JsonConvert.SerializeObject(
     database,
     Formatting.Indented,
     SerializerSettings);