小编ven*_*rik的帖子

不推荐使用android webview setDatabasePath

此方法在API级别19中已弃用. 数据库路径由实现管理,并且调用此方法将不起作用.

setDatabasePath用来设置webview的数据库路径.

String databasePath = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); 
settings.setDatabasePath(databasePath);
Run Code Online (Sandbox Code Playgroud)

这是否意味着在API 19中它不能再找到我的数据库了?怎么解决这个?(他们的意思是:数据库路径由实现管理)

database android deprecated webview

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

将文本块对齐到页面底部

我试图将我的Windows Phone应用程序的版本与页面的底部中心对齐.它将其置于视图中的所有组件的底部(下方).但不要到我的页面底部

<StackPanel>
    <TextBlock Text="Username:" Margin="12,0,0,0"/>
    <TextBox Text="{Binding UserName, Mode=TwoWay}" c4f:TextBinding.UpdateSourceOnChange="True" InputScope="EmailUserName" />
    <TextBlock Text="Password:" Margin="12,0,0,0"/>
    <PasswordBox Password="{Binding Password, Mode=TwoWay}" c4f:TextBinding.UpdateSourceOnChange="True" />
    <Button Content="Next" IsEnabled="{Binding CanMoveNext}" Command="{Binding LoginCommand}"/>
    <TextBlock Text="{Binding ConnectionError}"  TextWrapping="Wrap" FontSize="{StaticResource TitleSize}"></TextBlock>
    <TextBlock Text="{Binding VersionNumber}" Height="450" Padding="3" TextWrapping="Wrap" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="15"></TextBlock>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

我希望它在页面底部.

xaml windows-phone

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

如何使用YamlDotNet将JSON转换为YAML

我正在尝试使用YamlDotNet将JSON转换为YAML.这是我的代码:

class Program
{
    static void Main(string[] args)
    {
        var json = "{\"swagger\":\"2.0\",\"info\":{\"title\":\"UberAPI\",\"description\":\"MoveyourappforwardwiththeUberAPI\",\"version\":\"1.0.0\"},\"host\":\"api.uber.com\",\"schemes\":[\"https\"],\"basePath\":\"/v1\",\"produces\":[\"application/json\"]}";
        var swaggerDocument = JsonConvert.DeserializeObject(json);

        var serializer = new YamlDotNet.Serialization.Serializer();

        using (var writer = new StringWriter())
        {
            serializer.Serialize(writer, swaggerDocument);
            var yaml = writer.ToString();
            Console.WriteLine(yaml);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我提供的JSON:

{
   "swagger":"2.0",
   "info":{
      "title":"UberAPI",
      "description":"MoveyourappforwardwiththeUberAPI",
      "version":"1.0.0"
   },
   "host":"api.uber.com",
   "schemes":[
      "https"
   ],
   "basePath":"/v1",
   "produces":[
      "application/json"
   ]
}
Run Code Online (Sandbox Code Playgroud)

这是我期待的YAML:

swagger: '2.0'
info:
  title: UberAPI
  description: MoveyourappforwardwiththeUberAPI
  version: 1.0.0
host: api.uber.com
schemes:
  - https
basePath: /v1
produces:
  - application/json
Run Code Online (Sandbox Code Playgroud)

但是,这是我得到的输出:

swagger: []
info: …
Run Code Online (Sandbox Code Playgroud)

c# json yaml yamldotnet

6
推荐指数
3
解决办法
3548
查看次数

如何使用 SwashBuckle 设置或删除默认响应内容类型

使用 SwashBuckle 时的默认响应内容类型是text/plain。如何将默认值更改为application/json甚至删除text/plain

asp.net-web-api swashbuckle

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

WP8 MvvmLight命名空间丢失且EventToCommand不存在

我在Windows Phone 8项目中仅使用MVVM Light库(来自Nuget包),我想使用EventToCommandToggleSwitch.我有这些代码行:

<toolkit:ToggleSwitch x:Name="LockSwitch"
        IsChecked="{Binding IsLock, Mode=TwoWay}">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Toggled">
            <Command:EventToCommand 
                Command="{Binding DataContext.NavigateToArticleCommand, ElementName=LayoutRoot}"
                CommandParameter="{Binding}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</toolkit:ToggleSwitch>
Run Code Online (Sandbox Code Playgroud)

问题是VS显示错误:

错误1名称"EventToCommand"在命名空间"clr-namespace:GalaSoft.MvvmLight.Command; assembly = GalaSoft.MvvmLight.Extras.WP8"中不存在.

错误2找不到类型'Command:EventToCommand'.验证您是否缺少程序集引用,并且已构建所有引用的程序集.

错误3标记'EventToCommand'在XML命名空间'clr-namespace中不存在:GalaSoft.MvvmLight.Command; assembly = GalaSoft.MvvmLight.Extras.WP8'.

我在文件Styles.xaml中有上面的行,它是一个ResourceDictionary并且ToggleSwitch是a的一部分DataTemplate.我使用这一行包括MvvmLight库:

xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP8"
Run Code Online (Sandbox Code Playgroud)

怎么了?为什么我会收到错误?我试图使用谷歌,但我找不到解决方案.

c# mvvm mvvm-light windows-phone-8

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

TypeScript对象实现具有额外属性错误的接口

我正在阅读关于TypeScript的Pluralsight课程,这会引发错误,同时它被解释为课程中的有效代码.

错误TS2322:输入'{favouriteSport:string; name:string; 孩子:数量; 年龄:数量; calcPets :()=>数字; makeYo ...'不能指定为'Person'类型.对象文字只能指定已知属性,'person'类型中不存在'favouriteSport'.

interface Person{
    age: number,
    name: string,
    kids: number,
    calcPets: ()=> number;
    makeYounger: (years: number) => void;
    greet: (msg: string) => string; 
}

var p: Person = {
    favouriteSport: "tennis",
    name: "Michael",
    kids: 4,
    age: 44,
    calcPets: function(){
        return this.kids * 2;
    },
    makeYounger: function(years: number){
        this.age -= years;
    },
    greet: function(msg: string){
        return msg + ', ' + this.name;
    }
}
Run Code Online (Sandbox Code Playgroud)

typescript

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

无法在Swagger中注入Javascript

我得到一个404文件,我试图在我的招摇中注入一个JavaScript文件.以下是我的招摇配置

var thisAssembly = typeof(SwaggerConfig).Assembly;

GlobalConfiguration.Configuration 
    .EnableSwagger(c =>
        {
            c.SingleApiVersion("v1", "A title for your API");
        })
    .EnableSwaggerUi(c =>
        {
            c.InjectJavaScript(thisAssembly,"MyApi.Api.SwaggerExtensions.inject.js");   
        });
Run Code Online (Sandbox Code Playgroud)

对于inject.js构建操作设置为嵌入式资源,逻辑路径是正确的,因为我的项目名称是MyApi.Api,并且该文件位于名为SwaggerExtensions的项目中的文件夹中

swagger swashbuckle

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

用什么?WCF或套接字?在C#程序中

我需要创建一个C#程序,它将在我们的几台本地Windows客户机上运行.这些"客户端"程序必须从另一台机器上运行的"管理"程序中获取命令.这些命令可能是重新启动客户端计算机,将一些有关IP地址的本地信息返回给"admin"程序.

但是如何实现这一目标呢?我对WCF了解一点,但这是正确的方法吗?如果我使用WCF,那么我将不得不让客户端程序像每一秒一样运行服务方法来检查新命令.使用套接字我建立一个"直接"连接,客户端只是等待接收命令 - 是不是正确的理解?

哪种方式对我来说是正确的方式?

我们正在谈论~10个客户端,我想要1秒钟的最大延迟(发送命令 - 接收信息).

任何提示也将不胜感激.

最好的祝福

c# sockets wcf

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

FileHelpers中的DataTable类 - type.GetProperties()返回空数组

我已成功将CSV文件拖到以下类中:

[DelimitedRecord(",")]
[IgnoreFirst(1)] // ignores first line of file, since it's a header
public class Employee {
    public string EmployeeId;
    public string FirstName;
    public string LastName;
    // etc.
}
Run Code Online (Sandbox Code Playgroud)

我需要基于该类创建一个DataTable才能使用SqlBulkCopy.我找到了几个例子,但以下方法对我不起作用:

private static DataTable createEmptyDataTable(Type myType) {
        DataTable dt = new DataTable();

        foreach (PropertyInfo info in myType.GetProperties()) {
            dt.Columns.Add(new DataColumn(info.Name, info.PropertyType));
        }

        return dt;
    }
Run Code Online (Sandbox Code Playgroud)

问题出在myType.GetProperties()上.它没有抛出错误,但它什么也没有返回.它应该返回的PropertyInfo数组是空的.已经有一段时间了,无法弄清楚问题......

编辑:我也使用这个变种没有成功:

private static DataTable createEmptyDataTable(Type myType) {
        DataTable dt = new DataTable();
        PropertyInfo[] infoArray = myType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);

        foreach (PropertyInfo info …
Run Code Online (Sandbox Code Playgroud)

.net c# filehelpers

4
推荐指数
2
解决办法
3267
查看次数

在下拉列表中设置日期格式

我正在从数据集(_dsst)中检索日期值,并在下拉列表(drpStartYear)中填充它们.

由于我将日期存储为datetime数据类型,因此我将日期值设置为mm-dd-yyyy 00:00:00,其中00:00:00是时间.但我需要在下拉列表中以dd-mm-yyyy格式获取日期.我尝试使用datatextformatstring,但它不起作用.

以下是代码:

 drpStartYear.DataSource = _dstt.Tables["tbSettings"].DefaultView;    
 drpStartYear.DataValueField = "StartDate";    

 drpStartYear.DataTextFormatString = "{0:d}";   
 drpStartYear.DataBind();    
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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