我在开发时尝试使用 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 @@
吗?