Exemplo n.º 1
0
 public static ILogger GetEventHandlerLogger(Ninject.Activation.IContext context)
 {
     return(new CompositeLogger(new List <ILogger>
     {
         context.Kernel.Get <TextLogger>()
     }));
 }
Exemplo n.º 2
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            var Mapper = new MapperConfiguration(cfg =>
            {
                #region DbEntity>> DomainEntity
                cfg.CreateMap <DbEntity.Departament, DomainEntity.Departament>();
                cfg.CreateMap <DbEntity.Employee, DomainEntity.Employee>();
                cfg.CreateMap <DbEntity.EmployeeSkill, DomainEntity.EmployeeSkill>();
                cfg.CreateMap <DbEntity.Group, DomainEntity.Group>();
                cfg.CreateMap <DbEntity.Log, DomainEntity.Log>();
                cfg.CreateMap <DbEntity.Position, DomainEntity.Position>();
                cfg.CreateMap <DbEntity.PositionSkill, DomainEntity.PositionSkill>();
                cfg.CreateMap <DbEntity.Skill, DomainEntity.Skill>();
                #endregion

                #region DomainEntity >> DbEntity
                cfg.CreateMap <DomainEntity.Departament, DbEntity.Departament>();
                cfg.CreateMap <DomainEntity.Employee, DbEntity.Employee>();
                cfg.CreateMap <DomainEntity.EmployeeSkill, DbEntity.EmployeeSkill>();
                cfg.CreateMap <DomainEntity.Group, DbEntity.Group>();
                cfg.CreateMap <DomainEntity.Log, DbEntity.Log>();
                cfg.CreateMap <DomainEntity.Position, DbEntity.Position>();
                cfg.CreateMap <DomainEntity.PositionSkill, DbEntity.PositionSkill>();
                cfg.CreateMap <DomainEntity.Skill, DbEntity.Skill>();
                #endregion
            })
                         .CreateMapper();

            return(Mapper);
        }
Exemplo n.º 3
0
    private ISession CreateSession(Ninject.Activation.IContext context)
    {
        var session = context.Kernel.Get <ISessionFactory>().OpenSession();

        session.EnableFilter(DigitalLights.Model.FluentLogicalDeleteFilter.FilterName);
        return(session);
    }
Exemplo n.º 4
0
 public static ILogger GetLogger(Ninject.Activation.IContext context)
 {
     return(new CompositeLogger(new List <ILogger>()
     {
         context.Kernel.Get <AgentLogger>(),
         context.Kernel.Get <DatabaseLogger>()
     }));
 }
Exemplo n.º 5
0
 public override void Activate(Ninject.Activation.IContext context, Ninject.Activation.InstanceReference reference)
 {
     if (reference.Instance is ILogger)
     {
         _logger = (ILogger)reference.Instance;
     }
     _logger.Debug("Ninject Activate: " + reference.Instance.GetType());
     base.Activate(context, reference);
 }
Exemplo n.º 6
0
        private static object GetCurrentUser(Ninject.Activation.IContext context, Ninject.Planning.Targets.ITarget target)
        {
            if (HttpContext.Current != null)
            {
                return(HttpContext.Current.GetOwinContext().Authentication.User.Identity);
            }

            return(null);
        }
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <IUser, UserVM>().ReverseMap();
            });

            return(Mapper.Instance);
        }
Exemplo n.º 8
0
        private object GetTokenProvider(Ninject.Activation.IContext context)
        {
            var dataProtectionProvider = new DpapiDataProtectionProvider(Assembly.GetExecutingAssembly().GetName().Name);

            return(new DataProtectorTokenProvider <ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"))
            {
                //Code for email confirmation and reset password life time
                TokenLifespan = TimeSpan.FromHours(6)
            });
        }
Exemplo n.º 9
0
        protected override IGameObject CreateInstance(Ninject.Activation.IContext context)
        {
            ResourceAttribute attrib = (ResourceAttribute)context.Request.Target.GetCustomAttributes(typeof(ResourceAttribute), false).FirstOrDefault();

            if (attrib == null)
            {
                return(new UnityGameObject(new GameObject()));
            }
            return(loader.instantiate(attrib.Path));
        }
Exemplo n.º 10
0
 private IdentityFactoryOptions <ApplicationUserManager> GetTokenProvider(Ninject.Activation.IContext context)
 {
     return(new IdentityFactoryOptions <ApplicationUserManager>()
     {
         // DpapiDataProtectionProvider not working in Azure web app
         // then implement MachineKeyProtectionProvider
         // https://stackoverflow.com/questions/23455579/generating-reset-password-token-does-not-work-in-azure-website/23661872#23661872
         DataProtectionProvider = new MachineKeyProtectionProvider()
     });
 }
Exemplo n.º 11
0
        public static IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(x =>
            {
                x.AddProfile <EmployeeProfile>();
            });

            Mapper.AssertConfigurationIsValid(); // optional
            return(Mapper.Instance);
        }
Exemplo n.º 12
0
        protected override T CreateInstance(Ninject.Activation.IContext context)
        {
            Resource resource = Scoping.getContextAttribute <Resource>(context);

            if (null != resource)
            {
                loader.loadResource <UnityEngine.Object>(resource.Path);
            }
            return(new Moq.Mock <T>().Object);
        }
Exemplo n.º 13
0
        protected override T CreateInstance(Ninject.Activation.IContext context)
        {
            var resource = Scoping.getContextAttribute <ResourceAttribute>(context);

            if (resource == null)
            {
                throw new ArgumentException("Injected resources must have Resource attributes");
            }

            return(loader.loadResource <T>(resource.Path));
        }
Exemplo n.º 14
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.ConstructServicesUsing(type => context.Kernel.Get(type));
                config.AddProfile(new OrderMapper());
                config.AddProfile(new SkuMapper());
            });

            return(Mapper.Instance);
        }
Exemplo n.º 15
0
        public static T getContextAttribute<T>(Ninject.Activation.IContext context) where T : System.Attribute {
            if (context.Request.Target != null && context.Request.Target.IsDefined(typeof(T), false)) {
                return (T) context.Request.Target.GetCustomAttributes(typeof(T), false)[0];
            }
            
            if (context.Request.ParentContext != null) {
                return getContextAttribute<T>(context.Request.ParentContext);
            }

            return null;
        }
Exemplo n.º 16
0
        public T CreateInstance(Ninject.Activation.IContext context)
        {
            XMLConfigValue value = Scoping.getContextAttribute <XMLConfigValue>(context);

            if (value == null)
            {
                return(default(T));
            }

            return(manager.getValue <T>(value.file, value.xpath));
        }
        private ISession CreateSession(Ninject.Activation.IContext arg)
        {
            var sessionFactory = arg.Kernel.Get <ISessionFactory>();

            if (!CurrentSessionContext.HasBind(sessionFactory))
            {
                var session = sessionFactory.OpenSession();
                CurrentSessionContext.Bind(session);
            }
            return(sessionFactory.GetCurrentSession());
        }
Exemplo n.º 18
0
 private IMapper AutoMapper(Ninject.Activation.IContext context)
 {
     Mapper.Initialize(config =>
     {
         config.ConstructServicesUsing(type => context.Kernel.Get(type));
         config.AddProfile(new CustomProfile());
         // .... other mappings, Profiles, etc.
     });
     Mapper.AssertConfigurationIsValid(); // optional
     return(Mapper.Instance);
 }
Exemplo n.º 19
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            IMapper mapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <AutoMapping>();
                cfg.AddProfile <Museum.BLL.Infrastructure.AutoMapping>();
                cfg.ConstructServicesUsing(type => context.Kernel.GetType());
            }).CreateMapper();

            return(mapper);
        }
Exemplo n.º 20
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <UserEntity, UserPOCO>().ReverseMap();
                config.CreateMap <UserEntity, IUser>().ReverseMap();
                config.CreateMap <UserPOCO, IUser>().ReverseMap();
            });

            return(Mapper.Instance);
        }
Exemplo n.º 21
0
        private static IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(cfg =>
            {
                cfg.ConstructServicesUsing(type => context.Kernel.Get(type));
                cfg.AddProfile(new GatewayMapperProfile());
                cfg.AddProfile(new DeviceMapperProfile());
            });

            Mapper.AssertConfigurationIsValid(); // optional
            return(Mapper.Instance);
        }
        public static IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <CustomerDto, Customer>()
                .ForMember(dest => dest.Bets, opt => opt.Ignore());
                config.CreateMap <Customer, CustomerDto>();
            });

            Mapper.AssertConfigurationIsValid(); // optional
            return(Mapper.Instance);
        }
Exemplo n.º 23
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.ConstructServicesUsing(type => context.Kernel.Get(type));

                config.AddProfile <MappingProfile>();
            });

            Mapper.AssertConfigurationIsValid(); // optional
            return(Mapper.Instance);
        }
Exemplo n.º 24
0
 /*
  * Ninject scoping function; traverse the activation context hierarchy to the root, or a type 
  * that has a GameObjectBoundary attribute.
  */
 public static object GameObjectBoundaryScoper(Ninject.Activation.IContext context) {
     if (context.Request.Target != null) {
         if (context.Request.Target.IsDefined(typeof(GameObjectBoundary), true) || context.Request.Target.Type.IsDefined(typeof(GameObjectBoundary), true)) {
             return context.Request.Target;
         }
     }
     
     if (context.Request.ParentContext != null) {
         return GameObjectBoundaryScoper (context.Request.ParentContext);
     }
     
     return context;
 }
Exemplo n.º 25
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.ConstructServicesUsing(type => context.Kernel.Get(type));

                config.CreateMap <Inventory, InventoryModel>();
                config.CreateMap <User, UserResponseModel>(MemberList.None);
                config.CreateMap <User, UserIdentityModel>(MemberList.None);
            });

            Mapper.AssertConfigurationIsValid();
            return(Mapper.Instance);
        }
Exemplo n.º 26
0
        private static IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.ConstructServicesUsing(type => context.Kernel.GetType());

                config.AddProfile(new WebApiMappingConfig());
                config.AddProfile(new BLLAutomapperProfile());
                config.AddProfiles("ECommerce.DLL");
            });

            Mapper.AssertConfigurationIsValid();

            return(Mapper.Instance);
        }
Exemplo n.º 27
0
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            var conf = new MapperConfiguration(cfg =>
            {
                cfg.ConstructServicesUsing(type => context.Kernel.Get(type));

                cfg.CreateMap <User, UserDTO>().ForMember(dest => dest.Roles, src => src.MapFrom(o => o.Roles.Select(r => r.RoleId)));

                cfg.CreateMap <IdentityUserRole, string>().ConvertUsing(src => src.RoleId);

                cfg.CreateMap <RoleDTO, Role>().ForMember(dest => dest.Users, src => src.Ignore());
            });

            return(new Mapper(conf));
        }
Exemplo n.º 28
0
        public static MapperConfiguration GetConfig(Ninject.Activation.IContext context)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.ConstructServicesUsing(type => context.Kernel.GetType());

                cfg.CreateMap <WorkTask, WorkTaskDTO>().ReverseMap().MaxDepth(1);
                cfg.CreateMap <Project, ProjectDTO>().ReverseMap().MaxDepth(1);
                cfg.CreateMap <Position, PositionDTO>().ReverseMap().MaxDepth(1);

                cfg.CreateMap <ApplicationUser, UserDTO>().ReverseMap().MaxDepth(1);
                cfg.CreateMap <IdentityRole, RoleDTO>().ReverseMap().MaxDepth(1);
            });

            return(config);
        }
        public static IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <HorseDto, HorseModel>()
                .ForMember(dest => dest.Bets, opt => opt.Ignore())
                .ForMember(dest => dest.TotalNumberOfBets, opt => opt.Ignore())
                .ForMember(dest => dest.TotalAmoutPayout, opt => opt.Ignore())
                .ForMember(dest => dest.TotalBetAmount, opt => opt.Ignore());
                config.CreateMap <RaceDto, RaceModel>()
                .ForMember(dest => dest.TotalBets, opt => opt.Ignore());
                config.CreateMap <BetDto, BetModel>();
            });

            Mapper.AssertConfigurationIsValid(); // optional
            return(Mapper.Instance);
        }
Exemplo n.º 30
0
        //Bind method
        private IMapper AutoMapper(Ninject.Activation.IContext context)
        {
            var profiles =
                from t in typeof(ModelMappingProfile).Assembly.GetTypes()
                where typeof(Profile).IsAssignableFrom(t)
                select(Profile) Activator.CreateInstance(t);

            Mapper.Initialize(cfg =>
            {
                foreach (var profile in profiles)
                {
                    cfg.AddProfile(profile);
                }
            });

            Mapper.AssertConfigurationIsValid();
            return(Mapper.Instance);
        }