草庐IT

PATTERN_SIMPLE_GLOB

全部标签

c# - 使用 Simple Injector 的 Per Thread 和 Per Web Request 的混合生活方式

我正在使用SimpleInjector作为我的IoC库。我根据网络请求注册了DbContext,它工作正常。但是有一项任务是我在后台线程中运行它。所以,我在创建DbContext实例时遇到了问题。例如Service1有一个DbContext实例Service2有一个DbContext的实例Service1和Service2从后台线程运行。Service1获取实体并将其传递给Service2Service2使用该实体,但实体与DbContext分离其实问题就出在这里:Service1.DbContext和Service2.DbContext的区别。似乎当我在ASP.NETMVC中的单独线

c# - "An assembly with the same simple name has already been imported"没有重复引用的错误

我收到以下错误:errorCS1704:Anassemblywiththesamesimplename'Interop.xxx.dll,Version=1.0.0.0,Culture=neutral,PublicKeyToken=nullhasalreadybeenimported.Tryremovingoneofthereferencesorsignthemtoenableside-by-side.我所看到的一切都表明我引用了两个同名的程序集,我需要删除其中一个。但是,我已经检查过并且只引用了一次。这也仅在我使用msbuild从我的开发箱上的命令行构建时发生。如果我通过VisualS

c# - "Enum as immutable rich-object": is this an anti-pattern?

我经常看到并使用带有附加属性的枚举来做一些基本的事情,例如提供显示名称或描述:publicenumMovement{[DisplayName("TurnedRight")]TurnedRight,[DisplayName("TurnedLeft")][Description("Execute90degreeturntotheleft")]TurnedLeft,//...}并且有一组扩展方法来支持属性:publicstaticstringGetDisplayName(thisMovementmovement){...}publicstaticMovementGetNextTurn(thi

c# - 业务对象数据访问层的最佳 "pattern"

我正试图找出最简洁的方法来做到这一点。目前我有一个客户对象:publicclassCustomer{publicintId{get;set;}publicstringname{get;set;}publicListemailCollection{get;set}publicCustomer(intid){this.emailCollection=getEmails(id);}}然后我的电子邮件对象也很基础。publicclassEmail{privateintindex;publicstringemailAddress{get;set;}publicintemailType{get;s

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

我在这个表达式中遇到了上述错误:varaggregate=fromtinentities.TraceLinesjoinminentities.MethodNames.Where("it.NameLIKE@searchTerm",newObjectParameter("searchTerm",searchTerm))ont.MethodHashequalsm.MethodHashwhere(t.CallTypeId&(int)types)==t.CallTypeId&&t.UserSessionProcessId==m_SessionIdgrouptbym.Nameintodselect

c# - 这是 "Bastard injection anti-pattern"的一个很好的例子吗?

我看到首席开发人员正在编写这样的代码,并且在阅读MarkSeemann的书“.NET中的依赖注入(inject)”时,我想知道特定的"new"是否是“外来的”,因此是“BastardInjection”“??publicclassSessionInitServiceManager{protectedreadonlyICESTraceManager_traceManager;protectedreadonlyILogger_logger;protectedreadonlyIAggregateCalls_aggregator;protectedreadonlyIMultiCoreRepos

c# - Simple Injector 是否支持 MVC 4 ASP.NET Web API?

我是SimpleInjectorIOC容器的新手。我将开始在一个需要使用MVC4ASP.NETWebAPI的Multi-TenancyASP.NETMVC实现的项目中工作。我的问题是:Simpleinjector是否支持MVC4ASP.NETWebAPI?阅读简单的注入(inject)器文档,如this引用了MVC3,我想知道是否也支持MVC4。 最佳答案 DoesSimpleinjectorIOCsupportMVC4ASP.NETWebAPI?目前不支持MVC4WebAPI,future会支持。Theintegrationgui

javascript - _以 "revealing module pattern"样式编写的 JSDoc'ing Javascript 文件的最佳实践?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我的大多数Javascript函数都相对简单,并且需要它们的副作用:我使用jQuery来操作DOM或进行Ajax调用。我更喜欢以“揭示模块模式”的风格编写我的函数。我justdiscoveredJSDoc-注释Javascript文件有一个好处:在annotations的帮助下,Eclipse的JS开发工具可以解析我的JS文件和filltheEclipseOutlineView(否则将为空

javascript - Angular 模块 : event bus or mediator pattern/service 中的全局通信

到目前为止,我已经看到了很多问题的解决方案。当然,最简单的方法是在$rootScope中$emit事件作为事件总线,例如(https://github.com/btilford/anti-patterns/blob/master/angular/Angular.md)angular.module('myModule').directive('directiveA',function($rootScope){return{link:function($scope,$element){$element.on('click',function(event){$rootScope.$emit(

自动格式化 Pattern 的 JavaScript RegExp

我在stackflow社区看到很多格式化电话或数字(逗号和小数)的函数,比如这个问题here和别的。这是我想要的:第1步:为这样的模式维护库:varlibrary={fullDate:{pattern:/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/,error:"InvalidDateformat.UseYYYY-MM-DDformat."},fullDateTime:{pattern:/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}[0-9]{1,2}:[0-9]{1,2}$/,error:"InvalidDateTimeformat.UseYY