Example #1
0
        private static Thing ConfigureThing <T>(IServiceProvider provider)
            where T : Thing
        {
            var thing       = provider.GetRequiredService <T>();
            var option      = provider.GetRequiredService <ThingOption>();
            var optionsJson = new JsonSerializerOptions
            {
                WriteIndented        = false,
                IgnoreNullValues     = true,
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };

            var converter  = new ConverterInterceptorFactory(thing, optionsJson);
            var properties = new PropertiesInterceptFactory(thing, option);
            var events     = new EventInterceptFactory(thing, option);
            var actions    = new ActionInterceptFactory(option);

            CodeGeneratorFactory.Generate(thing, new List <IInterceptorFactory>()
            {
                converter,
                properties,
                events,
                actions
            });

            thing.ThingContext = new Context(converter.Create(),
                                             properties.Create(),
                                             events.Events,
                                             actions.Actions);
            return(thing);
        }
Example #2
0
 public PropertyInterceptFactoryTest()
 {
     _fixture = new Fixture();
     _thing   = new LampThing();
     _factory = new PropertiesInterceptFactory(_thing, new ThingOption
     {
     });
 }