小编MJK*_*MJK的帖子

实体与聚合与聚合根

我正在努力识别Domain对象.

问题:

  • 公司有一个或多个站点
  • 网站有主要和多个联系人
  • 因此,公司有一个或多个联系人.这些联系人分配给站点.
  • 必须将联系人添加到站点而不是公司

我的理解:

public class Company : IEntity
    {
         public int CompanyId {get;}
         public string CompanyName {get;}
         //.....
    }

    public class Site : IEntity
    {
         public int SiteId {get;}
         public string SiteName {get;}
         //.....
    }

    public class Contact : IEntity
    {
        public int ContactId {get;}
        public string SurName {get;}
        public bool MainSiteContact {get;}//Confused!! May be this is not the right place
         //.....
    }

    public class SiteContact : IAggregate
    {
        public Site ASite { get; }
        public …
Run Code Online (Sandbox Code Playgroud)

c# entity domain-driven-design aggregate aggregateroot

3
推荐指数
1
解决办法
3555
查看次数

Swagger .NETCORE无法读取json

我在使用.netcore时遇到麻烦。我已经尝试了一切,什么也没做。我看到了另一个类似的问题,但对我没有任何帮助。使用swagger运行我的webapi应用程序,始终返回“无法从http:// localhost:5000 / api / swagger / v1 / swagger.json读取swagger JSON ”。

我的代码:

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddApplicationInsightsTelemetry(Configuration);
    services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin()
                                                                .AllowAnyMethod()
                                                                .AllowAnyHeader()));
    services.AddMvc();
    services.AddSwaggerGen();

    services.ConfigureSwaggerGen(options =>
    {
        var info = new Info
        {
            Version = "v1",
            Title = "Web API Multiprodutos",
            Description = "Web API Multiprodutos",
            Contact = new Contact { Name = "Marcos Monte", Url = "www.arrowbus.com.br" }
        };

        options.SingleApiVersion(info);

        string caminhoAplicacao = AppContext.BaseDirectory;
        string nomeAplicacao =
            PlatformServices.Default.Application.ApplicationName; …
Run Code Online (Sandbox Code Playgroud)

.net json asp.net-web-api swagger .net-core

3
推荐指数
2
解决办法
5417
查看次数

IdentityServer4客户端-刷新CookieAuthenticationEvents上的访问令牌

访问令牌过期时,我正在尝试使用刷新令牌。这里也回答类似的问题。还有一个示例代码,通过操作来更新令牌

我最终在startup.cs中获得以下代码

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationScheme = "Cookies",
    //ExpireTimeSpan = TimeSpan.FromSeconds(100),
    AutomaticAuthenticate = true,
    AutomaticChallenge = true,
    Events = new CookieAuthenticationEvents()
    {
        OnValidatePrincipal = async x =>
        {
            if (x.Properties?.Items[".Token.expires_at"] == null) return;

            var logger = loggerFactory.CreateLogger(this.GetType());

            var now = DateTimeOffset.UtcNow;
            var tokenExpireTime = DateTime.Parse(x.Properties.Items[".Token.expires_at"]).ToUniversalTime();
            var timeElapsed = now.Subtract(x.Properties.IssuedUtc.Value);
            var timeRemaining = tokenExpireTime.Subtract(now.DateTime);

            if (timeElapsed > timeRemaining)
            {
                var httpContextAuthentication = x.HttpContext.Authentication;//Donot use the HttpContext.Authentication to retrieve anything, this cause recursive call to …
Run Code Online (Sandbox Code Playgroud)

authentication cookies identityserver4 asp.net-core-middleware

3
推荐指数
1
解决办法
1439
查看次数

当有2个或更多递归函数写入togeather时程序是如何执行的?

如何return((count-2)+(count-1))在以下cpp程序中运行?给定代码的ans 是-18.如何在不运行代码的情况下知道ans并且从两个中调用function count(n-2),count(n-1)哪个首先被调用,如何确定?

#include <iostream>
using namespace std;
int count(int n);
int main() {
    int n, m;
    n = 4;
    m = count(n);
    cout << m;
}

int count(int n)
{
    if (n<0)
    {
        return n;
    }
    else
    {
        return (count(n - 2) + count(n - 1));
    }
}
Run Code Online (Sandbox Code Playgroud)

c++ recursion function

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