public void ProcessInterfaceDirector(ResourceActivationContext context, InterfaceDirector director) { if (context.IsClosed) { return; } context.Open(); if (director.Commands == null || director.Commands.Length == 0) { context.Close(); return; } BatchProcessor iter = new BatchProcessor(director.Commands.Length, context.Close); foreach (var command in director.Commands) { IInterfaceCommandHandler handler = null; if (m_handlers.TryGetValue(command.Type, out handler)) { handler.ProcessInterfaceCommand(context, command, () => iter++); } else { throw new NotSupportedException("Unsupported interface command type " + command.Type); } } }
public void RegisterHandler(string type, IInterfaceCommandHandler handler) { m_handlers[type] = handler; }