public static ILogger GetEventHandlerLogger(Ninject.Activation.IContext context) { return(new CompositeLogger(new List <ILogger> { context.Kernel.Get <TextLogger>() })); }
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); }
private ISession CreateSession(Ninject.Activation.IContext context) { var session = context.Kernel.Get <ISessionFactory>().OpenSession(); session.EnableFilter(DigitalLights.Model.FluentLogicalDeleteFilter.FilterName); return(session); }
public static ILogger GetLogger(Ninject.Activation.IContext context) { return(new CompositeLogger(new List <ILogger>() { context.Kernel.Get <AgentLogger>(), context.Kernel.Get <DatabaseLogger>() })); }
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); }
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); }
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) }); }
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)); }
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() }); }
public static IMapper AutoMapper(Ninject.Activation.IContext context) { Mapper.Initialize(x => { x.AddProfile <EmployeeProfile>(); }); Mapper.AssertConfigurationIsValid(); // optional return(Mapper.Instance); }
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); }
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)); }
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); }
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; }
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()); }
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); }
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); }
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); }
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); }
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); }
/* * 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; }
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); }
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); }
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)); }
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); }
//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); }