小编jo1*_*jo1的帖子

如何在 ASP.NET CORE API 中添加服务依赖项

我是 ASP.NET CORE API 的新手,所以请坦白我有限的理解。我正在学习依赖注入,并尝试在启动类中注册我的服务。但是我注意到我的一项服务通过构造函数依赖于另一项服务。如何在配置服务方法中传递它。

我是否只是“新建”依赖类并将其添加到构造函数中。

这是我在启动类中的实现:

public void ConfigureServices(IServiceCollection services)
{

services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "TestAPI", Version = "v2" });
});

services.AddSingleton<IAdminRepository>(new AdminRepository());
services.AddSingleton<IAdminService>(new AdminService(need to add dependancy here));
}
Run Code Online (Sandbox Code Playgroud)

这是我的服务类中的实现:

private IAdminRepository _adminRepository;

public AdminService(IAdminRepository adminRepository)
{
_adminRepository = adminRepository;
}
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net asp.net-core asp.net-core-webapi

0
推荐指数
1
解决办法
2522
查看次数

键盘使用 ionic 将内容向上推送

我是 ionic 新手,正在设计一个登录页面。但是我注意到,当我将应用程序部署到 ios 设备时,当单击/按下输入字段时,本机 ios 键盘会将内容向上推。

我一直在试图找出如何解决这个问题,但我没有运气。我目前正在使用最新的离子框架。

有没有办法确保内容不被推送?

这是我的登录 html:

<ion-content class="background" [fullscreen]="true" slot="fixed">
  <h1 class="login-title-text">ign you in</h1>
  <p class="login-subtitle-text">Welcome back!</p>

  <div class="inputs">
    <ion-input class="item-input" type="email" placeholder="Email"></ion-input>
    <ion-input class="item-input" type="password" placeholder="Password"></ion-input>
  </div>
</ion-content>

<ion-footer>
  <ion-button color="dark" expand="block">Login</ion-button>
  <ion-button color="dark" expand="block">Forgot Password</ion-button>
  <ion-button color="dark" expand="block">Register</ion-button>
</ion-footer>
Run Code Online (Sandbox Code Playgroud)

这是我的 scss:

ion-content {
    --keyboard-offset: 0px;
  }
  
.background {
    --background: url("/assets/img/background.jpg") no-repeat fixed center;
}

.login-title-text {
    font-weight: bold;
    font-size: 28px;
    padding: 50px 0 20px 30px;
}

.login-subtitle-text {
    font-size: 18px;
    padding: 10px 0 …
Run Code Online (Sandbox Code Playgroud)

javascript hybrid-mobile-app ionic-framework angular

0
推荐指数
1
解决办法
3792
查看次数