我阅读了TypeScript编码指南
而且我觉得这句话很令人费解:
不要使用"I"作为接口名称的前缀
我的意思是,没有"我"前缀,这样的事情就没有多大意义
class Engine implements IEngine
Run Code Online (Sandbox Code Playgroud)
我错过了一些明显的东西吗
我不太明白的另一件事是:
类
为保持一致性,请不要在核心编译器管道中使用类.请改用函数闭包.
这是否表明我根本不应该使用课程?
希望有人可以为我清理:)
这是一个简单的问题:这之间是否存在任何(性能)差异:
Person person = new Person()
{
Name = "Philippe",
Mail = "phil@phil.com",
};
Run Code Online (Sandbox Code Playgroud)
还有这个
Person person = new Person();
person.Name = "Philippe";
person.Mail = "phil@phil.com";
Run Code Online (Sandbox Code Playgroud)
您可以想象具有更多属性的更大对象.
我想让A级Parcelable.
public class A {
public String str;
public ArrayList<B> list;
}
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所提出的.但是它崩溃了NullPointerException.问题是这两个陈述:dest.writeList(list);
&in.readList(list, this.getClass().getClassLoader());
.我无法弄清楚从这里做什么:(
A级
public class A implements Parcelable {
public String str;
public ArrayList<B> list;
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(str);
dest.writeList(list);
}
private A(Parcel in) {
str = in.readString();
in.readList(list, this.getClass().getClassLoader());
}
public static final Parcelable.Creator<A> CREATOR
= new Parcelable.Creator<A>() {
public A createFromParcel(Parcel in) {
return …
Run Code Online (Sandbox Code Playgroud) 有什么区别
<input [(ngModel)]="name">
Run Code Online (Sandbox Code Playgroud)
和
<input [(value)]="name">
Run Code Online (Sandbox Code Playgroud)
他们似乎做了同样的事情.
角度文档使用NgModel,但他们也说它们用"盒装香蕉"[()]替换所有angular1指令.那么为什么NgModel还在?
我错过了什么?
当客户端请求集合上的所有元素但集合为空时,我编写了一个返回204(无内容)的Web API.
例如:/api/products
当没有产品时返回204.
现在我的问题是我正在尝试使用Restangular来使用API,如下所示:
Restangular.all('products').getList().then(function (products) {
$scope.products = products;
});
Run Code Online (Sandbox Code Playgroud)
但是,这会导致以下javascript错误.
错误:getList的响应应该是一个数组,而不是一个对象或其他东西
是什么赋予了?我找不到有关在Restangular文档中处理任何内容的任何信息
我用错了吗?我应该用空列表返回200吗?
我正在尝试在我的ASP.NET MVC 5解决方案中实现Identity 2.0,该解决方案遵循洋葱架构.
我有一个ApplicationUser
核心.
namespace Core.DomainModel
{
public class ApplicationUser {...}
}
Run Code Online (Sandbox Code Playgroud)
在我的数据访问层中,我正在使用实体框架6.1,我的上下文源于IdentityDbContext
此处,并且在此处存在问题.ApplicationUser
需要从中衍生出来Microsoft.AspNet.Identity.EntityFramework.IdentityUser
namespace Infrastructure.DAL
{
public class TestContext : IdentityDbContext<ApplicationUser> {...}
}
Run Code Online (Sandbox Code Playgroud)
我的域名模型不应该引用Microsoft.AspNet.Identity.EntityFramework
违背洋葱的想法.
什么是好的解决方案?
我做了一个plunker演示(点击按钮,观察输入框保持不变)
标记:
<body ng-controller="Ctrl">
<input type="text" id="input" name="input" ng-model="myValue" test>
<p translate="VARIABLE_REPLACEMENT" translate-values="{{ 'translationData' }}"></p>
<p ng-bind-html="alink"></p>
</body>
Run Code Online (Sandbox Code Playgroud)
角度的东西:
var translations = {
VARIABLE_REPLACEMENT: 'Hi, {{name}}'
};
var app = angular.module('myApp', ['pascalprecht.translate', 'ngSanitize']);
app.config(['$translateProvider', function ($translateProvider) {
// add translation table
$translateProvider.translations(translations);
}]);
app.controller('Ctrl', ['$scope', '$sce', function ($scope, $sce) {
$scope.translationData = { name: 'foo'};
$scope.setValue = function(value) {
$scope.myValue = value;
};
}]);
app.directive('test', ['$translate', '$sce', function ($translate, $sce) {
return { …
Run Code Online (Sandbox Code Playgroud) 灵感来自于此我做了这个:
ISortable
public interface ISortable<T>
{
IPageable<T> OrderBy<U>(Expression<Func<T, U>> orderBy);
IPageable<T> OrderByDescending<U>(Expression<Func<T, U>> orderBy);
}
Run Code Online (Sandbox Code Playgroud)
IPageable
public interface IPageable<T> : ISortable<T>, IEnumerable<T>
{
IPageable<T> Page(int pageNumber, int pageSize);
List<T> ToList();
int TotalPages { get; }
int TotalItemCount { get; }
int PageNumber { get; }
int? PageSize { get; }
}
Run Code Online (Sandbox Code Playgroud)
分页
public class Pageable<T> : IPageable<T>
{
private readonly IQueryable<T> _countQuery;
private IQueryable<T> _sourceQuery;
/// <summary>
/// A pageable result
/// </summary>
/// <param name="sourceQuery">Query which holdes …
Run Code Online (Sandbox Code Playgroud) 我正在使用FSharp.Data.SqlClient并尝试将我的connectionString从a移动[<Literal>]
到app.config.
我的app.config看起来像这样
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我的SqlCommandProvider
外观如下所示,根据http://fsprojects.github.io/FSharp.Data.SqlClient/configuration%20and%20input.html,这应该是正确的
new SqlCommandProvider<"SELECT ...",
ConnectionStringOrName = "name=DefaultConnection",
SingleRow = true,
AllParametersOptional = true>(??????)
Run Code Online (Sandbox Code Playgroud)
现在的问题是.最后一部分是什么,??????
部分.
我试过"name=DefaultConnection"
但它给了我一个运行时错误,名称不受支持.
我似乎找不到任何文件来解释那里发生了什么.
Instaed of fixnig我发现了这个问题的解决方法. https://fsprojects.github.io/FSharp.Configuration/
ConnectionStringOrName
如果必须提供连接字符串,我无法达到目的.另外你为什么要指定它两次.对我来说没什么意义:(
我正在尝试制作一个使用将 a 作为 的组件的TemplateRef
故事@Input
。但我不知道怎么做。
测试组件
@Component({
selector: 'test',
templateUrl: './test.component.html',
})
export class TestComponent {
@Input() public set value(value: TemplateRef<void>) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
故事
export default {
title: 'Components/Test',
component: TestComponent,
} as Meta;
const Template: Story<TestComponent> = (args) => ({
props: args,
});
export const TemplateRefStory = Template.bind({});
TemplateRefStory.args = {
value: ???, // <-- what do I put here?
};
Run Code Online (Sandbox Code Playgroud)
我尝试了多种方法,它们与下面的类似。这确实没有意义。
export const TemplateRef: Story<TestComponent> = (args) => ({
template: `<ng-template #hello>Hello</ng-template>`, …
Run Code Online (Sandbox Code Playgroud) c# ×3
angular ×2
android ×1
angularjs ×1
coding-style ×1
f# ×1
f#-data ×1
linq ×1
parcelable ×1
performance ×1
properties ×1
rest ×1
restangular ×1
setter ×1
storybook ×1
translation ×1
typescript ×1