小编Eri*_*fer的帖子

为什么WaitForSingleObject(INVALID_HANDLE_VALUE,INFINITE)会阻塞?

为什么

HANDLE mutexHandle = INVALID_HANDLE_VALUE;
WaitForSingleObject(mutexHandle, INFINITE);
Run Code Online (Sandbox Code Playgroud)

块?它不会返回错误消息.检查句柄对于INVALID_HANDLE互斥锁来说是愚蠢的,因为我需要一个互斥锁来访问互斥锁句柄...

BTW:WAIT_FAILED如果把手关闭,它确实会返回.

windows winapi multithreading synchronization waitforsingleobject

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

是否有任何F#替代(非网)实施项目?

一些流行语言(如Python和Ruby)具有本机,JVM和.Net CLR实现.C#是使用免费的Mono项目实现的.是否有任何实施F#的尝试?

f#

7
推荐指数
3
解决办法
1266
查看次数

windowbackground 不适用于深色和浅色主题

我有一个主题,用户可以选择浅色或深色,一切正常,但是有两个问题:

  1. 当我打开应用程序时[在深色/浅色主题中],首先显示一个白页,然后应用程序使用深色主题
  2. 当我更改主题时,首先出现黑屏

我试图改变背景但没有用,我改变了它的颜色,我还使用了可绘制的形状。无论如何,它不起作用并且对两者都使用一种颜色。

样式文件

 <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"/>
Run Code Online (Sandbox Code Playgroud)

值/themes.xml

 <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"/>
Run Code Online (Sandbox Code Playgroud)

值夜/themes.xml

<style name="Theme.MaterialComponents.DayNight.NoActionBar"
        parent="Theme.MaterialComponents.Light.NoActionBar">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@drawable/window_background</item>
</style>
Run Code Online (Sandbox Code Playgroud)

windows_background

<style name="Theme.MaterialComponents.DayNight.NoActionBar"
        parent="Theme.MaterialComponents.NoActionBar">

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/TabBackground</item>
    <item name="colorAccent">@color/green_inactive</item>
    <item name="android:windowBackground">@drawable/window_background_dark</item>

</style>
Run Code Online (Sandbox Code Playgroud)

windows_background_dark

和上面的代码类似,只是颜色不同

这就是我加载主题的方式

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#64b5f6"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

java android styles

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

如何在 spring-boot 应用程序中配置多个 Keycloak sso 客户端?

我正在使用 Spring Boot 微服务配置 Keycloak SSO。我想要多个 keycloak 客户端访问 spring 引导服务。如果在 Spring Boot 应用程序中使用 Keycloak 适配器,pom.xml则所需的属性仅支持一个客户端和密钥。我们如何在运行时在 spring boot 应用程序中添加多个客户端?

我使用了以下适配器 pom.xml

<dependency>
    <groupId>org.keycloak.bom</groupId>
    <artifactId>keycloak-adapter-bom</artifactId>
    <version>5.0.0</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

下面是配置在 application.properties

keycloak.auth-server-url=http://localhost:9080/auth
keycloak.realm=test
keycloak.ssl-required=external
keycloak.resource=rest-api
keycloak.credentials.secret=62s4376d-9b45-4aa3-abcb-1abdefc4fab88
keycloak.use-resource-role-mappings = true
keycloak.security-constraints[0].authRoles[0]=rest-api
keycloak.security-constraints[0].securityCollections[0].patterns[0]=/api/*
Run Code Online (Sandbox Code Playgroud)

以上属性只支持一种客户端配置,并且只允许客户端rest-api生成的token添加到application.properties.

我想在 Keycloak 中动态创建客户端,并希望 spring-boot 应用程序允许所有客户端生成令牌。

动态客户端注册可用于 spring boot oAuth2 配置,但找不到在 spring boot 应用程序中配置 keycloak 多个客户端的任何示例

如果有人解决了类似的需求并愿意分享配置或示例,这将很有帮助。

java single-sign-on spring-boot keycloak

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

禁用 Chromium“无法更新 Chromium”窗口通知

我们在触摸屏 (Linux) 上以自助服务终端模式运行 Google Chromium。我们经常收到消息“无法更新 Chromium”窗口通知。我们还没有找到可以阻止这种情况的标志。

有人有想法吗?

google-chrome chromium google-chrome-extension kiosk-mode

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

Flutter - Local_auth(未启用所需的安全功能)

在更新我正在开发的应用程序后,我试图让生物识别身份验证再次工作。但是我在激活它时不断收到同样的错误:

 PlatformException(NotAvailable, Required security features not enabled, null, null)
Run Code Online (Sandbox Code Playgroud)

店里目前的一款完全没有问题。

我正在使用 local_auth:1.1.4
MainActivity.java 已转换为 FragmentedActivity
我正在做一个简单的检查,看看生物识别是否可用。他们是谁

 PlatformException(NotAvailable, Required security features not enabled, null, null)
Run Code Online (Sandbox Code Playgroud)

之后我尝试进行身份验证

bool canCheckBiometrics = await auth.canCheckBiometrics;
List<BiometricType> availableBiometrics =
await auth.getAvailableBiometrics();

print(canCheckBiometrics); //Returns true
print(availableBiometrics.toString()); //Returns [BiometricType.fingerprint]
Run Code Online (Sandbox Code Playgroud)

这将返回:

PlatformException(NotAvailable, Required security features not enabled, null, null)
Run Code Online (Sandbox Code Playgroud)

这就是代码中的插件注释所说的。

// Indicates the device does not have a Touch ID/fingerprint scanner.  
const String notAvailable = 'NotAvailable';
Run Code Online (Sandbox Code Playgroud)

我真的不确定要检查什么了。这是我需要注意的新事物吗?

真的希望有人能帮助我解决这个问题!

希望听到!

flutter

7
推荐指数
3
解决办法
1022
查看次数

如何从颤振中的数据快照中获取特定值?

我有这个数据快照

"{post1: {pic: https://i.redd.it/ni6zhxh874011.jpg, title: title, desc: desc}, post2: {pic: https://i.redd.it/krj9miojg5011.jpg, title: awsdas, desc: desc2}}"
Run Code Online (Sandbox Code Playgroud)

我想从每个帖子中检索“图片”值。snapshot.value["pic"] 不起作用,它返回 null。

提前致谢

这就是我为我未来的建造者收到数据快照的方式

"{post1: {pic: https://i.redd.it/ni6zhxh874011.jpg, title: title, desc: desc}, post2: {pic: https://i.redd.it/krj9miojg5011.jpg, title: awsdas, desc: desc2}}"
Run Code Online (Sandbox Code Playgroud)

dart firebase firebase-realtime-database flutter

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

画布的 .MoveUp 使用什么值

下面的代码将 PDF 文件中的所有页面复制到一个新文件中,并在第一页的顶部插入一个带有红色边框的矩形,其中包含一个短文本。

如果我不移动它,顶部会留下一个缺口(这里放大了很多,字体大小只有8):

在此处输入图片说明

但是,如果我将矩形向上移动4的经验值:

    iText.Kernel.Geom.Rectangle pageSize = firstPage.GetCropBox().MoveUp(4);
Run Code Online (Sandbox Code Playgroud)

顶部会有一个完美的匹配:

在此处输入图片说明

值 4 与字体大小无关。

我不喜欢代码中的幻数,所以我的问题是:为什么是 4?什么表达式会揭示这个值 4?

代码行在此处的第一种方法中。第二个是使用它的地方,第三个是从第一个调用的;它只是提供一种风格:

private static void RegisterDocument(PdfDocument pdfDocument, string registration)
{
    // Magic value to close gap between top of page and top of rectangle with the registration.
    const float moveUp = 4F;

    Document document = new Document(pdfDocument, new PageSize(PageSize.A4));
    PdfPage firstPage = document.GetPdfDocument().GetFirstPage();

    Paragraph paragraph = new Paragraph(registration).AddStyle(RegistrationStyle());

    iText.Kernel.Geom.Rectangle pageSize = firstPage.GetCropBox().MoveUp(moveUp);
    LayoutContext layoutContext = new LayoutContext(new LayoutArea(1, pageSize));
    IRenderer renderer …
Run Code Online (Sandbox Code Playgroud)

.net c# pdf itext7

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

无法确定条件表达式的类型?

我刚刚遇到这个(编写代码来演示"问题"):

public ICollection<string> CreateCollection(int x)
{
    ICollection<string> collection = x == 0 
                                   ? new List<string>() 
                                   : new LinkedList<string>();
    return collection;
}
Run Code Online (Sandbox Code Playgroud)

编译器抱怨:

Fehler CS0173:Der Typ des bedingten Ausdrucks kann nicht bestimmt werden,weil keine implizite Konvertierung zwischen"System.Collections.Generic.List"und"System.Collections.Generic.LinkedList"erfolgt.

其翻译大致为:

无法确定条件运算符的类型,因为List和LinkedList之间没有隐式转换.

我可以看到为什么编译器抱怨,但是,嘿,来吧.它试图发挥愚蠢.我可以看到两个表达式不是同一类型,而是有一个共同的祖先,作为奖励,左侧的类型也是共同的祖先.我相信编译器也可以看到它.如果左侧被声明为,我可以理解错误var.

我在这里错过了什么?

编辑:

我接受詹姆斯·冈特的解释.也许只是为了说清楚.我可以很好地阅读编译器规范.我想了解原因.为什么有人决定以这种方式编写规范.这种设计背后必然有一个原因.根据詹姆斯的说法,设计原则是"毫无意外".此外,CodeInChaos还解释了如果编译器试图从常见的祖先中推断出类型,您可能遇到的惊喜.

.net c# compiler-construction

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

是什么使一个类成为根据NUnit集合约束的集合?

我有一个实现的类ICollection<SomeConcreteClass>.NUnit集合约束不会将其识别为集合.

例如Assert.That( sut, Has.No.Member( someObjectOfTypeSomeConcreteClass ) );投掷System.ArgumentException : The actual value must be a collection

Assert.That( sut, Is.Empty );失败了sut.

那么什么时候集合是一个集合(根据NUnit)?

堆栈跟踪:

System.ArgumentException : The actual value must be a collection Parametername: actual
at NUnit.Framework.Constraints.CollectionConstraint.Matches(Object actual)
at NUnit.Framework.Constraints.NotConstraint.Matches(Object actual)
    MyTestFile.cs(36,0): at MyAssembly.MyTestFixture.MyTestMethod()
Run Code Online (Sandbox Code Playgroud)

NUnit 2.4.3.0出现上述问题.我刚用2.6尝试过.Is.Empty现在有效,但Has.No.Member仍然失败.它甚至没有打电话Equals()operator ==().它如何比较收集元素?RhinoMocks Arg<MyCollection>.List.Count( Is.Equal( 1 ) )现在也失败了.

结论:
对于NUnit 2.4,集合约束要求将集合的非泛型ICollection实现为集合(可回答原始问题).IEnumerable相等按预期工作.

使用NUnit 2.6(可能还有3.0),IEnumerable即使Equals被覆盖,匹配元素也会检查s的相等性.这就是为什么如果元素IEnumerable本身就是成员约束不起作用的原因.这是一个已知问题(https://bugs.launchpad.net/nunit-3.0/+bug/646786). …

.net c# collections nunit constraints

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