Example #1
0
        protected void Configure(PatcheetahConfig config)
        {
            config.EnableNestedPatching();
            config.EnableAttributes();
            config.SetPrePatchProcessingFunction(context =>
            {
                if (context.NewValue is int age && age == 0)
                {
                    return(18);
                }

                return(context.NewValue);
            });
            config
            .ConfigureEntity <User>()
            .UseMapping(x => x.Username, x =>
            {
                if (x == "convertme")
                {
                    return(MappingResult.MapTo($"{x}_1"));
                }

                return(MappingResult.Skip(x));
            })
            // .Required(x => x.LastSeenFrom) -> we don't need this anymore. Instead of method setup, we'll install it from attribute
            // .IgnoreOnPatching(x => x.Username) -> Same situation, let's install it from attribute
            .SetKey(x => x.Username);     // Set login as key but replace it by id from attributes
        }
Example #2
0
        public static void Init(Action <PatcheetahConfig> configure, IJsonTypesResolver jsonTypesResolver)
        {
            _jsonTypesResolver = jsonTypesResolver;
            var config = new PatcheetahConfig();

            configure(config);
            _config = config;
        }
 protected void Configure(PatcheetahConfig config)
 {
     config
     .ConfigureEntity <User>()
     .Required(x => x.LastSeenFrom)
     .IgnoreOnPatching(x => x.Login)
     .UseJsonAlias(x => x.PersonalInfo, "Personal")
     .SetKey(x => x.Id);
 }
 protected void Configure(PatcheetahConfig config)
 {
     config.EnableAttributes();
 }