小编Gue*_*lla的帖子

将流浪盒下载到不同的驱动器

我在安装过程中选择了D:\驱动器,但是当我下载一个流浪盒时,它会下载到我在C:\驱动器上的用户目录中.我使用的SSD几乎没有任何空间.如何将其下载到另一个驱动器?

vagrant

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

使用anglesharp linq查询获取Href属性

我试图了解如何使用anglesharp。

我根据示例(https://github.com/AngleSharp/AngleSharp)制作了此代码:

        // Setup the configuration to support document loading
        var config = Configuration.Default.WithDefaultLoader();
        // Load the names of all The Big Bang Theory episodes from Wikipedia
        var address = "http://store.scramblestuff.com/";
        // Asynchronously get the document in a new context using the configuration
        var document = await BrowsingContext.New(config).OpenAsync(address);
        // This CSS selector gets the desired content
        var menuSelector = "#storeleft a";
        // Perform the query to get all cells with the content
        var menuItems = document.QuerySelectorAll(menuSelector);
        // We …
Run Code Online (Sandbox Code Playgroud)

c# linq anglesharp

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

如何在点网核心中查找mx记录?

我正在尝试将我的应用程序移植到.net核心。当前,它使用ArSoft.Tools nuget包查找mx记录,但是此包与core不兼容。

在核心中查找mx记录的最佳方法是什么?

c# dns mx-record .net-core asp.net-core

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

图像无法在 flexbox 内缩放

当图像在 flexbox 内时,它不会正确缩放(高度不会自动调整)。

这是它在 flex 外部工作而不在内部工作的示例;

.image-size{
  height:auto;
  width: 300px;
}
.container{
  display: flex;
}
Run Code Online (Sandbox Code Playgroud)
<img class="image-size" src="https://openclipart.org/image/2400px/svg_to_png/233274/arrow-circle.png" alt="circle" />
<div class="container">
  <img class="image-size" src="https://openclipart.org/image/2400px/svg_to_png/233274/arrow-circle.png" alt="circle" />
</div>
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

html css flexbox

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

更新EFCore连接的通用方法

我发现EFCore处理多对多关系的方式非常乏味的一件事是更新实体连接集合.经常要求视图模型来自前端,新的嵌套实体列表,我必须为每个嵌套实体编写一个方法,找出需要删除的内容,需要添加的内容然后执行删除和添加.有时一个实体有多个多对多关系,我必须为每个集合写出几乎相同的代码.

我认为这里可以使用通用方法来阻止我重复自己,但我正在努力弄清楚如何.

首先让我告诉你我目前的做法.

让我们说我们有这些模型:

public class Person
{
    public int Id { get; set; }
    public string Name { get; set; }

    public virtual ICollection<PersonCar> PersonCars { get; set; } = new List<PersonCar>();
}

public class Car
{
    public int Id { get; set; }
    public string Manufacturer { get; set; }

    public virtual ICollection<PersonCar> PersonCars { get; set; } = new List<PersonCar>();
}

public class PersonCar
{
    public virtual Person Person { get; set; }
    public int PersonId { …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework entity-framework-core

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

与 React 之外的功能组件通信

我希望能够从正常 HTML 中的组件外部与我的 React 组件进行通信(由于将组件嵌入到另一个系统中而需要)。

我一直在研究这个,我看到了一些建议,您可以window通过在渲染元素上添加引用来添加组件,如下所示:

  ReactDOM.render(
    <Hello
      ref={(element) => {
        window.helloComponent = element;
      }}
    />,
    rootElement
  );
Run Code Online (Sandbox Code Playgroud)

但对我来说它不起作用并生成此警告:

index.js:27 警告:不能为函数组件提供引用。尝试访问此引用将失败。您的意思是使用 React.forwardRef() 吗?

该组件不会添加到 window 对象,因此该引用无法从 React 组件外部的 html 按钮起作用。

我一直在尝试使用 createRef() 的各种方法来添加到窗口,但无法弄清楚。我无法将forwardRef() 文档与我当前的情况联系起来。

这是我的代码:

  ReactDOM.render(
    <Hello
      ref={(element) => {
        window.helloComponent = element;
      }}
    />,
    rootElement
  );
Run Code Online (Sandbox Code Playgroud)
const rootElement = document.getElementById("root");

if (rootElement) {
  ReactDOM.render(
    <Hello
      ref={(element) => {
        window.helloComponent = element;
      }}
    />,
    rootElement
  );
}

function Hello() {
  function alertOne() {
    alert("hi from 1");
  }
  return …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

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

无法使用集合初始值设定项初始化类型“SelectListItem”,因为它未实现“System.Collections.IEnumerable”

我正在尝试创建一个SelectListItem列表以在我的视图中使用。

我尝试使用 Linq 将其传递给 ViewBag,如​​下所示:

    public ActionResult Create()
    {
        ViewBag.EmailAccounts = db.EmailAccounts.Select(e => new SelectListItem { e.ID, e.Name });
        return View();
    }
Run Code Online (Sandbox Code Playgroud)

但它给了我这个错误:

无法使用集合初始值设定项初始化类型“SelectListItem”,因为它未实现“System.Collections.IEnumerable”

我从这里得到了这样做的想法:http://odetocode.com/blogs/scott/archive/2013/03/11/dropdownlistfor-with-asp-net-mvc.aspx

我在这里缺少什么概念?

c# linq asp.net-mvc-5

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

try/catch 块中未捕获异常

有什么原因导致 try/catch 块不起作用吗?

我在 try catch 块内调用 Magento2 API 中的一个方法,但它没有捕获异常并且执行停止,并且我看到堆栈跟踪。

这是我的代码:

        $productModel = $this->productRepository->getById( $pId );

        $debpt = "";
        try{
            $debpt = $productModel->getCustomAttribute('depart_num')->getValue();
        }
        catch(\Exception $ex){
            $debpt = $ex->getMessage();
        }
Run Code Online (Sandbox Code Playgroud)

getValue()方法导致异常,但我的 try/catch 没有捕获它。

这是堆栈跟踪:

( ! ) Fatal error: Uncaught Error: Call to a member function getValue() on null in /var/www/nwl/app/code/Raleigh/CustomReports/Controller/Report/Generate.php on line 118
( ! ) Error: Call to a member function getValue() on null in /var/www/nwl/app/code/Raleigh/CustomReports/Controller/Report/Generate.php on line 118
Call Stack
#   Time    Memory  Function    Location …
Run Code Online (Sandbox Code Playgroud)

php magento2

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

Asp.net Core 2.0 Configure.Services &lt;model&gt;()绑定不适用于用户机密

我的问题是Configure.Services<model>()没有将用户机密绑定到我的班级。服务内部注入的类始终具有null属性。

我的secrets.json看起来像这样:

{
  "OtherSection": {
    "Another": {
      "Prop": "1234"
    }
  },
  "EmailSettings": {
    "Mailgun": {
      "ApiKey": "omitted",
      "BaseUri": "omitted",
      "RequestUri": "omitted",
      "From": "omitted",
      "Smtp": "omitted",
      "SmtpUser": "omitted",
      "SmtpPass": "omitted",
      "SmtpPort": 465
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我创建了此用户设置类:

public class MailgunSettings : ISmtpDetails
{
    public string ApiKey { get; set; }
    public string BaseUri { get; set; }
    public string RequestUri { get; set; }
    public string From { get; set; }
    public string Smtp { get; set; }
    public string …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc .net-core asp.net-core asp.net-core-2.0

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

获取受保护字段的值

我的方法正在从第三方代码传递一个对象作为参数。有问题的类称为:SqlExpression<T>

该类具有以下受保护字段:

protected List<ModelDefinition> tableDefs = new List<ModelDefinition>();
Run Code Online (Sandbox Code Playgroud)

我需要该属性内的信息,但我已经检查了该类,并且没有公共访问器。

我尝试制作一个儿童课程:

public class SqlExpressionExtension<T> : SqlExpression<T>
{
    public SqlExpressionExtension(IOrmLiteDialectProvider dialectProvider) : base(dialectProvider)
    {
    }

    public List<Type> GeTableTypes()
    {
        return this.tableDefs.Select(x => x.ModelType).ToList();
    }
}

Run Code Online (Sandbox Code Playgroud)

然后像SqlExpression<T>这样投射SqlExpressionExtension<T>

var types = ((SqlExpressionExtension<T>)query).GeTableTypes();
Run Code Online (Sandbox Code Playgroud)

但我得到一个例外,它无法转换类型。

获取这些数据的正确方法是什么?

c#

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