哪种设计模式适用于普通服务 [英] Which design pattern for common service

查看:58
本文介绍了哪种设计模式适用于普通服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试改进我的设计决策,并希望获得以下方面的帮助;



1.创建一个服务层,在SAP上完成插入/更新/删除系统。在我的VM中使用Unity来解析服务。 - 完成

2.我需要一个首先运行模拟的验证层。这可以通过在RFC参数IsCommit中发送/设置来完成。该层还将记录SAP引发的任何问题。



所以我不想复制这一层的代码。但希望此层运行相同的代码,但只添加新的RFC参数。它还将记录通过模拟提出的任何问题。对我的方法有什么建议吗?像解决服务/方法的通用服务,设置IsCommit参数然后执行基本服务?



VM



Trying to improve my design decisions and would like some assistance on the following;

1. Create a service layer that completes Insert/Update/Delete on a SAP system. Using Unity in my VM to resolve the service. - Done
2. I need a verification layer that first runs a simulation. This is simple done by sending/setting in a RFC parameter IsCommit. This layer will also log any issues that is raised by SAP.

So I dont want to duplicate the code for this layer. But want this layer to run the same code but only add the new RFC Parameter. It will also log any issues raised through the simulation. Any suggestions on my approach? Something like a generic service that resolves the service/ method, sets the IsCommit paramater and then executes the base service?

VM

public static BankAccountVM Save(BankAccountVM bankVM)
        {
            var svc = GlobalContext.Current.Container.Resolve<IBankService>();
            BankAccount bankAccount = bankVM.GetModel();

            svc.Update(bankAccount);
            return bankVM;
        }





服务层



Service Layer

public class BankService : BaseService, IBankService
{
    private readonly Common _common;
    private readonly IUnityContainer _container;
    private readonly LookupTextValues _textHelp;

    public bool IsCommit { get; set; }

    public void Update(BankAccount bankAccount)
    {
          //Breakdown bank account into rfc paramters

          if(IsCommit )
          {
               //add IsCommit RFC parameter
          }
    }
}





验证服务?



Verification service?

推荐答案

使用额外参数创建覆盖。在没有参数的版本中,使用参数调用一个,只需将其设置为默认值(如您所示)。

示例:



Create override with extra parameter. In the version without parameter, call the one with parameter, just set it to some default (as you need).
Example:

Update (BankAccount ba) {
    Update (ba, false);
}

Update(BankAccount ba, boolean isCommit)







如果这有帮助请花时间接受解决方案。谢谢




If this helps please take time to accept the solution. Thank you


这篇关于哪种设计模式适用于普通服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆