public User(User tmp) { Username = tmp.Username; Email = tmp.Email; Password = tmp.Password; RegisterAs = tmp.RegisterAs; }
public Injector() { this.Container = new ServiceContainer(); this.Container.SetDefaultLifetime <PerContainerLifetime>(); Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .MinimumLevel.Debug() .WriteTo.Debug() .CreateLogger(); this.Container.RegisterInstance(Log.Logger); this.Logger = Log.Logger; Resolve resolveDelegate = type => this.Container.GetInstance(type); this.Container.RegisterInstance(resolveDelegate); Register registerDelegate = o => this.Container.RegisterInstance(o.GetType(), o); this.Container.RegisterInstance(registerDelegate); RegisterAs registerAsDelgate = (o, t) => this.Container.RegisterInstance(t, o); this.Container.RegisterInstance(registerAsDelgate); this.RegisterTypesFromAssembliesInWorkingDirectory(); }
public GameBootstrapper(Register registerDelegate, RegisterAs registerAsDelegate, Func <GameLoop> gameLoopFactory) { this.RegisterDelegate = registerDelegate; this.RegisterAsDelegate = registerAsDelegate; this.GameLoopFactory = gameLoopFactory; this.Graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = 1920, PreferredBackBufferHeight = 1080, PreferredBackBufferFormat = SurfaceFormat.ColorSRgb, PreferMultiSampling = false, SynchronizeWithVerticalRetrace = true, GraphicsProfile = GraphicsProfile.HiDef }; this.Content.RootDirectory = "Content"; this.IsMouseVisible = true; }
private async Task FillRegistrationDataAsync(RegisterAs registerAs) { ExternalLogins = (await signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); RegisterAs = registerAs; if (RegisterAs == RegisterAs.NGO) { AvailableServices = applicationDbContext.Services.Select(x => new SelectListItem() { Value = x.ID.ToString(), Text = x.Name }).ToList(); AvailableCategories = applicationDbContext.Categories.Select(x => new SelectListItem() { Value = x.ID.ToString(), Text = x.Name }).ToList(); } else if (RegisterAs == RegisterAs.Volunteer) { AvailableNGOs = applicationDbContext.NGOs.Select(o => new SelectListItem { Value = o.ID.ToString(), Text = o.Name }).ToList(); } }
public static void RegisterTypes <T>(this IServiceCollection services, Assembly[] assembly, RegisterAs registerAs) { assembly.ToList() .ForEach(service => services.RegisterTypes <T>(service, registerAs)); }
public static int RegisterTypes <T>(this IServiceCollection services, Assembly assembly, RegisterAs registerAs, bool throwErrorOnNonFound = true) { var types = assembly.GetTypesThatImplement <T>().ToList(); if (throwErrorOnNonFound && types.Any() == false) { throw new InvalidOperationException($"No implementations found for {typeof(T).Name}"); } var serviceType = typeof(T); if (registerAs == RegisterAs.AsScoped) { types.ForEach(x => services.AddScoped(serviceType, x)); } if (registerAs == RegisterAs.AsSingleton) { types.ForEach(x => services.AddSingleton(serviceType, x)); } if (registerAs == RegisterAs.AsTransient) { types.ForEach(x => services.AddTransient(serviceType, x)); } return(types.Count()); }