小编Bry*_*ump的帖子

如何使用material-ui @ next MenuItem进行路由?

使用实施路由的最佳实践是material-ui@next什么?在以前的版本中,我可以使用containerElementLink但不再起作用。在文档中找不到任何帮助。

 <MenuItem containerElement={<Link to="/myRoute" />}>My Link</MenuItem>
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui react-router-dom

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

自定义异常作为聚合异常抛出

从Task.Run(...)。Result引发自定义异常时,catch块将找到AggregateException而不是CustomException。为什么?

   public MainPage()
    {
        this.InitializeComponent();
        CallAMethod();
    }

    static bool AMethod()
    {
        return Task.Run(() =>
        {
            throw new CustomException();
            return false;
        }).Result;
    }

    static bool CallAMethod()
    {
        try
        {
            return AMethod();

        }
        catch (CustomException e)
        {
            //not caught
            throw;
        }
        catch (Exception ex)
        {
            //caught?
            throw;
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是自定义Exception类

class CustomException : Exception
{

}
Run Code Online (Sandbox Code Playgroud)

.net c# windows-runtime winrt-async windows-store-apps

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

两个xAxes水平条形图Charts.js

我正在努力通过Charts.js和两轴水平条形图获得正确的xAxis设置。JsFiddle链接在下面。麻烦的是,我试图在同一张图表中显示两个不同的比例。一个是高数字(价格),另一个是低数字(数量)。

https://jsfiddle.net/clevelandbuckeye/Luaf2tm4/533/

我在options属性中使用了第二个x轴,但是标签显示为月,而不是数量!数量如何显示?

<canvas id="myChart" width="400" height="200"></canvas>
<script>
var canvas = document.getElementById('myChart');
var data = {
  labels: ["January", "February", "March", "April", "May", "June", "July"],
  datasets: [{
    label: "# Deals",
    backgroundColor: "rgba(255,99,132,0.2)",
    borderColor: "rgba(255,99,132,1)",
    borderWidth: 2,
    hoverBackgroundColor: "rgba(255,99,132,0.4)",
    hoverBorderColor: "rgba(255,99,132,1)",
    data: [15, 19, 5, 16, 1, 12, 8],
      xAxisID:'x1',
  }, {
    label: "$Money",
    backgroundColor: "rgba(55,99,132,0.2)",
    borderColor: "rgba(255,99,132,1)",
    borderWidth: 1,
    hoverBackgroundColor: "rgba(55,99,132,0.4)",
    hoverBorderColor: "rgba(255,99,132,1)",
    data: [265, 459, 320, 181, 456, 555, 1040]
  }]
};
var option = {
    scales: {
      yAxes: [{ …
Run Code Online (Sandbox Code Playgroud)

chart.js

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

实体框架核心重用一组包含语句

如何清理我的实体“包含”以重用同一组语句?我试图在保持 DRY 的同时重用一组 Includes。

_context.Accounts
              .Include(x=> x.Status)
              .Include(x=> x.Type)
              .Include(x=> x.Phones)
              .Include(x=> x.Users)
              .Include(x=> x.Admins)
Run Code Online (Sandbox Code Playgroud)

后:

_context.Accounts.CustomIncludes()
Run Code Online (Sandbox Code Playgroud)

ef-core-2.0 ef-core-2.1

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

读取文本文件 aws-amplify s3 从预先签名的 URL 读取数据

如何使用 aws-amplify 库读取 s3 中的文本文件?我能够获取预先签名的 URL,但在访问该 url 时出现错误,

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>
private/xx-xxxx-4:42134231243423142131423/filename.json
</Key>
<RequestId>1242341243</RequestId>
<HostId>
 uudawfeawefhszec/6kM8VawefawefawfawefawefgwegweawgeagweyRk=
</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)

文档有关于如何获取 url 的说明:

Storage.get('test.txt', {level: 'private'})
  .then(result => console.log(result))
  .catch(err => console.log(err));
Run Code Online (Sandbox Code Playgroud)

结果是路径的 url,而不是文本。当我运行 http get 方法时,端点不存在。

获取数据的最佳实践是什么?我正在使用反应。

如果有诸如 Storage.getText(...) 这样的方法,那将是最好的情况。

我试过使用这个添加授权......

  Auth.currentCredentials()
            .then(credentials => {
                axios.get(result, { headers: { 'Authorization': JSON.stringify(Auth.essentialCredentials(credentials)) } })
                    .then(r => {

                        console.log(r);
                    })
            });
Run Code Online (Sandbox Code Playgroud)

400 错误请求 :(

amazon-s3 reactjs aws-amplify

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

如何在C#中区分typeof(int)== typeof(int?)

为什么C#设置相同?

typeof(int).GetType() == typeof(int?).GetType()
Run Code Online (Sandbox Code Playgroud)

在编写表达式树时,会出现问题

List<int?> ids = JsonConvert.DeserializeObject<List<int?>>(filter.Value?.ToString());
var filterField = filter.PropertyName;
var method = ids.GetType().GetMethod("Contains");
return Expression.Call(Expression.Constant(ids), method, member);
Run Code Online (Sandbox Code Playgroud)

生成此错误

System.ArgumentException:类型'System.Int32'的表达式不能用于'System.Nullable 1[System.Int32]' of method 'Boolean Contains(System.Nullable1 [System.Int32] 类型的参数

有没有办法在发送到表达式树之前检查类型?

我尝试检查类型int和,int?并且两者都返回true以进行以下检查:

bool isIntNull = type == typeof(int?).GetType();
Run Code Online (Sandbox Code Playgroud)

c#

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