/// <summary> /// Implementors should perform any initialization logic. /// </summary> public void Initialize() { PaymentRegisters = _iocManager.ResolveAll <IPaymentRegister>()?.ToList(); PaymentCallbackActions = _iocManager.ResolveAll <IPaymentCallbackAction>()?.ToList(); ToPayServices = _iocManager.ResolveAll <IToPayService>()?.ToList(); //日志函数 void LogAction(string tag, string message) { if (tag.Equals("error", StringComparison.CurrentCultureIgnoreCase)) { Logger.Error(message); } else { Logger.Debug(message); } } if (PaymentRegisters != null) { foreach (var action in PaymentRegisters) { // action.Build(LogAction).Wait(); } } PayNotifyConfig(LogAction); }
public static async Task <ILocalizationDictionary> Create(string sourceName, string cultureCode, IIocManager iocManager) { var dictionary = new DbLocalizationDictionary(sourceName, CultureInfo.GetCultureInfo(cultureCode)); var dublicateNames = new List <string>(); var providers = iocManager.ResolveAll <ILocalizationProvider>(); foreach (var provider in providers) { foreach (var item in await provider.getLocalizationDicionary(sourceName, cultureCode)) { if (string.IsNullOrEmpty(item.Key)) { throw new LocalizationException(StringLocal.Format("The key is empty in given dictionary.")); } if (dictionary.Contains(item.Key)) { dublicateNames.Add(item.Key); } dictionary[item.Key] = item.Value.NormalizeLineEndings(); } } if (dublicateNames.Count > 0) { throw new LocalizationException( StringLocal.Format("A dictionary can not contain same key twice. There are some duplicated names: " + string.Join(", ", dublicateNames))); } return(dictionary); }
/// <summary> /// 注册所有实现IEventHandler<TEventData> 接口,获取所有事件处理器 /// </summary> /// <param name="e"></param> public void InitEventHandler(IIocManager iocManager) { var list = iocManager.ResolveAll <IEventHandler>(); foreach (var component in list) { var interfaces = component.GetType().GetInterfaces(); foreach (var @interface in interfaces) { if (!typeof(IEventHandler).IsAssignableFrom(@interface)) { continue; } var genericArgs = @interface.GetGenericArguments(); if (genericArgs.Length == 1) { //Register(genericArgs[0], new IocHandlerFactory(_iocResolver, component)); } } } }