2
我正在處理生成數據庫訪問代碼並使用靜態對象進行用戶標識的桌面應用程序。將用戶信息傳遞到數據訪問
現在我們需要通過webservice公開一些邏輯,我們正在尋找最少侵入性的形式來將用戶信息沿着管道推送到數據庫訪問類。
我們來到這了是一個委託傳遞給插入/更新方法,看起來像這樣:
public delegate string GetLogin();
public class BaseEntity : BaseNotifiableEntity, System.ComponentModel.IDataErrorInfo
{
public GetLogin Login { get; set; }
(...)
}
public static class BaseEntityHelper
{
public static SqlCommand buildUpdateCommand(BaseEntity entity)
{
UpdateDefaultValues(entity, false);
(...)
}
public static void UpdateDefaultValues(BaseEntity entity, bool affectCreationFields)
{
if (entity.Login == null && AppServer.RunningApplication.CurrentUser == null)
throw new Exception("Something went wrong");
(...)
}
}
因此,在我們的邏輯將會有這樣的事情:
public class Service
{
T_DIST_Service record;
(...)
public bool Update(DataAccess.Base.GetLogin login)
{
record.Login = login;
(...)
record.Update();
}
}
這當然涉及到改變應用程序中的很多方法。 所以我想知道是否有無縫的方式來完成這個使用依賴注入(例如)。
也許你們中的一些人已經走上了這條路,並有一些見解分享。 謝謝你的時間。
編輯1: 使用.NET
哪個平臺? 。淨? –
我的不好,這是.NET的平臺 –