简体   繁体   English

是否有.NET(C#)的信号发射器/使用者引擎(如Django)

[英]is there a signal emiter/consumer engine (like in Django) for .NET (C#)

Has .NET (C#) anything like Django's Signals engine? .NET(C#)是否像Django的Signals引擎一样?

Our business logic become really complicated over few years of adding new features. 在添加新功能的几年中,我们的业务逻辑变得非常复杂。 I'm going to re-architecture it. 我将重新架构它。 Currently all features are very coupled that makes regression errors while changing something one one place - some other place may be broken. 当前,所有功能都非常紧密地耦合在一起,从而在一个地方更改某些内容时可能导致回归错误,而其他地方可能会损坏。

I really like Django's apps idea where separate applications introduce new functionality and are absolutely separate. 我真的很喜欢Django的应用程序创意,其中独立的应用程序引入了新功能,并且绝对是独立的。 Communication between apps is implemented though signals. 应用之间的通信通过信号来实现。

I wounder if there is something in .NET that allows to divide project business to many separated "apps" (plug-ins, zones, modules, you name it) and make communication using some kind of "signals". 我很讨厌.NET中是否有某些东西可以将项目业务划分为许多单独的“应用程序”(插件,区域,模块,您可以命名),并使用某种“信号”进行通信。

For example we have simple order flow. 例如,我们有简单的订单流程。 We can add "coupon app" that if exists in the project adds abilities to use discount coupon. 我们可以添加“优惠券应用”,如果项目中存在该优惠券,则会添加使用优惠券的功能。 We can add "cross sale" module that if exists adds abilities to offer cross-sale products Email notification module that if exists adds abilities to send order email notifications. 我们可以添加“交叉销售”模块(如果存在)添加功能以提供交叉销售产品电子邮件通知模块(如果存在)添加功能以发送订单电子邮件通知。 But in the same time all this modules are "self-contained" means that communication between them is done using emitting signals (ORDER_PROCCESS_START, ORDER_SUCCESS, etcs) and other modules can subscribe to this signals and process them in required way. 但是,与此同时,所有这些模块都是“独立的”,这意味着它们之间的通信是使用发射信号(ORDER_PROCCESS_START,ORDER_SUCCESS等)完成的,其他模块可以订阅此信号并以所需方式对其进行处理。

This architecture is not related to web, all business logic is processed on the server side like without working with HTTP directly. 此体系结构与Web无关,所有业务逻辑都在服务器端进行处理,就像不直接使用HTTP一样。

I wonder if it's good architecture from code maintaining and testing point of few, is it possible to do this in .NET? 我不知道从代码维护和测试的角度来看,这是否是一个好的架构,是否可以在.NET中做到这一点? Any drawbacks that I don't realize now? 我现在没有意识到的任何弊端?

I am not to familiar with Django - but immediately two frameworks come to mind 我不熟悉Django,但立即想到了两个框架

1) Prism 1) 棱镜

2) MEF 2) MEF

Now, I know thatt Prism is really a UI Pattern - but the event agregator which they use in it may be useful in segmenting / messaging between loosely coupled projects 现在,我知道Prism实际上是一个UI模式-但是他们在其中使用的事件聚合器可能对松散耦合的项目之间的分段/消息传递很有用。

My hunch is though something like MEF may be closer to what you are wanting, where you can make plugins to extend the functionality of the application. 我的直觉是,像MEF这样的东西可能更接近您想要的东西,您可以在其中制作插件来扩展应用程序的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM