Пример #1
0
        public static PredicateProgram FromDto(PredicateProgramDto dto, EffectsManager manager)
        {
            var p = manager.Programs[dto.Program];

            return(new PredicateProgram
            {
                AndConditions = dto.AndConditions != null?dto.AndConditions.Select(ParameterPredicate.FromDto).ToList() : null,
                                    OrConditions = dto.OrConditions != null?dto.OrConditions.Select(ParameterPredicate.FromDto).ToList() : null,
                                                       Condition = ParameterPredicate.FromDto(dto.Condition),
                                                       Program = p
            });
        }
Пример #2
0
        public static Effect LoadFromJson(string jsonFileName, EffectsManager manager)
        {
            var fi = new FileInfo(jsonFileName);

            if (!fi.Exists)
            {
                throw new FileNotFoundException(jsonFileName);
            }

            var json = File.ReadAllText(jsonFileName);
            var dto  = JsonConvert.DeserializeObject <EffectDto>(json);

            var effect = new Effect
            {
                Name       = dto.Name,
                Predicates = dto.Predicates.ToDictionary(x => x.Key, y => y.Value.Items.Select(x => PredicateProgram.FromDto(x, manager)).ToList()),
                Programs   = dto.Programs.ToDictionary(x => x.Key, y => manager.Programs[y.Value])
            };

            return(effect);
        }
Пример #3
0
 public static Task <Effect> LoadFromJsonAsync(string jsonFileName, EffectsManager manager) => Task.Run(() => LoadFromJson(jsonFileName, manager));