小编Sve*_*übe的帖子

C#lambda未命名参数

有可能,通过不给它们一个名字来丢弃lambda表达式中的一些参数吗?例如,我必须传递一个Action <int,int>,但我只对第二个参数感兴趣,我想写一些像

(_, foo) => bar(foo)
// or
(, foo) => bar(foo)
Run Code Online (Sandbox Code Playgroud)

在第一种情况下,它正在工作.但第一个参数并非真正未命名,因为它的名称为"_".所以它不起作用,当我想丢弃两个或更多.我选择_因为在prolog中它具有"任何价值"的含义.

所以.我的用例有什么特殊的字符或表达吗?

c# parameters lambda

20
推荐指数
3
解决办法
2953
查看次数

Windows UWP在发现后连接到BLE设备

我正在BluetoothLEAdvertisementWatcher寻找附近的BLE设备并且它运行良好.找到它们后,我想通过GATT连接和读/写数据.但是在获得BluetoothLEAdvertisement(https://msdn.microsoft.com/de-de/library/windows/apps/windows.devices.bluetooth.genericattributeprofile)后我无法弄清楚如何使用API .

public class Adapter
{
    private readonly BluetoothLEAdvertisementWatcher _bleWatcher = new BluetoothLEAdvertisementWatcher();

    public Adapter()
    {
        _bleWatcher.Received += BleWatcherOnReceived;
    }

    private void BleWatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
    {       
        // how to connect?
        // I know, it's the wrong place to to this, but this is just an example
    }

    public void StartScanningForDevices(Guid[] serviceUuids)
    {
        _blewatcher.advertisementfilter.advertisement.serviceuuids.clear();
        foreach (var uuid in serviceuuids)
        {
            _blewatcher.advertisementfilter.advertisement.serviceuuids.add(uuid);
        }
        _blewatcher.start();
    }
}
Run Code Online (Sandbox Code Playgroud)

我发现使用的样品DeviceInformation.FindAllAsync代替BluetoothLEAdvertisementWatcher但是这些样品不起作用/找不到任何设备.

UPDATE

经过一段时间的挖掘,我找到了以下方法.但不幸的是,配对失败了.该设备只是一个带有BLE屏蔽的Arduino.我绝对可以与Android和iOS连接.因此必须以某种方式与UWP合作.:/

private void …
Run Code Online (Sandbox Code Playgroud)

c# bluetooth-lowenergy gatt win-universal-app windows-10-universal

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

MSTest数据驱动测试集来自DataSource的行的DisplayName

如何在数据驱动的测试中设置数据行的DisplayName,其中数据源是XML,提供者是Microsoft.VisualStudio.TestTools.DataSource.XML.

XML:

<?xml version="1.0" encoding="utf-8" ?>
<environments>
    <environment><name>IE</name></environment>
    <environment><name>Chrome</name></environment>
</environments>
Run Code Online (Sandbox Code Playgroud)

App配置:

<!-- CONNECTION STRINGS SETTINGS -->
<connectionStrings>
    <add name="IE_Chrome" connectionString="IE_Chrome.xml" providerName="Microsoft.VisualStudio.TestTools.DataSource.XML"/>
</connectionStrings>
<!-- PARAMETERIZING TEST SETTINGS -->
<microsoft.visualstudio.testtools>
    <dataSources>
        <add name="IE_Chrome" connectionString="IE_Chrome" dataTableName="environment" dataAccessMethod="Sequential"/>
    </dataSources>
</microsoft.visualstudio.testtools>
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

我想显示环境名称而不是"数据行0".

mstest xmldatasource data-driven-tests visual-studio-2012 test-reporting

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

MvvMCross与格式字符串绑定

如何为绑定添加格式,使用string.Format或类似的东西格式化绑定值?我在其他线程中看到,您可以传递一个converterName.

  • 是否存在针对此问题的转换器?
  • 我在哪里可以看到MvvMCross v3的标准转换器列表?

我很快浏览了代码,但找不到任何东西.我知道可能会发生信息丢失,这会破坏双向绑定,但我只想要这个来显示值.我的具体案例是DateTime的绑定.

bindings.Bind(purchaseDate).To(vm => vm.RegisteredDevice.PurchaseDate);
Run Code Online (Sandbox Code Playgroud)

我的愿望,例如:

bindings.Bind(purchaseDate).To(vm => vm.RegisteredDevice.PurchaseDate).WithFormat("hh:mm");
Run Code Online (Sandbox Code Playgroud)

c# format binding xamarin.ios mvvmcross

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

iOS以编程方式取消TouchID身份验证对话框

是否可以在LAContext.evaluatePolicy通话后以编程方式取消TouchID警报对话框?如果是的话:怎么样?

ios touch-id

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

如何在Xamarin/Android上启用多个BLE特征通知?

我正在尝试使用Xamarin/Android启用多个BLE特性的通知,但似乎无法这样做.如果我尝试一次启用多个BLE事件,该应用程序似乎停止接收任何BLE事件.

任何人都可以使用Tamarin/Android确认这是否可行.我们有一个原生的iOS应用程序,可以正常启用多个通知.我们使用的基本步骤如下:

  1. 扫描设备
  2. 连接到设备
  3. 发现服务
  4. 对于每个发现的服务,迭代特征并启用所需的服务
  5. 处理BLE回调中的每个异步回调事件

每当我们尝试在多个特征上启用通知时,我们就不再接收任何事件.

我也无法找到任何启​​用多个特性的示例.

我希望我在这里错过了使用Xamarin/Android API的基本信息.

public override void OnServicesDiscovered (BluetoothGatt gatt, GattStatus status)
{
    base.OnServicesDiscovered (gatt, status);
    foreach (BluetoothGattService service in gatt.Services) {
        string uuid = service.Uuid.ToString ().ToUpper();
        if (uuid.Equals (BLEServices.HRService.ToUpper())) {
            _Adap.LogMessage ("HRService discovered");
            foreach(BluetoothGattCharacteristic characteristic in service.Characteristics) {
                string c_uuid = characteristic.Uuid.ToString ().ToUpper ();
                _Adap.LogMessage (" HRCharacteristic: " + c_uuid);

                if (c_uuid.Equals(_Adap.useCharacteristic.ToUpper())) {
                    _Adap.LogMessage ("  enabling HRCharacteristic");
                    gatt.SetCharacteristicNotification(characteristic, true);
                    BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor (Java.Util.UUID.FromString (BLEServices.CLIENT_CHARACTERISTIC_CONFIG), GattDescriptorPermission.Write | GattDescriptorPermission.Read);
                    characteristic.AddDescriptor (descriptor);
                    descriptor.SetValue …
Run Code Online (Sandbox Code Playgroud)

notifications xamarin.android characteristics bluetooth-lowenergy xamarin

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

Webpack typescript编译没有webpackJsonp

是否可以使用webpack进行包装而不使用webpack模块加载?

我有一个应用程序,可以使用webpack的所有内容,在这个应用程序旁边我有一个小的打字稿文件test.ts,应该编译,缩小等.但输出应该是一个没有包装的简单的js文件webpackJsonp.对于没有外部依赖的几行来说,增加了太多的开销(96kb).

test.ts

alert('foo');
Run Code Online (Sandbox Code Playgroud)

test.js是

webpackJsonp([1],{
/***/ 0:
/***/ function(module, exports, __webpack_require__) {

    __webpack_require__(1);
    __webpack_require__(75);
    module.exports = __webpack_require__(105);

/***/ },

/***/ 105:
/***/ function(module, exports) {

    "use strict";
    alert('test');

/***/ }
});
Run Code Online (Sandbox Code Playgroud)

test.js应该

alert('foo');
Run Code Online (Sandbox Code Playgroud)

我试图建立一个生态系统(webpack).

typescript webpack

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

当isVisible设置为true时,Listview未更新

我正在尝试ListView使用可点击的行.当您单击某一行时,它会将子堆栈布局设置为可见性为true.这在android中运行良好,但在ios中不行.也许我做错了.我仍然是初学者,任何想法如何解决这个或任何其他更好的方法?问题是它在ios上打开,因此可见性会发生变化,但它不会更新单元格的高度.例如,如果向上滚动直到无法再看到打开的单元格,然后向下滚动,则单元格会在屏幕外更新.你会看到它已经更新了高度.

我尝试使用自定义渲染器,但我不知道从哪里开始.

这是我的xaml:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Lisa.Excelsis.Mobile.AssessmentPage" xmlns:local="clr-namespace:Lisa.Excelsis.Mobile;assembly=Lisa.Excelsis.Mobile">
<StackLayout>
    <local:SpecialListView x:Name="CategoryList" 
                ItemsSource = "{Binding Categories}" 
                HasUnevenRows="true" 
                RowHeight="-1" 
                GroupDisplayBinding="{Binding Name}"
                IsGroupingEnabled="true">
        <local:SpecialListView.ItemTemplate>
            <DataTemplate> 
                <ViewCell x:Name="ObservationCell">
                    <ViewCell.View>
                        <StackLayout x:Name="ObservationContainer"
                                     HorizontalOptions="FillAndExpand"
                                     Orientation="Vertical"
                                     VerticalOptions="StartAndExpand"
                                     BackgroundColor="White">   
                            <StackLayout x:Name="Observation"   
                                         HorizontalOptions="FillAndExpand"
                                         VerticalOptions="StartAndExpand"                                        
                                         Padding="15, 10, 10, 10"
                                         BackgroundColor="White">   
                                <StackLayout.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="OpenItem"/>
                                </StackLayout.GestureRecognizers>

                                <Grid HorizontalOptions="FillAndExpand" >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />     
                                        <RowDefinition Height="Auto" />                 
                                    </Grid.RowDefinitions>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="35" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <Label  x:Name="ObservationOrder" 
                                            Text="{Binding Criterion.Order, StringFormat='{0}.'}" 
                                            FontSize="18" 
                                            VerticalOptions="StartAndExpand" 
                                            Grid.Column="0" Grid.Row="0"/>   

                                    <Label  x:Name="ObservationTitle" 
                                            Text="{Binding …
Run Code Online (Sandbox Code Playgroud)

listview expandablelistview ios xamarin xamarin.forms

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

在 Safari 中加载源映射和调试?

我们遇到了仅在 Safari 浏览器上发生的错误,所以我清理了 Macbook 上的 OSX 分区并尝试调试它,但我无法找到如何查看原始源代码并设置断点。

我的主文件是main.d7f60b0631c7822cabf3.bundle.js,文件的最后一行是这个,它指向确实存在的源映射文件,因为我可以输入 url 并获取它,它在 Firefox 和 chrome 中工作:

//# sourceMappingURL=main.d7f60b0631c7822cabf3.bundle.js.map
Run Code Online (Sandbox Code Playgroud)

在 Firefox 中,我可以转到开发工具中的调试器选项卡,在源下我可以看到我的原始源文件webpack:///src/app/app.component.ts,我可以打开它并设置断点。

在 Chrome 开发工具中,我转到“源”选项卡并执行相同的操作,将树导航到webpack://- .- src- app- app.component.ts

有没有办法在 Safari 中实现同样的目标?从内存中,因为我在 Windows 上写这个,我在调试选项卡中看不到任何文件,只是一个断点列表。在资源选项卡中,我可以看到包和一个箭头,看起来我应该能够展开它,但是点击那个箭头确实把它从右转到下,就像它被展开但没有显示任何东西。像jquery这样的其他文件在展开时似乎在它们下面有原始源......

javascript safari source-maps typescript webpack

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

Azure Devops Docker Push:本地不存在带有该标签的映像

我正在使用 spring boot maven 插件在 Azure DevOps 上构建一个 java spring boot 应用程序 docker 容器。之后我想将其推送到天蓝色的容器注册表。但它失败了

本地不存在带有以下标签的镜像:***/my/container

不幸的是,容器 uri 的开头被***. 但正如您在下面的输出中看到的/usr/bin/docker images,容器已注册。我尝试遵循以下示例:https://medium.com/@TimvanBaarsen/build-your-spring-boot-project-using-azure-pipelines-in-azure-devops-3305977991d

管道步骤

steps:
- task: Maven@3
  displayName: "Build Docker image"
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'spring-boot:build-image'
    publishJUnitResults: false
    jdkVersionOption: '1.11'
    mavenOptions: '-Xmx3072m -Dspring-boot.build-image.imageName=acr-foobar.azurecr.io/my/container'

- task: Docker@2
  displayName: Push Docker image
  inputs:
    containerRegistry: 'acr-foobar.azurecr.io'
    repository: 'my/container'
    command: 'push'
    tags: 'latest'
Run Code Online (Sandbox Code Playgroud)

输出 Maven 任务

[INFO] Successfully built image 'acr-***/my/container:latest'
Run Code Online (Sandbox Code Playgroud)

输出 Docker 任务

Starting: Push Docker image
==============================================================================
Task         : …
Run Code Online (Sandbox Code Playgroud)

docker spring-boot azure-devops azure-container-registry

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