小编Pav*_*ski的帖子

对测试用户进行身份验证{“ error_type”:“ OAuthException”,“ code”:400,“ error_message”:“无效的平台应用程序”}

我正在尝试通过Instagram基本显示API恢复访问令牌,但是在尝试对测试用户进行身份验证时出现此错误:

{
    "error_type": "OAuthException",
    "code": 400,
    "error_message": "Invalid platform app"
}
Run Code Online (Sandbox Code Playgroud)

我希望看到应用授权屏幕

facebook-graph-api-v2.0 instagram-api

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

几何图形有太多边缘(Google Earth Engine)。帮我

在此输入图像描述

我在使用 Google Earth Engine 时遇到问题。我正在处理一些矢量文件。我得到以下代码:

google-earth-engine

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

从字典值到 IEnumerable 的 Concat 列表

我有一个Dictionary<int, list<T>>并且想要得到一个IEnumerable<T>,它允许我遍历字典中所有列表的所有元素。这当然应该避免处理所有元素和其他性能成本高的操作。

我对 Linq 的处理方式不太正确:

IEnumerable<T> enumerable = dict.SelectMany(list).Foreach(list.ConcatAll()).ToEnum();
Run Code Online (Sandbox Code Playgroud)

如果Linq不是最佳方式,请提出其他选择。

.net c# linq dictionary

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

从 T1 列表中创建 T2 列表,使用需要 T1 的 T2 构造函数

如果我得到一个Type1来自方法的列表GetType1List

List<Type1> Type1List = GetType1List();
Run Code Online (Sandbox Code Playgroud)

然后我可以创建一个列表Type2并循环遍历第一个列表foreachType2使用它的构造函数添加新的,它需要一个Type1实例:

List<Type2> Type2List = new List<Type2>();
foreach(Type1 type1 in Type1List)
{
    Type2List.Add(new Type2(Type1));
}
Run Code Online (Sandbox Code Playgroud)

有什么办法可以在不创建循环Type1和没有foreach循环的初始列表的情况下完成它?

.net c# list

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

是否有同时包含 List&lt;T&gt; 和 HashSet&lt;T&gt; 的类型?

我有两种显示方法:一种是项目列表,另一种是项目的 HashSet。方法是一样的。有没有办法用参数类型编写方法,这样我就可以使用相同的方法,而不管传递给方法的参数是什么类型:List<T>HashSet<T>

方法是:

    public static void DisplayList<T>(List<T> list)
    {
        int i = 0;
        foreach (T item in list)
        {
            Console.Write(item.ToString());
            if (i < list.Count - 1)
            {
                Console.Write(", ");
            }
            i++;
        }
        Console.WriteLine();
    }

    public static void DisplayHashSet<T>(HashSet<T> set)
    {
        int i = 0;
        foreach (T item in set)
        {
            Console.Write(item.ToString());
            if (i < set.Count - 1)
            {
                Console.Write(", ");
            }
            i++;
        }
        Console.WriteLine();
    }
Run Code Online (Sandbox Code Playgroud)

.net c# list hashset

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

在 .Net Core 3.1 的 2.0 版中找不到 MahApps ToggleSwitch 属性

我创建了一个新的 .Net Core 3.1 WPF 应用程序。我为 MahApps.Metro v 2.0.0-alpha0748 添加 nuget 包

我在 xaml 中添加了一个切换开关

<Window x:Class="WpfTestSandbox.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfTestSandbox"
    xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
    <Grid>
        <mah:ToggleSwitch Header="WiFi rest state"
            Ischecked="True" />
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

这是我的 App.xaml

<Application x:Class="WpfTestSandbox.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:WpfTestSandbox"
         StartupUri="MainWindow.xaml">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <!-- Accent and AppTheme setting -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/dark.green.xaml" />
            <ResourceDictionary>
                <SolidColorBrush x:Key="{x:Static SystemColors.WindowTextBrushKey}" …
Run Code Online (Sandbox Code Playgroud)

wpf mahapps.metro .net-core

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

使用 Linq 将一本字典映射到另一本字典

Dictionary在 .NET 框架中是否有一种使用 Linq将一个映射到另一个的优雅方法?

这可以通过枚举来完成foreach

var d1 = new Dictionary<string, string>() {
    { "One", "1" },
    { "Two", "2" }
};

// map dictionary 1 to dictionary 2 without LINQ
var d2 = new Dictionary<string, int>();
foreach(var kvp in d1) {
    d2.Add(kvp.Value, int.Parse(kvp.Value));
}
Run Code Online (Sandbox Code Playgroud)

...但我正在寻找某种方式来完成 LINQ:

// DOES NOT WORK
Dictionary<string, int> d2 =
    d1.Select(kvp => {
        return new KeyValuePair<string, int>(kvp.Key, int.Parse(kvp.Value));
    })
Run Code Online (Sandbox Code Playgroud)

.net c# linq dictionary

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

c# - 将 list&lt;string&gt; 转换为字符串 - 但节省结构

我尝试将列表转换为字符串。但我遇到错误,我尝试这样做,但时间太长了,我需要你的帮助

我想做什么:

List<string> list = new List<string> {"a","a","a" };
Run Code Online (Sandbox Code Playgroud)

我想得到这样的字符串:

我的字符串将等于:

"["a","a","a"]" 
Run Code Online (Sandbox Code Playgroud)

我怎么能在一行中做到这一点?

谢谢!!!!!!

c# string list

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

是否可以在同一个 T 上使用通用的“in”和“out”修饰符?

此代码无效,因为 T 不能同时具有 in 和 out 修饰符:

public interface IInOut<in out T>
{

}
Run Code Online (Sandbox Code Playgroud)

但是您可以执行此“解决方法”:

public interface IInOutWorkaround<in TIn, out TOut>
{
    TOut Test(TIn value);
}

public class InOutWorkaround<T> : IInOutWorkaround<T, T>
{
    public T Test(T value)
    {
        throw new NotImplementedException();
    }
}
Run Code Online (Sandbox Code Playgroud)

第二个示例有效并且 InOutWorkaround 类对于 TIn 和 TOut 具有相同的类型,那么为什么不能直接在接口中将这两个修饰符添加到同一个 T 中呢?或者是否可以使用不同的语法?

c# generics interface

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

TestMethod 未在 c# 中运行

我有以下测试类:

using System;
using DDDSample1.Domain.DriverDuties;
using DDDSample1.Domain.Shared;
using DDDSample1.Controllers;
using System.Collections.Generic;
using Moq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IntegrationTests
{
    public class DriverDutyControllerTest
    {
        [TestMethod]
        public async void GetByIdTest()
        {
            var repo = new Mock<IDriverDutyRepository>();
            var unitOfWork = new Mock<IUnitOfWork>();

            var service = new DriverDutyService(unitOfWork.Object, repo.Object);
            var controller = new DriverDutiesController(service);

            DriverDutyId id = new DriverDutyId("id1");
            string key = "keyDD1";
            string driver = "DriverDD";
            List<String> workblocks = new List<String>();
            workblocks.Add("wb1");
            workblocks.Add("wb2");
            workblocks.Add("wb3");

            var ddDto = new CreatingDriverDutyDto(key, driver, workblocks.ToArray());
            var dd = …
Run Code Online (Sandbox Code Playgroud)

.net c# testing integration-testing

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