public UncloseOrderWatcher(OrderContext orderContext, QuotationContext qutationContext, IOrderStore store, IPricePolicyStore pricePolicyStore, OrderServiceBuilder builder, OrderNotifyManager orderNotifyer) { if (orderContext == null) { throw new ArgumentNullException(nameof(orderContext)); } if (qutationContext == null) { throw new ArgumentNullException(nameof(qutationContext)); } if (store == null) { throw new ArgumentNullException(nameof(store)); } if (pricePolicyStore == null) { throw new ArgumentNullException(nameof(pricePolicyStore)); } if (builder == null) { throw new ArgumentNullException(nameof(builder)); } _orderContext = orderContext; _qutationContext = qutationContext; _store = store; _pricePolicyStore = pricePolicyStore; _builder = builder; _orderNotifyer = orderNotifyer; DefaultClosePricePolicy = new RealTimeCloseOpenPricePolicy(); }
public static OrderServiceBuilder AddOrderStoreDapper(this OrderServiceBuilder orderServiceBuilder, string connectionstring) { if (connectionstring == null) { throw new ArgumentNullException(nameof(connectionstring)); } var services = orderServiceBuilder.Services; services.AddScoped(typeof(IOrderPolicyStore), typeof(OrderPolicyStore)); services.AddScoped(typeof(IPricePolicyStore), typeof(PricePolicyStore)); services.AddScoped(typeof(IGameStore), typeof(GameStore)); services.AddScoped(typeof(IOrderStore), typeof(OrderStore)); services.AddSingleton(sp => { var store = sp.GetRequiredService <IOrderStore>(); var currentId = store.GetLastOrderId(orderServiceBuilder.ServerName) ?? 0; var result = new OrderIdGenerator(currentId); return((IOrderIdGenerator)result); }); services.AddDbUow(() => { var conn = new SqlConnection(connectionstring); return(new OrderUow(conn)); }, true); return(orderServiceBuilder); }
AddOrderService(this IServiceCollection services, bool enableCloseService, string serverName) { services.AddSingleton <OrderContext>(); services.AddScoped(typeof(OrderService)); services.AddSingleton(typeof(UncloseOrderWatcher)); services.AddSingleton(sp => { var notifies = sp.GetServices <IOrderNotify>(); return(new OrderNotifyManager(notifies)); }); var result = new OrderServiceBuilder(services, true, enableCloseService, serverName); services.AddSingleton(result); return(result); }