今天我开始在我的应用程序中实现一个API,当应用程序加载时,它会显示活动(一个加载对话框)一秒钟.然后以下消息在logcat中开始发送垃圾邮件:
10-04 15:54:33.094 27832-27832/nl.berris.roy.raspberrypiproject E/libc: Access denied finding property "vendor.perf.iop_v3.enable"
10-04 15:54:33.094 27832-27832/nl.berris.roy.raspberrypiproject E/libc: Access denied finding property "vendor.perf.iop_v3.enable.debug"
Run Code Online (Sandbox Code Playgroud)
Logcat设置为错误级别,仅在选定的应用程序上使用过滤器.这是唯一给出的输出.
在此消息发送5秒之后,应用程序将强制停止而不显示任何消息.我在谷歌上找不到任何相关信息.有没有人能解释为什么会这样?
我在gradle中的实现:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:cardview-v7:25.4.0'
implementation 'com.android.support:recyclerview-v7:25.4.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.afollestad.material-dialogs:core:0.9.4.3'
implementation ('com.squareup.retrofit2:retrofit:2.3.0') {
exclude module: 'okhttp'
}
implementation 'com.squareup.okhttp3:okhttp:3.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
implementation 'com.google.code.gson:gson:2.8.2'
Run Code Online (Sandbox Code Playgroud)
我正在使用Retrofit2进行api调用.我确实注释掉了API代码,应用程序仍然崩溃了.仍然api调用运行异步.
现在只在应用程序中发生的事情是一个打开片段的活动.在这个片段中是一个带有适配器的recyclerview.此外,"失败"MaterialDialog将显示,因为API调用失败.一切都加载,甚至是"失败"对话框.在api调用之后创建(并且失败).几秒钟后,应用程序停止.并显示如上所示的错误消息.
因此??,当左手为null时,我们必须解析其右手值。什么是等价的string[]。
例如
string value = "One - Two"
string firstValue = value.Split('-')[0] ?? string.Empty;
string secondValue = value.Split('-')[1] ?? string.Empty;
Run Code Online (Sandbox Code Playgroud)
如果我们尝试获取第三个索引或,上述示例仍然会崩溃string value = "One"。因为它不是null而是IndexOutOfRangeException被抛出。
https://docs.microsoft.com/zh-cn/dotnet/api/system.indexoutofrangeexception
那么解决上述问题的单线解决方案是什么?我想避免尝试捕获的情况,因为这会产生难看的代码。
我想string[]使用a string.Empty作为备用值来获取价值,所以我string永远不会null。
我想在HTML <input/>标签更改时运行一个函数.我该怎么做呢?有一些答案,但他们都在jQuery,我想要简单的JavaScript.有人能给我一个简单的例子吗?谢谢!
我希望输入是一个类型为文本:
<input type="text" id="change">
Run Code Online (Sandbox Code Playgroud) Visual Studio 在IEnumerable. 然后我添加ToList()它。但我开始想知道为什么这是一个不好的做法。
那么为什么多次枚举不好呢?
我想提交带有可选选项的车道。例如车道:
lane :mylane do |options|
mailgun(
to: "#{options[:mailto]}"
....
)
end
Run Code Online (Sandbox Code Playgroud)
我如何给出:mailto默认值?所以如果我跑fastlane mylane它会自动设置:mailto为mail@example.com。
但是如果我运行fastlane mylane mailto:"secondmail@example.com"它会使用那个值
出于某种原因,我一直在 gradle javafx 项目中获得 NPE。
我的文件夹结构非常基本。我的main/java文件夹中有一个包含我的 java 文件的包。我的main/resources文件夹中也有我的资源。当我尝试加载image.png它时,它给了我一个 NPE。
public static Image createImage(Object context, String url) {
Image m = null;
InputStream str = null;
URL _url = context.getClass().getResource(url);
try {
m = new Image(_url.getPath());
} catch (NullPointerException e) {
e.printStackTrace();
}
return m;
}
Run Code Online (Sandbox Code Playgroud)
这是一个辅助类。
从SceneI 调用:Image image = Helper.createImage(this, "image.png");
图像的绝对路径将是main/resources/images/image.png.
我检查了互联网上的每个教程,但找不到任何解决方案。我还尝试将图像路径作为参数,也尝试使用 ,InputStream但它从未奏效。
是否可以通过 IJSRuntime 获取对 Bootstrap 5 的引用bootstrap.Modal并保存对该实例的引用以供以后使用?
例子:
我可以用这种方法显示模式:
await _jsRuntime.InvokeVoidAsync("eval", $"new bootstrap.Modal(document.getElementById('myId')).show()");
Run Code Online (Sandbox Code Playgroud)
但我不能以同样的方式隐藏它,因为我需要存储对new bootstrap.Modal创作的引用。我怎样才能动态地做到这一点(我有一个引导模式组件)而不必编写javascript?有什么方法可以保存变量并稍后通过 IJSRuntime 引用它们吗?
因此,当我为 DbContext 编写查询时,可查询的顺序实际上代表了输出查询。例如:
_dbContext
.Table
.OrderBy(i => i.Date)
.Take(25)
.Where(i => i.Variable == "something")
.ToList()
Run Code Online (Sandbox Code Playgroud)
相对
_dbContext
.Table
.Where(i => i.Variable == "something")
.OrderBy(i => i.Date)
.Take(25)
.ToList()
Run Code Online (Sandbox Code Playgroud)
因此,这些查询是不同的,因为第一个查询按日期获取最后 25 个项目并执行 where 子句。但另一个从where的结果中取出25。
当它被执行时,它会保持这个顺序吗?或者这就像一个构建器,其中所有属性都被设置和执行。如果我查看普通的 SQL,我无法在同一查询中的TAKE之前进行操作。WHERE所以对我来说这是有道理的。
我感到困惑的原因是,如果我用 MS SQL 编写第一个查询,我们会得到以下结果:
SELECT TOP 25 * FROM `Table` WHERE `Variable` = 'something' ORDER BY `Date`
Run Code Online (Sandbox Code Playgroud)
其中从 where 结果中取出 25。
我想制作一个过滤器.如果您输入"黑名单"中的单词,它会告诉您某些内容.我有所有的代码,但有问题.
JS:
input = document.getElementById("input").value;
array = ["1","2","3"];
function filter() {
if (input == array)
// I will do something.
} else {
// Something too
}
}
Run Code Online (Sandbox Code Playgroud)
我想这样做,如果它input是一个项目array.声明是真的.但是这样做的正确方法是什么?因为我在这里所做的不起作用!另外我想摆脱区分大小写!因此,如果阵列中有hello两个hello并且Hello被检测到.
对不起,如果以前问过这个问题.我搜索它但不知道使用什么关键字.
编辑1:
我正在改变我的问题:我想检查我原来的问题是什么,但有一些其他功能.
我还想检查是否input有项目的一部分array.因此,如果输入hello的是helloworld正在检测,因为IS拥有hello它.以及hello或Hello.
那么是否可以在 C# 中为方法动态指定泛型类型?我不是在谈论使用反射,而是仅使用 C#。
例子:
internal class MyRepository
{
async Task<IEnumerable<WhateverClass>> GetItemsFor<T>(int entityId, int itemId, params string[] keys)
where T : class, IEntity
{
// do whatever
}
}
interface IEntity
{
public int Id { get; set; }
}
internal class Foo : IEntity
{
// whatever
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是我将提供一个string“foo”,internal class Foo因为它Foo是内部的,不能被我的其他项目访问(这是预期的)。但它在外部被称为string“foo”。
现在我想调用以下方法(这是公共的)。
public async Task<IEnumerable<WhateverClass>> GetItemsFor(string forAsString, int entityId, int itemId, params string[] keys)
{
var forAsType = forAsString switch
{ …Run Code Online (Sandbox Code Playgroud) 我有一个具有以下结构的JSON对象
{"30-31":[{"msg":"hello","usr":"31"}],
"33-30":[{"msg":"shah hi","usr":"30"}]}
Run Code Online (Sandbox Code Playgroud)
我可以执行什么操作来获取这样的数组["30-31", "33-30"].我尽力使用.map等但没有成功,有人可以帮忙吗?
在互联网上找不到任何内容,也找不到有关此的文档。DateTime.NowC#从哪里得到它DateTime.Today?这些是本地化值。是Windows决定的吗?或者 IIS 对此有影响吗?我想知道到底是什么将实时时间解析为 C# 以及什么会影响它。
我遇到了一些奇怪的 API 行为,其中有些内容提前了几个小时返回。这很可能与时区有关。VPS 和客户端位于同一时区,所以我想知道什么会影响这种行为。
我正在努力工作...FromDate.Date <= DateTime.Today.Date,由于某种原因,我有时会收到“来自”明天的记录。哪里2021-02-21 <= 2021-02-20看起来是“真实”的。真正的意思是,DateTime.Today似乎已经关闭了。仅在晚上 10 点左右(也就是实际午夜前的几个小时)左右看到此行为,这表明它与时区有关。
如果您对此行为有任何想法,请告诉我
所以现在我得到了
Error: System.InvalidOperationException: A second operation was started on this context before a previous operation completed.
Run Code Online (Sandbox Code Playgroud)
因为blazor似乎不尊重当前的请求。
我正在做的是这样的:
FirstComponent.razor
@inject IService _service; // abstracted service that calls EF
<layout> // layout stuff here
<SecondComponent /> // second blazor component
</layout>
@code {
protected override async Task OnInitializeAsync()
{
var getSomething = await _service.OnInitializedAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
SecondComponent.razor
@inject IService _service; // abstracted service that calls EF
@code {
protected override async Task OnInitializedAsync()
{
var getSomething = await _service.GetSomething();
}
} …Run Code Online (Sandbox Code Playgroud) c# ×7
javascript ×3
arrays ×2
blazor ×2
html ×2
android ×1
angularjs ×1
asp.net-core ×1
datetime ×1
enumeration ×1
fastlane ×1
function ×1
generics ×1
iqueryable ×1
java ×1
javafx ×1
json ×1
linq ×1
reflection ×1
string ×1