Ejemplo n.º 1
0
        public void Test1()
        {
            MappingRegistration.RegisterAll(typeof(UnitTest1).Assembly);

            var client     = new MongoClient("mongodb://*****:*****@192.168.39.31");
            var database   = client.GetDatabase("Scoring");
            var repository = new MongoRuleRepository(database);

            //var spec = new WorkingExperience(TimeSpan.FromDays(365)).And(new WorkingExperience(TimeSpan.FromDays(10)));
            //var rule = new Rule(1, "Test rule", spec);
            //rule.SetCalculation(CalculationStrategy.IncreasePointsTo(1000));
            //repository.Add(rule).Wait();

            //var rule = repository.Get(1).Result;
        }
Ejemplo n.º 2
0
        public IMappingRegistration <TSource, TDest> Register <TSource, TDest>()
        {
            var key = new TypeMap(typeof(TSource), typeof(TDest));

            if (mappings.ContainsKey(key))
            {
                throw new ArgumentException();
            }

            // TODO : static MapEssence issue
            MapEssence <TSource, TDest> .MapFunc = null;

            var mappingRegistration = new MappingRegistration <TSource, TDest>();

            mappings.Add(key, mappingRegistration);

            return(mappingRegistration);
        }
Ejemplo n.º 3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "SIENN Recruitment API v1");
            });

            app.UseMvc();
            MappingRegistration.Register();
        }
Ejemplo n.º 4
0
        public Func <TSource, TDest> MapFunc <TSource, TDest>()
        {
            var mapFunc = MapEssence <TSource, TDest> .MapFunc;

            if (mapFunc != null)
            {
                return(mapFunc);
            }

            var key = new TypeMap(typeof(TSource), typeof(TDest));

            if (!mappings.TryGetValue(key, out var impl))
            {
                impl = new MappingRegistration <TSource, TDest>();
            }

            var mapFactory = new MapFactory(new MemberMappingsResolver(), dynamicMemberResolver, new MapEmitter(typeof(TDest)));

            mapFunc = MapEssence <TSource, TDest> .MapFunc = mapFactory.BuildMapMethod <TSource, TDest>(impl);
            ExpandResolvedMappings();
            return(mapFunc);
        }