private void SetProcessor() { try { eventLog1.WriteEntry("Processore da instanziare: " + Settings.Default.PROCESSOR_ASSEMBLY, EventLogEntryType.Information); eventLog1.WriteEntry("Classe da instanziare: " + Settings.Default.PROCESSOR_CLASS, EventLogEntryType.Information); //definisco il processore come lista di processori _processor = new IServiceProcessor[] { }; //Recupera gli assembly e i nomi delle classi string[] assemblyNames = GetAssemblyNames(); string[] classNames = Settings.Default.PROCESSOR_CLASS.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < assemblyNames.Length; i++) { Assembly asm = Assembly.LoadFrom(assemblyNames[i]); //verifica che non sia nullo if (asm == null) { eventLog1.WriteEntry(string.Format("Assembly del processore {0} non istanziato o non trovato!", assemblyNames[i])); } else { //instanzia la classe processore IServiceProcessor p = (IServiceProcessor)asm.CreateInstance(classNames[i], true, System.Reflection.BindingFlags.CreateInstance, null, null, new System.Globalization.CultureInfo("it-IT"), null); if (p != null) { Array.Resize <IServiceProcessor>(ref _processor, _processor.Length + 1); _processor[_processor.Length - 1] = p; } } } //verifica della presenza della classe if (_processor.Length == 0) { eventLog1.WriteEntry("Classe/i del processore non istanziata/e o non trovata!"); } else { eventLog1.WriteEntry("Processore e classe del processore correttamente instanziate", EventLogEntryType.Information); } } catch (Exception ex) { string error = "Impossibile instanziare il processore del servizio!"; error += Environment.NewLine + ex.Message; if (ex.InnerException != null) { error = error + "; inner: " + ex.InnerException.Message; } eventLog1.WriteEntry(error, EventLogEntryType.Error); } }
private void BuildConfig() { CheckIsBuild(); if (config.Communication == null) { throw new InvalidOperationException("Communication is not config."); } if (config.Serializer == null) { throw new InvalidOperationException("Serializer is not config."); } if (config.ServiceProvider == null) { throw new InvalidOperationException("ServiceProvider is not config."); } if (config.ProtocolStackFactory == null) { config.ProtocolStackFactory = new DefaultProtocolStackFactory(); } if (config.RouteFactory == null) { config.RouteFactory = new DefaultRouteFactory(); } if (config.LoginValidator == null) { config.LoginValidator = new DefaultLoginValidator(); } if (config.ServiceInvoker == null) { config.ServiceInvoker = new DefaultServiceInvoker(); } if (config.ServiceProcessor == null) { config.ServiceProcessor = new DefaultServiceProcessor(); } else { IServiceProcessor last = config.ServiceProcessor; while (last.Next != null) { last = last.Next; } last.Next = new DefaultServiceProcessor(); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="config">NodeServer配置</param> public DefaultNodeServer(NodeServerConfig config) { ValidateConfig(config); logger = LoggerManager.ServerLoggerFactory.CreateLogger <DefaultNodeServer>(); server = config.Communication; protocolStackFactory = config.ProtocolStackFactory; serviceProvider = config.ServiceProvider; RouteManager = config.RouteFactory.CreateRouteManager(); routeDescriptor = config.RouteFactory.CreateRouteDescriptor(); if (config.ServiceConfigs != null) { routeDescriptor.SetServiceConfig(config.ServiceConfigs); } serializer = config.Serializer; serviceInvoker = config.ServiceInvoker; serviceProcessor = config.ServiceProcessor; loginValidator = config.LoginValidator; this.config = config ?? throw new InvalidOperationException("Argument config is null."); }
/// <summary> /// 添加服务处理器 /// </summary> /// <param name="serviceProcessor"></param> /// <returns></returns> public INodeServerBuilder AddServiceProcessor(IServiceProcessor serviceProcessor) { CheckIsBuild(); if (serviceProcessor == null) { return(this); } if (config.ServiceProcessor == null) { config.ServiceProcessor = lastServiceProcessor = serviceProcessor; } else { lastServiceProcessor.Next = serviceProcessor; lastServiceProcessor = serviceProcessor; } return(this); }
public AdvertisementController(IServiceProcessor serviceProcessor, IAdvertisementService advertisementService, IMapper mapper) { this.serviceProcessor = serviceProcessor; this.advertisementService = advertisementService; this.mapper = mapper; }
/// <summary> /// Basekt controller. /// </summary> /// <param name="serviceProcessor">Service for processing domain requests.</param> public BasketController(IServiceProcessor serviceProcessor) { this.serviceProcessor = serviceProcessor; }
public ControllerImplBase(IServiceProcessor serviceProcessor) { this.serviceProcessor = serviceProcessor; }
public OrderController(IOrderService orderService, IServiceProcessor serviceProcessor) { this.orderService = orderService; this.serviceProcessor = serviceProcessor; }
public MenuController(IMenuService menuService, IServiceProcessor serviceProcessor, IMapper mapper) { this.menuService = menuService; this.serviceProcessor = serviceProcessor; this.mapper = mapper; }
public ContactsController(IServiceProcessor serviceProcessor) : base(serviceProcessor) { }
/// <summary> /// Constructor. /// </summary> /// <param name="serviceProcessor">Service for processing domain requests.</param> public ProductsController(IServiceProcessor serviceProcessor) { this.serviceProcessor = serviceProcessor; }
public RestaurantController(IRestaurantService restaurantService, IServiceProcessor serviceProcessor, IMapper mapper) { this.restaurantService = restaurantService; this.serviceProcessor = serviceProcessor; this.mapper = mapper; }
public UserController(IUserService userService, IMapper mapper, IServiceProcessor serviceProcessor) { this.userService = userService; this.mapper = mapper; this.serviceProcessor = serviceProcessor; }