我正在尝试提高用 C# 和 .NET 2.0 开发的、处理大量文件的 Windows 服务的性能。我想每秒处理更多文件。
在其过程中,对于每个文件,该服务都会执行数据库查询以检索系统的某些参数。
这些参数每年都会变化,我认为如果将这些参数作为单例加载并定期刷新该单例,我会获得一些性能。我不会对每个正在处理的文件进行数据库查询,而是从内存中获取参数。
完成该场景:我使用 Windows Server 2008 R2 64 位,SQL Server 2008 是数据库,C# 和 .NET 2.0,如前所述。
我的方法正确吗?你会怎么办?
谢谢!
我正在开发一个新的MVC应用程序,该应用程序将主要使用TDD编写.我想补充一些集成测试,以确保完全有线应用(我用StructureMap海委会,NHibernate的持久性)按预期工作.
虽然我打算用Selenium编写一些功能性烟雾测试,但出于可维护性的原因,我宁愿通过使用旧的C#在我的控制器上直接调用操作来进行大部分集成测试.
关于如何实现这一目标的指导令人惊讶,因此我对攻击计划进行了抨击
我已经完成了第1步,但实际上不知道如何继续第2步.任何指导都将不胜感激.
public class Bootstrapper
{
public static void Bootstrap()
{
DependencyResolverInitializer.Initialize();
FilterConfig.RegisterFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
ModelBinders.Binders.DefaultBinder = new SharpModelBinder();
}
}
public class DependencyResolverInitializer
{
public static Container Initialize()
{
var container = new Container();
container.Configure(x => x.Scan(y =>
{
y.Assembly(typeof(Webmin.UI.FilterConfig).Assembly);
y.WithDefaultConventions();
y.LookForRegistries();
}));
DependencyResolver.SetResolver(new StructureMapDependencyResolver(container));
return container;
}
}
public class StructureMapDependencyResolver : IDependencyResolver
{
private readonly IContainer _container;
public StructureMapDependencyResolver(IContainer container)
{
_container = container;
}
public object GetService(Type serviceType)
{
if (serviceType.IsAbstract || serviceType.IsInterface) …Run Code Online (Sandbox Code Playgroud) 我试图在多个WCF客户端端点中使用相同的http cookie(实际上是asmx sessionid).
服务器有几个端点,其中一个是:
AuthenticationService.asmx
Login()< - 创建一个HTTP cookie,即服务器ASP.NET sessionid
Logout()< - 销毁相同的cookie
SomeOtherService.asmx
DoSomeThing()< - 从AuthenticationService.asmx中重新获取有效的cookie.
如何跨多个端点共享HTTP Cookie.
我无法控制服务器代码,必须使用WCF.
我在通过此处的方法" 集中式cookie管理 "中概述的方法进行WCF服务调用时管理共享的auth cookie :http://megakemp.com/2009/02/06/managing-shared-cookies-in- WCF /
我已经建立了一个自定义的IClientMessageInspector,IEndpointBehavior,BehaviorExtensionElement,的作品.我的端点行为添加了一个消息检查器,如下所示:
public class MyEndpointBehavior : IEndpointBehavior
{
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
{
// yuck.. Wish I had an instance of MyClientMessageInspector
// (which has the auth cookie already) so I could just inject that
// instance here instead of creating a new instance
clientRuntime.MessageInspectors.Add(new MyClientMessageInspector());
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
{
} …Run Code Online (Sandbox Code Playgroud) structuremap wcf dependency-injection wcf-client endpointbehavior
我已经阅读了Mark Seeman 关于自动模拟的文章,我现在正在编写一个基于该文章的可重复使用的windsor容器.
我执行Mark的文章(基本上直接复制)
主要工作是在AutoMoqResolver课堂上完成的.只要类依赖于接口,这将提供模拟:
public class AutoMoqResolver : ISubDependencyResolver
{
private readonly IKernel kernel;
public AutoMoqResolver(IKernel kernel)
{
this.kernel = kernel;
}
public bool CanResolve(
CreationContext context,
ISubDependencyResolver contextHandlerResolver,
ComponentModel model,
DependencyModel dependency)
{
return dependency.TargetType.IsInterface;
}
public object Resolve(
CreationContext context,
ISubDependencyResolver contextHandlerResolver,
ComponentModel model,
DependencyModel dependency)
{
var mockType = typeof(Mock<>).MakeGenericType(dependency.TargetType);
return ((Mock)this.kernel.Resolve(mockType)).Object;
}
}
Run Code Online (Sandbox Code Playgroud)
将AutoMoqResolver被添加到使用以下实施的容器IWindsorInstaller接口:
public class AutoMockInstaller<T> : IWindsorInstaller
{
public void Install(
IWindsorContainer container,
IConfigurationStore …Run Code Online (Sandbox Code Playgroud) 我面临着与一个奇怪的问题AutoFixture,并AutoMoqCustomization和它如何与具体类的automocking交易.我怀疑我没有很好地使用它,但想知道问题是什么.首先是她的一些背景.假设我有一个我想测试的课程:
public class IdentityApplicationService
{
public IdentityApplicationService(
TenantProvisioningService tenantProvisioningService)
{
// guard clause etc.
_tenantProvisioningService = tenantProvisioningService;
}
}
Run Code Online (Sandbox Code Playgroud)
及其依赖类TenantProvisioningService(TenantProvisioningService的依赖项在这里不相关,因为它们将被自动模拟,我在测试时并不关心):
public class TenantProvisioningService
{
readonly IRoleRepository _roleRepository;
readonly ITenantRepository _tenantRepository;
readonly IUserRepository _userRepository;
public TenantProvisioningService(
ITenantRepository tenantRepository,
IUserRepository userRepository,
IRoleRepository roleRepository)
{
this._roleRepository = roleRepository;
this._tenantRepository = tenantRepository;
this._userRepository = userRepository;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的简单测试:
[Fact]
public void ShouldReturnTenantWhenCallingProvisionTenant()
{
var fixture = new Fixture().Customize(new AutoMoqCustomization());
var mockTenantProvisioningService =
fixture.Freeze<Mock<TenantProvisioningService>>();
var sut = fixture.Create<IdentityApplicationService>();
var …Run Code Online (Sandbox Code Playgroud) 我的应用程序是使用简单的注入器来处理我的ioc.我有一些像下面的代码会做一些自动注册.
RegisterForAssembly(container, webApiLifestyle, typeof(IAddEntityCommand).Assembly, "MyProj.CommandQuery.Commands");
RegisterForAssembly(container, webApiLifestyle, typeof(IGetAllEntityQuery).Assembly, "MyProj.CommandQuery.Queries");
private static void RegisterForAssembly(Container container, WebApiRequestLifestyle webApiLifestyle, Assembly assembly, string nameSpace)
{
var registrations =
from type in assembly.GetExportedTypes()
where type.Namespace == nameSpace
where type.GetInterfaces().Any()
select new { InterfaceType = type.GetInterfaces().Single(), ConcreteType = type };
foreach (var reg in registrations)
{
container.Register(reg.InterfaceType, reg.ConcreteType, webApiLifestyle);
}
}
Run Code Online (Sandbox Code Playgroud)
它基本上是在一个程序集中查找并将任何接口与它的具体命名空间配对.
我希望使用AutoFixture实现类似的功能
private static void RegisterForAssembly(Fixture fixture, Assembly assembly, string nameSpace)
{
var registrations =
from type in assembly.GetExportedTypes()
where type.Namespace == nameSpace
where type.GetInterfaces().Any() …Run Code Online (Sandbox Code Playgroud) 请有人告诉我Git在合并两个分支时的历史方面.
如果我有两个分支都在积极开发并且都包含提交,这类似于以下时间轴:
Branch #1: ----(branch)----C1----------C2-------(merge)------C5
\ /
\ /
\ /
Branch #2: -----------C3----------C4
Run Code Online (Sandbox Code Playgroud)
一旦两个分支合并,分支1的历史如何看待C5(提交#5)?我的印象是Git将合并所有历史记录给我以下内容:
Branch #1: ----------------C1----C3----C2----C4--------------C5
Run Code Online (Sandbox Code Playgroud)
这是正确的理解吗?
如果是这样,在紧急情况下,如何撤消合并,因为分支#2的所有历史肯定会与分支#1的历史交织在一起.
我遇到了AutoFixture的问题,并为它提交了GitHub问题.但是,在这里进行一些搜索似乎有一些类似于我的问题的问题(但是没有解决)所以我想在这里询问是否具有更高的可见性.
问题是:我最近将我的NuGet 2.0项目(packages.config)升级到NuGet 3.0(project.json - 不要与ASP/.NET Core的project.json混淆).除了一组特定的测试外,所有东西都跳了起来:
那些使用AutoFixture的AutoData(或InlineAutoData)理论并进行修饰的测试.
我已经创建了一个非常简单的这个问题的复制品,可以在这里找到:https: //github.com/Mike-EEE/Stash/tree/master/ReSharper.NuGet30
(请注意,该名称反映了问题与ReSharper相关的初步印象,但它确实影响了它和本机VS单元测试运行器.)
您可以尝试构建解决方案,并且应该发现它构建正常,但是在ReSharper的测试运行器和本机VS测试运行器中都找不到测试(请注意我正在运行VS 2015 Update 3).
但是,注释掉这些行并重建应该成功发现所有测试.
这是一个头脑风暴,并且阻止我继续.我有一个考虑因素吗?FWIW,我已清空了我的%TEMP%\VisualStudioTestExplorerExtensions作为的xUnit的文档中建议,也没有工作,要么.
任何帮助将不胜感激!
unit-testing xunit.net autofixture vs-unit-testing-framework nuget
作为主题陈述.如何将一天额外的一天添加到所选用户帐户.
我知道AD遵循Windows文件时间.有谁知道最简单和最少编写代码的方法?
我需要StructureMap.ObjectFactory在ASP.NET MVC 3应用程序中初始化.
ObjectFactory.Initialize(x => x.For<Db>().HttpContextScoped().Use<Db>());
Run Code Online (Sandbox Code Playgroud)
我必须做的Application_BeginRequest还是Application_Start?
.net c# structuremap dependency-injection inversion-of-control
我有一个新的 MacOS Catalina 10.15.6,我正在按照此链接中的步骤显示 git 分支名称在终端 macos 中cd,这样每当我在 git 存储库中时,我就可以在终端上显示分支名称。
我在我的主目录中,所以当我运行时ls -la,我看不到以下任何文件
.zshrc, .bashrc, .bash_profile, .zprofile
Run Code Online (Sandbox Code Playgroud)
列表中显示的唯一相关文件是.bash_history和.zsh_history。
这些是否位于不同的路径上,或者我是否错过了该过程中的任何步骤?
我想保护一个简单的WCF服务,从客户端发送用户名和密码,并使用CustomUserNamePasswordValidator.对于我在Web上尝试的每个例子,我都被困在巨大的配置和模糊的错误,SSL,证书等...
最相似的替代方法(让你更好地理解)是将"serviceUsername"和"servicePassword"参数(可能是散列)传递给服务的每个方法并在此处执行身份验证,但我承认这是一个丑陋和肮脏的解决方案.
我不介意加密凭证,因为它不是一个安全关键服务.我只需要一种基本的保护形式.
谢谢!
亚历山德罗
c# ×6
autofixture ×4
wcf ×3
.net ×2
structuremap ×2
unit-testing ×2
asmx ×1
asp.net ×1
asp.net-mvc ×1
automocking ×1
automoq ×1
bash ×1
cookies ×1
git ×1
git-merge ×1
https ×1
merge ×1
moq-3 ×1
mvccontrib ×1
nuget ×1
performance ×1
powershell ×1
security ×1
singleton ×1
terminal ×1
wcf-client ×1
xunit.net ×1
zsh ×1