我正在尝试使用SVN补丁文件在开发过程中删除Web API的身份验证。删除身份验证的补丁文件运行良好,内容如下:
Index: WebApplication.Api/Global.asax.cs
===================================================================
--- WebApplication.Api/Global.asax.cs (revision 18939)
+++ WebApplication.Api/Global.asax.cs (working copy)
@@ -115,7 +115,7 @@
_dependencyRegister.AddRegistration<WebApplication.Application.Aspects.AuthorisationAspect>();
// WebApplication.Application.CurrentUser
- _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Application.CurrentUser.CurrentUserService>();
+ _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Api.DummyServices.CurrentUserService>();
// WebApplication.Application.Interface.Manager
_dependencyRegister.AddRegistration<WebApplication.Application.Interface.Manager.IAspNetMembershipManager, WebApplication.Application.Manager.AspNetMembershipManager>();
Index: WebApplication.Api/Web.config
===================================================================
--- WebApplication.Api/Web.config (revision 18939)
+++ WebApplication.Api/Web.config (working copy)
@@ -64,14 +64,12 @@
</sessionState>
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
- <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
- <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</modules>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
正如你所看到的,它改变了接口的DI实现,并从XML配置文件中删除了两个节点。
由于(根据我所找到的方法)没有办法反向应用补丁(我在Visual Studio中使用VisualSVN来应用补丁),因此我基于原始补丁文件创建了一个“反向补丁”:
Index: WebApplication.Api/Global.asax.cs
===================================================================
--- WebApplication.Api/Global.asax.cs (revision 18939)
+++ WebApplication.Api/Global.asax.cs (working copy)
@@ -115,7 +115,7 @@
_dependencyRegister.AddRegistration<WebApplication.Application.Aspects.AuthorisationAspect>();
// WebApplication.Application.CurrentUser
+ _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Application.CurrentUser.CurrentUserService>();
- _dependencyRegister.AddRegistration<WebApplication.Application.CurrentUser.ICurrentUserService, WebApplication.Api.DummyServices.CurrentUserService>();
// WebApplication.Application.Interface.Manager
_dependencyRegister.AddRegistration<WebApplication.Application.Interface.Manager.IAspNetMembershipManager, WebApplication.Application.Manager.AspNetMembershipManager>();
Index: WebApplication.Api/Web.config
===================================================================
--- WebApplication.Api/Web.config (revision 18939)
+++ WebApplication.Api/Web.config (working copy)
@@ -64,14 +64,12 @@
</sessionState>
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
+ <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
+ <add name="ProtectedResourceModule" type="WebApplication.Api.Modules.ProtectionModule"/>
</modules>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
简单来说,我只是把加号"+"和减号"-"互换。这样就创建了一个对我有意义的反向补丁文件。
这个反向补丁文件工作正常,但XML配置文件中的最后一个“行添加”,除了添加该行外,还会删除其后面的多行,导致生成不良格式的XML。
有没有人能够解释一下这是为什么?我需要对神奇的@@ -64,14 +64,12 @@
做些什么吗?