小编Hes*_*efi的帖子

使用C#中的反射反序列化Json

我想使用以下方法使用Newtonsoft.Json进行反射:

MyType object = JsonConvert.DeserializeObject<MyType>(jsonString);
Run Code Online (Sandbox Code Playgroud)

这是我的方法不起作用(模糊匹配异常):

Type type = Type.GetType("MyType",false);
Type JSONCovert = typeof(JsonConvert);
MethodInfo deserializer = JSONCovert.GetMethod("DeserializeObject", new Type[] { typeof(String) });
deserializer = deserializer.MakeGenericMethod(type);
var o = deserializer.Invoke(null, new object[] { JsonString });
Run Code Online (Sandbox Code Playgroud)

c# reflection json json.net deserialization

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

使用 OpenIddict 登录外部提供商获取 Token

我有一个带有 ASP.NET Core 的 API,它将由本机移动应用程序(当前是 UWP、Android)使用,我正在尝试实现一种客户端可以使用用户名/密码和外部提供商(例如谷歌和脸书。现在我正在使用openIddict并且我ExternalProviderCallback必须返回本地令牌,我假设当前返回cookie!(我已经从某处复制了大部分代码)而且它似乎不是我认为正确的方法的 AuthorizationCodeFlow !

现在这是我的启动课程

public class Startup
{
    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

        if (env.IsDevelopment())
        {
            builder.AddUserSecrets();
        }
        builder.AddEnvironmentVariables();
        Configuration = builder.Build();
    }

    public IConfigurationRoot Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSingleton<IConfiguration>(c => Configuration);
        services.AddEntityFramework();
        services.AddIdentity<ApplicationUser, IdentityRole>(config => …
Run Code Online (Sandbox Code Playgroud)

authentication google-authentication oauth-2.0 asp.net-core openiddict

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