public static void AddRequestProviders(this IServiceCollection services, Action <WwtOptions> config) { var manager = new EndpointManager(); var types = typeof(RequestProvider).Assembly.GetTypes() .Where(t => !t.IsAbstract && typeof(RequestProvider).IsAssignableFrom(t)); foreach (var type in types) { services.AddSingleton(type); foreach (var endpoint in type.GetCustomAttributes <RequestEndpointAttribute>()) { manager.Add(endpoint.Endpoint, type); } } services.AddSingleton(manager); services.AddSingleton <IFileNameHasher, Net4x32BitFileNameHasher>(); services.AddSingleton <IOctTileMapBuilder, OctTileMapBuilder>(); services.AddSingleton <IMandelbrot, Mandelbrot>(); services.AddSingleton <IVirtualEarthDownloader, VirtualEarthDownloader>(); services.AddSingleton <IDevDataAccessor, DevDataAccessor>(); var options = new WwtOptions(); config(options); services.AddSingleton(options); }
public static void AddEndpoint(EndPointRow pEndPointRow, EndpointContext pEndpointContext) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndPointRow, pEndpointContext)) { //TODO: NEW DAL - VirtualSwitch pEndPointRow.Virtual_switch_id = AppConstants.DefaultVirtualSwitchId; EndpointManager.Add(_db, pEndPointRow, pEndpointContext); //CarrierAcctManager.AddDialPeer(_db, pEndPointRow, pEndpointContext); if (pEndpointContext.CarrierAcctEPMapRowToAdd != null && pEndpointContext.CarrierAcctEPMapRowToAdd.Length > 0) { foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToAdd) { _carrierAcctEPMapRow.End_point_id = pEndPointRow.End_point_id; CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } if (pEndpointContext.CustomerAcct != null) { if (pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers != null && pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers.Length > 0) { foreach (var _accessNumber in pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers) { var _newDialPeer = new DialPeerRow { End_point_id = pEndPointRow.End_point_id, Prefix_in = _accessNumber.Number.ToString(), Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow); } } else { var _newDialPeer = new DialPeerRow { End_point_id = pEndPointRow.End_point_id, Prefix_in = pEndpointContext.CustomerAcct.PrefixIn, Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow); } } _tx.Commit(); } } }