public static ServiceParams GetServiceParams(this IServiceProvider sp, IEnumerable <Type> assemblyTypes, IEnumerable <KeyValuePair <string, object> > extends = null) { var svcParams = new ServiceParams { { "assemblies", assemblyTypes.Append(typeof(ServiceCollectionExtensions)).GetAssembliesByTypes() } }; if (extends == null || !extends.Any()) { return(svcParams); } var conParams = svcParams.Concat(extends); // to avoid a side-effect then we don't manipulate directly ServiceParams in the input var result = new ServiceParams(); foreach (var param in conParams) { result.Add(param.Key, param.Value); } return(result); }
public static ServiceParams ExtendServiceParams(this ServiceParams serviceParams, IEnumerable <KeyValuePair <string, object> > extends = null) { if (extends == null || !extends.Any()) { return(serviceParams); } var conParams = serviceParams.Concat(extends); // to avoid a side-effect then we don't manipulate directly ServiceParams in the input var result = new ServiceParams(); foreach (var param in conParams) { result.Add(param.Key, param.Value); } return(result); }