我试图使用react-redux和typescript,当我尝试使用connect()和mapStateToProps注入道具时,我遇到了类型错误.
我的组件看起来像这样:
function mapStateToProps(state) {
return {
counter: state.counter
};
}
function mapDispatchToProps(dispatch) {
return {
incr: () => {
dispatch({type: 'INCR', by: 2});
},
decr: () => {
dispatch({type: 'INCR', by: -1});
}
};
}
export default class Counter extends React.Component<HelloProps, any> {
render() {
return (
<div>
<p>
<label>Counter: </label>
<b>#{this.props.counter}</b>
</p>
<button onClick={e => this.props.incr() }>INCREMENT</button>
<span style={{ padding: "0 5px" }}/>
<button onClick={e => this.props.decr() }>DECREMENT</button>
);
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Counter);
Run Code Online (Sandbox Code Playgroud)
这家商店看起来像这样
let store …Run Code Online (Sandbox Code Playgroud) 我创建了一个带有OAuth令牌认证的Web API应用程序.当令牌服务器在与服务相同的应用程序上运行时,这没有问题.但是,我想将授权服务移动到自己的应用程序(VS项目)中,并将其用于我正在处理的几个Web API项目中.但是,当我将授权逻辑隔离到它自己的项目中时,原始服务不再将生成的令牌视为有效.我的问题是,一个Web API项目是否有可能为另一个Web API项目生成令牌以进行验证?这是我的授权服务和原始服务的OWIN启动代码
认证服务:
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
HttpConfiguration config = new HttpConfiguration();
ConfigureOAuth(app);
WebApiConfig.Register(config);
app.UseWebApi(config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
}
private void ConfigureOAuth(IAppBuilder app)
{
OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider()
};
// Token Generation
app.UseOAuthAuthorizationServer(OAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
}
Run Code Online (Sandbox Code Playgroud)
原始服务:
public void Configuration(IAppBuilder app)
{
ConfigureOAuth(app);
// For more information on how to …Run Code Online (Sandbox Code Playgroud) 有没有办法在Discriminated Unions中使用函数?我希望做这样的事情:
Type Test<'a> = Test of 'a-> bool
我知道在Haskell中使用newtype是可能的,我想知道F#中的等价物是什么.
谢谢.
在Visual Studio 2012 RC中,重构菜单没有显示给我.它没有显示在菜单栏或上下文相关帮助中.是否需要更改设置以使其显示.我在自定义选项中看到了重构菜单,但无法使其显示在菜单栏中.这是在ac#项目中.