我有两个目标构建环境; 发布和分期.Web.config看起来像这样:
<system.web>
<authentication mode="Windows">
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
Run Code Online (Sandbox Code Playgroud)
我想通过构建到暂存配置来转换它:Web.Staging.config
<system.web>
<authentication mode="Windows">
</authentication>
<authorization xdt:Transform="Replace">
<deny users="?" />
<allow roles="StagingRoles" />
<deny users="*" />
</authorization>
</system.web>
Run Code Online (Sandbox Code Playgroud)
我从命令行构建如下:
msbuild buildscript.build /p:Configuration=Staging
Run Code Online (Sandbox Code Playgroud)
在构建之后,我没有看到在构建工件文件夹中转换的web.config文件.这里有什么问题吗?
谢谢
我是CQRS的新手,我想要在写端(域)内理解业务规则验证.我知道客户端验证应该在有效日期(必填字段,字符串长度,有效电子邮件等)方面完成,业务规则/业务域相关验证应该在域方进行.实际上,同样的客户端验证规则也应该应用于域中的命令,因为我们不信任用户.
因此,我们有一个有效的命令(AddEmailToCustomer),并在命令上调用命令处理程序.这是我的验证方法.
我在命令处理程序中抛出异常并在那里添加这些错误吗?我是否将命令发送到错误队列或其他地方?我是否回复Bus.Reply之类的内容并返回错误代码?如果是这样,我该如何处理错误消息?如何将这些错误传达给用户?我知道我可以稍后通过电子邮件发送它们,但在Web场景中,我可以在命令中发送请求ID(或使用消息ID),并使用请求ID轮询响应并向用户显示错误消息.
感谢您的指导.
谢谢
有一个像这样的简单结构:
type Event struct {
Id int
Name string
}
Run Code Online (Sandbox Code Playgroud)
这两种初始化方法有什么区别?
e1 := Event{Id: 1, Name: "event 1"}
e2 := &Event{Id: 2, Name: "event 2"}
Run Code Online (Sandbox Code Playgroud)
我为什么要使用这些初始化方法?
谢谢
我有一个简单的TypeScript(ts)需要JavaScript文件中的函数.如何将该js文件导入ts文件?我是否必须为该js文件创建一个ts文件才能在我的ts文件中使用它?
有没有.bowerrc等价的jspm?当我运行时jspm install,我希望jspm将软件包安装到client/jspm_packages文件夹中.
如何配置jspm来更改jspm_packages文件夹的位置?
谢谢
"Autofac会自动选择具有能够从容器中获取的最多参数的构造函数." 我希望它不这样做,而是选择默认构造函数.http://code.google.com/p/autofac/wiki/Autowiring
internal class ParameterlessConstructorSelector : IConstructorSelector
{
#region Implementation of IConstructorSelector
/// <summary>
/// Selects the best constructor from the available constructors.
/// </summary>
/// <param name="constructorBindings">Available constructors.</param>
/// <returns>
/// The best constructor.
/// </returns>
public ConstructorParameterBinding SelectConstructorBinding(ConstructorParameterBinding[] constructorBindings)
{
return constructorBindings.First();
}
#endregion
}
Run Code Online (Sandbox Code Playgroud)
当我上课时,我这样做了:
builder.RegisterType<EmployeeFactory>()
.As<IEmployeeFactory>().UsingConstructor(new ParameterlessConstructorSelector())
.SingleInstance();
Run Code Online (Sandbox Code Playgroud)
constructorBindings列表中的第一个绑定始终是带有paremeterless构造函数的绑定.不确定它是先定义还是autofac扫描构造函数的方式,但这是无参数构造函数的正确接线方法吗?
谢谢
我想处理一个application/json内容类型的传入POST .我只是试图返回发布的JSON作为对此测试的响应:
WebhookController控制器
pipeline :api do
plug :accepts, ["json"]
end
def handle(conn, params) do
{:ok, body, conn} = Plug.Conn.read_body(conn)
json(conn, %{body: body})
end
Run Code Online (Sandbox Code Playgroud)
router.ex
scope "/webhook", MyApp do
pipe_through :api
post "/handle", WebhookController, :handle
end
Run Code Online (Sandbox Code Playgroud)
如果传入的帖子具有内容类型application/json,则body为空.如果内容类型是text或text/plain,则body具有内容.
解析传入application/json请求正文的正确方法是什么?
我正在使用Phoenix 1.2
我有一个动作返回一个简单的json.出于演示目的,我将粘贴示例代码.要序列化的简单类:
public class Employee
{
public string FullName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
返回json的动作:
public JsonResult Test()
{
var employee = new Employee { FullName = "Homer Simpson" };
var serializer = new JavaScriptSerializer();
var json = serializer.Serialize(employee);
return Json(json, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
这是我困惑的地方.当我从浏览器调用此操作并查看Fiddler的响应时,结果如下:
HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 15 Aug 2011 20:52:34 GMT
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
Cache-Control: private
Content-Type: application/json; charset=utf-8
Content-Length: 34
Connection: Close
"{\"FullName\":\"Homer Simpson\"}"
Run Code Online (Sandbox Code Playgroud)
Fiddler中的"JSON"选项卡显示"所选响应不包含有效的JSON文本".有效的回答应该是这样的:
"{"FullName":"Homer Simpson"}"
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?谢谢
我有这个界面:
public interface IUserProfileService
{
// stuff
}
Run Code Online (Sandbox Code Playgroud)
实施者:
public class UserProfileService : IUserProfileService
{
private readonly string m_userName;
public UserProfileService(string userName)
{
m_userName = userName;
}
}
Run Code Online (Sandbox Code Playgroud)
我需要将这个注入到这样的控制器中:
public class ProfilesController : BaseController
{
private readonly IUserProfileService m_profileService;
public ProfilesController(IUserProfileService profileService)
{
m_profileService = profileService;
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何将此接口及其实现注册到Ninject容器中,以便在Ninject进入此服务的实例时传入userName参数.
我有什么想法可以达到这个目的吗?
我正在索引网页上的所有名称,其中包含带有"José"等重音的字符.我希望能够用"Jose"和"José"搜索这个名字.
如何为具有一个字段"name"的简单索引设置索引映射和分析器?
我为名称字段设置了一个分析器,如下所示:
"analyzer": {
"folding": {
"tokenizer": "standard",
"filter": ["lowercase", "asciifolding"]
}
}
Run Code Online (Sandbox Code Playgroud)
但它将所有重音折叠成ascii等效物,并在索引"é"时忽略重音.我希望"é"字符在索引中,我希望能够用"José"或"Jose"搜索"José"
谢谢
我想使用基类消息类,如:
[Serializable]
public abstract class MessageBase : IMessage
{
public Guid MessageID { get; private set; }
public DateTime UtcDateTime { get; private set; }
protected MessageBase()
{
UtcDateTime = DateTime.UtcNow;
MessageID = Guid.NewGuid();
}
public override string ToString()
{
return string.Format("{0} MessageID={1}, UtcDate={2}", GetType().FullName, MessageID, UtcDateTime);
}
}
Run Code Online (Sandbox Code Playgroud)
将通过从此基类进行子类化来创建新消息.这是我观察到的问题.当我发布消息时,我发现消息id和datetime在处理时是不同的.
我错过了什么?
我正在将带有require.js的toastr.js加载到我的角度项目中,但它不能用作全局变量.
这是main.js:
require.config({
baseUrl: 'js',
paths: {
domReady: '../lib/requirejs-domready/domReady',
jquery: '../lib/jquery/jquery',
jqueryValidate: '../lib/jquery.validation/jquery.validate',
underscore: '../lib/underscore/underscore',
bootstrap: '../lib/bootstrap/dist/js/bootstrap',
moment: '../lib/momentjs/moment',
toastr: '../lib/toastr/toastr',
angular: '../lib/angular/angular',
ngAnimate: '../lib/angular-animate/angular-animate',
'ui.router': '../lib/angular-ui-router/release/angular-ui-router',
'chieffancypants.loadingBar': '../lib/angular-loading-bar/build/loading-bar',
uuid4: '../lib/angular-uuid4/angular-uuid4',
'ui.bootstrap': '../lib/angular-bootstrap/ui-bootstrap',
'ui.bootstrap.tpls': '../lib/angular-bootstrap/ui-bootstrap-tpls',
xeditable: '../lib/angular-xeditable/dist/js/xeditable',
Restangular: '../lib/restangular/dist/restangular',
ngCookies: '../lib/angular-cookies/angular-cookies'
},
shim: {
angular: {
exports: 'angular'
},
Restangular: {
deps: ["underscore", "angular"]
},
'ui.router': {
deps: ['angular']
},
'ui.bootstrap': {
deps: ['angular', 'ui.bootstrap.tpls']
},
underscore: {
exports: '_'
},
bootstrap: {
deps: ['jquery']
},
toastr: {
deps: ['jquery'], …Run Code Online (Sandbox Code Playgroud) 我在公共库中使用依赖解析器接口作为抽象.这使我可以灵活地切换容器.鉴于下面的接口和静态IoC类,我需要使用不带IKernel全局asax 的工厂初始化IoC .
请参阅下面我如何使用NinjectHttpApplicationbase创建Ninject内核.
这是问题所在; 该IKernel物业CtsDependencyFactory始终null.
Ninject不会像这样注射自己吗?我应该使用不同的方法传递IKernel给工厂吗?我找不到像静态类ObjectFactory中StructureMap的Ninject得到一个参考解析器.
任何帮助表示赞赏.
public interface IResolveDependency
{
T Resolve<T>();
T Resolve<T>(params object[] parameters);
T Resolve<T>(string name);
T Resolve<T>(string name, params object[] parameters);
object Resolve(Type type);
IEnumerable<T> ResolveAll<T>();
void Clear();
}
public interface IResolveDependencyFactory
{
IResolveDependency CreateInstance();
}
public class CtsDependencyResolver : IResolveDependency
{
private readonly IKernel m_kernel;
public CtsDependencyResolver(IKernel kernel)
{
m_kernel = kernel;
}
#region Implementation of IResolveDependency …Run Code Online (Sandbox Code Playgroud) ninject ×2
nservicebus ×2
.net ×1
asp.net-mvc ×1
autofac ×1
c# ×1
command ×1
cqrs ×1
ecmascript-6 ×1
elixir ×1
go ×1
json ×1
jspm ×1
loader ×1
msbuild ×1
toastr ×1
typescript ×1
validation ×1