protected void Application_Start() { DependencyInjection.ConfigureContainer(); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); }
/// <summary> /// Initializes a new instance of the <see cref="MediaModelBinder"/> class. /// </summary> public MediaModelBinder() : base(DependencyInjection.Resolve <IUserAuthorization>()) { }
public OAuth2UserIdentity SignUpUser(OAuth2UserIdentity entity) { using (IEntityContext context = DependencyInjection.Get<IEntityContext>()) { using (IOAuth2UserRepository repository = DependencyInjection.Get<IOAuth2UserRepository>(InjectionParameter.Create("context", context))) { IList<OAuth2Scope> scopes = repository.Context.Query<OAuth2Scope>() .Where(x => x.Code == "application.role.user.default") .List(); bool isValidIdentifier = this.IsValidEmail(entity.User.Identifier); if (isValidIdentifier) { OAuth2User user = new OAuth2User(); user.ID = Guid.NewGuid(); user.Identifier = entity.User.Identifier; user.Password = entity.User.Password; user.CreationTimestamp = DateTime.UtcNow; user.ValidFrom = DateTime.UtcNow; user.ValidUntil = new DateTime(DateTime.Parse("2100-01-01").Ticks, DateTimeKind.Utc); repository.Context.AddOrUpdate(user); Identity identity = new Identity(); identity.ID = Guid.NewGuid(); identity.FirstName = entity.Identity.FirstName; identity.Name = entity.Identity.Name; identity.Locale = entity.Identity.Locale; repository.Context.AddOrUpdate(identity); OAuth2UserScope userScope = new OAuth2UserScope(); userScope.ID = Guid.NewGuid(); userScope.Scope = scopes.Single(); userScope.User = user; userScope.CreationTimestamp = DateTime.UtcNow; userScope.ValidFrom = DateTime.UtcNow; userScope.ValidUntil = new DateTime(DateTime.Parse("2100-01-01").Ticks, DateTimeKind.Utc); repository.Context.AddOrUpdate(userScope); OAuth2UserIdentity userIdentity = new OAuth2UserIdentity(); userIdentity.ID = Guid.NewGuid(); userIdentity.User = user; userIdentity.Identity = identity; userIdentity.CreationTimestamp = DateTime.UtcNow; userIdentity.ValidFrom = DateTime.UtcNow; userIdentity.ValidUntil = new DateTime(DateTime.Parse("2100-01-01").Ticks, DateTimeKind.Utc); repository.Context.AddOrUpdate(userIdentity); } else { throw new Exception("Invalid e-mail address."); } } context.Commit(); } Domain.Entity.OAuth2UserIdentity _entity = this.GetUserIdentity(entity.User.Identifier); return _entity; }
public KeyFramesOrderer(IKeyFramesScroll keyFramesScroll) { _keyFramesScroll = keyFramesScroll; _settings = DependencyInjection.Resolve <IReadOnlySettings>(); }
public static void Run() { DependencyInjection.SetSimpleInjectorContainer(); //Configure AutoMapper AutoMapperConfiguration.InitializeAutoMapper(); }
public void ConfigureServices(IServiceCollection services) { DependencyInjection.Setup(new ConfigurationBuilder().AddEnvironmentVariables().Build(), services); services.AddHostedService <DataDeploymentBackgroundSync>(); }
/// <summary> /// Creates a new <see cref="NamedDependenciesCommand{T}"/> /// </summary> /// <param name="options">The options for the command.</param> public SyncCommand(SyncSubOptions options) : base(options) { _factory = DependencyInjection.Resolve <IGitDependFileFactory>(); _git = DependencyInjection.Resolve <IGit>(); _fileSystem = DependencyInjection.Resolve <IFileSystem>(); }
public static void RegisterServices(IServiceCollection services) { DependencyInjection.RegisterServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Register the Swagger generator, defining 1 or more Swagger documents _ = services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "Mobile Contact API", Description = "Web Api for MC application", Contact = new OpenApiContact { Name = "MC - Mobile Contacts", Email = "*****@*****.**" }, License = new OpenApiLicense { Name = "Use under MC", } }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "MC Authorization header using the Bearer scheme.", Name = "Authorization", In = ParameterLocation.Header, Scheme = "bearer", Type = SecuritySchemeType.Http, BearerFormat = "MC" }); c.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } }, new List <string>() } }); // Set the comments path for the Swagger JSON and UI. string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); DependencyInjection.Inject(services); // Cors Enable for everything // TODO: change this when finished _ = services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .WithExposedHeaders("X-Total-Count")); }); _ = services.AddDbContext <MCContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MCDb"), sqlOptions => sqlOptions.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null))); _ = services.AddControllers(options => options.Filters.Add(typeof(ValidationFilterAttribute))) .AddNewtonsoftJson() .AddFluentValidation(fv => { _ = fv.RegisterValidatorsFromAssemblyContaining <IBaseDTO>(); fv.RunDefaultMvcValidationAfterFluentValidationExecutes = false; }); }
public APIMethodTestor() { DependencyInjection.InjectTypes(); }
public void DIInit() { var provider = DependencyInjection.Init(Consts.TestConnectionString); Assert.IsNotNull(provider); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Prototype API", Version = "v1" }); }); #region Token services.AddAuthorization(auth => { auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder() .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser().Build()); }); services.AddDbContext <PrototypeDataContext>(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))); var key = Encoding.ASCII.GetBytes(Configuration.GetSection("TokenConfig:HashKey").Value); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => { options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = "prototype", ValidAudience = "prototype", IssuerSigningKey = new SymmetricSecurityKey(key) }; options.Events = new JwtBearerEvents { OnAuthenticationFailed = context => { Console.WriteLine("Token Inválido...:" + context.Exception.Message.ToString()); return(Task.CompletedTask); }, OnTokenValidated = context => { Console.WriteLine("Token válido...:" + context.SecurityToken); return(Task.CompletedTask); } }; }); #endregion DependencyInjection.ResoluteDependencies(services); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddMvc().AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddResponseCompression(); services.AddHttpContextAccessor(); }
public SaveButton() : base(200, 5) { _settings = DependencyInjection.Resolve <IReadOnlySettings>(); _characterDefinition = DependencyInjection.Resolve <CharacterDefinition>(); }
public DependencyInjectionConfig(string functionName) { DependencyInjection.Initialize(RegisterModules, functionName); }
static void Main(string[] args) { Provider = DependencyInjection.SetUpDependencyInjection(SetUpExternalDependencyInjection); Provider.GetRequiredService <Startup>().Run(); }
public LedgesLoader() { _mapData = DependencyInjection.Resolve <IMapData>(); }
/// <summary> /// Hyperlinks the tags. /// </summary> /// <param name="tags">The tags.</param> /// <param name="username">The username.</param> /// <returns></returns> public string HyperlinkTags(string tags, string username) { ITagService tagService = DependencyInjection.Resolve <ITagService>(); return(tagService.HyperlinkTheTags(tags, username)); }
/// <summary> /// Creates a new <see cref="CloneCommand"/> /// </summary> /// <param name="options">The <see cref="CloneSubOptions"/> that configure this command.</param> public CloneCommand(CloneSubOptions options) { _options = options; _algorithm = DependencyInjection.Resolve <IDependencyVisitorAlgorithm>(); _console = DependencyInjection.Resolve <IConsole>(); }
private IEnumerator RunTutorial(int skips) { while (SceneIntermediary.LOADING) { yield return(null); } bool canSkip() => skips-- > 0; IEnumerator wait(Func <bool> cond) { if (!canSkip()) { while (!cond()) { yield return(null); } } } IEnumerator waitlf(Func <bool> cond) => wait(() => ETime.FirstUpdateForScreen && cond()); IEnumerator waiti(IInputHandler ih) { yield return(null); yield return(waitlf(() => ih.Active)); } IEnumerator waitir(IInputHandler ih) { yield return(null); yield return(waitlf(() => !ih.Active)); } IEnumerator confirm() => waiti(UIConfirm); DependencyInjection.Find <IUIManager>().SetSpellname("Tutorial"); Message(text10, welcome1(UIConfirm.Desc)); yield return(confirm()); Prompt(text10, blue2(Pause.Desc)); yield return(waitlf(() => EngineStateManager.IsPaused)); UIManager.PauseMenu !.GoToOption(0); const float menuLeft = -4.8f; Message(text00, pause3, x: menuLeft); yield return(confirm()); Message(text00, shaders4, x: menuLeft); yield return(confirm()); Prompt(text00, shaders5, 1.2f, x: menuLeft); var sd = SaveData.s.Shaders; yield return(waitlf(() => SaveData.s.Shaders != sd)); Prompt(text00, res6, 0.85f, x: menuLeft); var r = SaveData.s.Resolution; yield return(waitlf(() => SaveData.s.Resolution != r)); Message(text00, refresh7, 0.5f, x: menuLeft); yield return(confirm()); Message(text00, fullscreen8, 0.15f, x: menuLeft); yield return(confirm()); Message(text00, vsync9, -0.25f, x: menuLeft); yield return(confirm()); Message(text00, inputsmooth10, -0.7f, x: menuLeft); yield return(confirm()); Prompt(text00, unpause11(Pause.Desc), x: menuLeft); yield return(waitlf(() => !EngineStateManager.IsLoadingOrPaused)); var mov = new Movement(new Vector2(-2, 2.5f), 0); BulletManager.RequestSimple("lcircle-red/", _ => 4f, null, mov, new ParametricInfo(in mov)); var nrx = new RealizedLaserOptions(new LaserOptions(), GenCtx.New(this, V2RV2.Zero), FiringCtx.New(), new Vector2(3, 5), V2RV2.Angle(-90), Cancellable.Null); mov = new Movement(new Vector2(2, 5), -90); BulletManager.RequestLaser(null, "mulaser-blue/b", mov, new ParametricInfo(in mov), 999, 0, ref nrx); mov = new Movement(new Vector2(3, 5), -90); BulletManager.RequestLaser(null, "zonelaser-green/b", mov, new ParametricInfo(in mov), 999, 0, ref nrx); "sync _ <> relrect greenrect level <-2;2.5:1.4;1.4:0> witha 0.7 green".Into <StateMachine>() .Start(new SMHandoff(this)); Message(text10, redcircle12); yield return(confirm()); Message(text10, legacy13); yield return(confirm()); Message(text10, safelaser14); yield return(confirm()); BulletManager.ClearAllBullets(); BehaviorEntity.GetExecForID("greenrect").InvokeCull(); Prompt(text10, fire15(ShootHold.Desc)); yield return(waitir(ShootHold)); yield return(waiti(ShootHold)); Prompt(text10, move16); yield return(waitlf(() => Math.Abs(HorizontalSpeed01) > 0.1 || Math.Abs(VerticalSpeed01) > 0.1)); Prompt(text10, focus17(FocusHold.Desc)); yield return(waiti(FocusHold)); var bcs = new Cancellable(); var boss = GameObject.Instantiate(tutorialBoss).GetComponent <BehaviorEntity>(); boss.Initialize(SMRunner.CullRoot(StateMachine.CreateFromDump(bossSM.text), bcs)); IEnumerator phase() { while (boss.PhaseShifter == null) { yield return(null); } var pct = boss.PhaseShifter; if (canSkip()) { boss.ShiftPhase(); } else { yield return(wait(() => pct.Cancelled)); } for (int ii = 0; ii < 244; ++ii) { yield return(null); //phase delay if (EngineStateManager.IsRunning) { ++ii; } } } IEnumerator shift() { boss.ShiftPhase(); for (int ii = 0; ii < 4; ++ii) { yield return(null); //phase delay } } for (int ii = 0; ii < 8; ++ii) { yield return(null); //start delay } Message(text10, boss18); yield return(confirm()); Message(text10, hpbar19); yield return(confirm()); yield return(shift()); Prompt(text10, ns20); yield return(phase()); Prompt(text10, nss21); yield return(phase()); Prompt(text10, spell22); yield return(phase()); Prompt(text10, survival23); yield return(phase()); Message(text10, items24); yield return(confirm()); Message(text10, bullets25); yield return(confirm()); yield return(shift()); Prompt(text10, shoot26); yield return(phase()); Message(text10, lives27, 0.3f); yield return(confirm()); Instance.SetLives(10); Message(text10, dots28); yield return(confirm()); Instance.SetLives(15); Message(text10, dots29); yield return(confirm()); Instance.SetLives(1); Message(text10, dots30); yield return(confirm()); Message(text10, nobombs31); yield return(confirm()); yield return(shift()); Prompt(text10, pleasedie32); yield return(waitlf(() => EngineStateManager.IsDeath)); Prompt(text00, deathscreen33, x: menuLeft); yield return(waitlf(() => !EngineStateManager.IsDeath)); yield return(shift()); Message(text10, lifeitems34, -0.3f); yield return(confirm()); yield return(shift()); Prompt(text10, lifeitems35); int currLives = Instance.Lives; yield return(waitlf(() => Instance.Lives > currLives)); yield return(shift()); Message(text10, valueitems36(InstanceData.valueItemPoints)); yield return(confirm()); yield return(shift()); Prompt(text10, points37); yield return(waitlf(() => Instance.Score > 75000)); yield return(shift()); Message(text00, scoremult38); yield return(confirm()); Message(text00, faith39(InstanceData.pivFallStep)); yield return(confirm()); Message(text00, faithblue40); yield return(confirm()); Message(text10, graze41); yield return(confirm()); yield return(shift()); Prompt(text10, scoremult42); yield return(waitlf(() => Instance.PIV >= 1.11)); yield return(shift()); yield return(waitlf(() => Instance.PIV <= 1.0)); Message(text10, scoreext43); yield return(confirm()); yield return(shift()); Prompt(text10, scoreext44); yield return(waitlf(() => Instance.Score > 2000000)); yield return(shift()); Message(text10, ability45); yield return(confirm()); yield return(shift()); Prompt(text10, ability46(Meter.Desc)); GameManagement.Instance.AddGems(100); yield return(waitlf(() => InputManager.IsMeter)); yield return(shift()); Message(text10, ability47); yield return(confirm()); Message(text10, meter48); yield return(confirm()); yield return(shift()); Message(text10, hitbox49); yield return(confirm()); yield return(shift()); Message(text10, hitbox50); yield return(confirm()); yield return(shift()); Message(text10, safelaser51); yield return(confirm()); yield return(shift()); Prompt(text10, end52); SaveData.r.CompleteTutorial(); }
/// <summary> /// Initializes a new instance of the <see cref="ManagePhotoBase"/> class. /// </summary> /// <param name="user">The user.</param> /// <param name="authorization">The authorization.</param> protected ManagePhotoBase(Domain.Model.User user, Authorization authorization) : this(UserUrlService.GetInstance(authorization.Owner), user, DependencyInjection.Resolve <IMediaRepository>(), DependencyInjection.Resolve <ITagRepository>(), DependencyInjection.Resolve <IPaginationService <Media> >(), authorization) { }
public Bootstrapper(string functionName) { DependencyInjection.Initialize(builder => { builder.RegisterType <OrderProcessor>().As <IOrderProcessor>(); }, functionName); }
// this is another explicit option public void AddToDatabase(MyType object) { IRepository dbRep = DependencyInjection.GiveMeDatabaseRepository <IRepository>(); dbRep.Add(object); }
public DatabaseUnitOfWorkTest() { DependencyInjection.RegisterServices(); DependencyInjection.AddDbContextInMemoryDatabase <DatabaseContext>(); DatabaseUnitOfWork = DependencyInjection.GetService <IDatabaseUnitOfWork>(); }
/// <summary> /// Creates a new <see cref="CreateBranchVisitor"/> /// </summary> /// <param name="branchName">The branch name to create.</param> public CreateBranchVisitor(string branchName) { BranchName = branchName; _git = DependencyInjection.Resolve <IGit>(); _console = DependencyInjection.Resolve <IConsole>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { DependencyInjection.RegisterDependencies(services); services.AddRazorPages(); }
/// <summary> /// Creates a new <see cref="Nuget"/> /// </summary> public Nuget() { _processManager = DependencyInjection.Resolve <IProcessManager>(); }
/// <summary> /// This injects the current assembly into the DependencyImplementationSelector /// </summary> protected override void ConfigureDependencyImplentationSelector(DependencyInjection.ImplementationSelector defaultImplementationSelector) { base.ConfigureDependencyImplentationSelector(defaultImplementationSelector); defaultImplementationSelector.AddAssembly(typeof(ODataUnitTestModule).Assembly); }
public FileFeedReader(ICacheStorage cacheStorage) { this.CacheStorage = cacheStorage; this.FilterFeedResult = DependencyInjection.Instance().Container.Resolve <IFilterFeedResult>("FilterCountriesFeedResult"); }