コード例 #1
0
 public FlowManager(
     IConfiguration configuration,
     IStateManager stateManager,
     IContextProvider contextProvider,
     INamedSemaphore namedSemaphore,
     IActionProvider actionProvider,
     ISender sender,
     IDocumentSerializer documentSerializer,
     IEnvelopeSerializer envelopeSerializer,
     IArtificialIntelligenceExtension artificialIntelligenceExtension,
     IVariableReplacer variableReplacer,
     ILogger logger,
     ITraceManager traceManager,
     IUserOwnerResolver userOwnerResolver,
     IInputExpirationHandler inputExpirationHandler,
     Application application)
 {
     _configuration      = configuration;
     _stateManager       = stateManager;
     _contextProvider    = contextProvider;
     _namedSemaphore     = namedSemaphore;
     _actionProvider     = actionProvider;
     _sender             = sender;
     _documentSerializer = documentSerializer;
     _envelopeSerializer = envelopeSerializer;
     _artificialIntelligenceExtension = artificialIntelligenceExtension;
     _variableReplacer       = variableReplacer;
     _logger                 = logger;
     _traceManager           = traceManager;
     _userOwnerResolver      = userOwnerResolver;
     _inputExpirationHandler = inputExpirationHandler;
     _applicationIdentity    = application.Identity;
     _applicationNode        = application.Node;
 }
コード例 #2
0
        public CommandProcessor(IServiceLocator services, IVariableReplacer variableReplacer, IScriptLog scriptLog)
        {
            _services = services;
            _variableReplacer = variableReplacer;
            _scriptLog = scriptLog;
            _tokenizer = Tokenizer.With(TokenDefinitionRegistry.ClientCommands());

            _tokenHandlers = new SimpleDictionary<string, ITokenHandler>();
            _tokenHandlers["script"] = new ScriptTokenHandler();
            _tokenHandlers["scriptcommand"] = new ScriptCommandTokenHandler();
            _tokenHandlers["send"] = new SendTokenHandler();
            _tokenHandlers["globalvar"] = new GlobalVarTokenHandler();
            _tokenHandlers["parse"] = new ParseTokenHandler();
        }
コード例 #3
0
ファイル: Runtime.cs プロジェクト: codeflood/chel
        /// <summary>
        /// Create a new instance.
        /// </summary>
        public Runtime()
        {
            var nameValidator = new NameValidator();
            var commandDescriptorGenerator = new CommandAttributeInspector();

            _commandRegistry = new CommandRegistry(nameValidator, commandDescriptorGenerator);

            _commandServices  = new CommandServices();
            _parser           = new Parser();
            _variableReplacer = new VariableReplacer();

            _sessionObjectTypes = new ScopedObjectRegistry();
            _sessionObjectTypes.Register <VariableCollection>();

            _commandRegistry.Register(typeof(Help));
            _commandRegistry.Register(typeof(Var));

            _commandServices.Register(_commandRegistry);
            _commandServices.Register <IPhraseDictionary>(new PhraseDictionary());
        }
コード例 #4
0
        /// <summary>
        /// Create a new instance.
        /// </summary>
        /// <param name="commandRegistry">The <see cref="ICommandRegistry" /> used to resolve commands.</param>
        /// <param name="variableReplacer">The <see cref="IVariableReplacer" /> used to replace variables.</param>
        /// <param name="variables">The variables available for substitution.</param>
        public CommandParameterBinder(ICommandRegistry commandRegistry, IVariableReplacer variableReplacer, VariableCollection variables)
        {
            if (commandRegistry == null)
            {
                throw new ArgumentNullException(nameof(commandRegistry));
            }

            if (variableReplacer == null)
            {
                throw new ArgumentNullException(nameof(variableReplacer));
            }

            if (variables == null)
            {
                throw new ArgumentNullException(nameof(variables));
            }

            _commandRegistry  = commandRegistry;
            _variableReplacer = variableReplacer;
            _variables        = variables;
        }
コード例 #5
0
 public FlowManager(
     IConfiguration configuration,
     IStateManager stateManager,
     IContextProvider contextProvider,
     INamedSemaphore namedSemaphore,
     IActionProvider actionProvider,
     ISender sender,
     IDocumentSerializer documentSerializer,
     IEnvelopeSerializer envelopeSerializer,
     IArtificialIntelligenceExtension artificialIntelligenceExtension,
     IVariableReplacer variableReplacer)
 {
     _configuration      = configuration;
     _stateManager       = stateManager;
     _contextProvider    = contextProvider;
     _namedSemaphore     = namedSemaphore;
     _actionProvider     = actionProvider;
     _sender             = sender;
     _documentSerializer = documentSerializer;
     _envelopeSerializer = envelopeSerializer;
     _artificialIntelligenceExtension = artificialIntelligenceExtension;
     _variableReplacer = variableReplacer;
 }
コード例 #6
0
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);

            theGameState.Set(ComponentKeys.Roundtime, "0");

            theLog = new InMemoryScriptLog();

            theReplacer = new VariableReplacer();
            theGameStream = new GameStream(theGameState);

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLog);
            theServices.Add<IVariableReplacer>(theReplacer);
            theServices.Add<IIfBlockExecuter>(
                new IfBlockExecuter(
                    new WaitForTokenHandler(theGameState, theGameStream),
                    new WaitForReTokenHandler(theGameState, theGameStream),
                    new MatchWaitTokenHandler(theGameState, theGameStream)
                ));
            theServices.Add<IGameStream>(theGameStream);

            theCommandProcessor = new CommandProcessor(theServices, theReplacer, theLog);
            theServices.Add<ICommandProcessor>(theCommandProcessor);

            theLocalVars = new SimpleDictionary<string, string>();

            theScriptContext = new ScriptContext("1", "if", CancellationToken.None, theServices, theLocalVars);
            theScriptContext.DebugLevel = 5;

            theHandler = new IfTokenHandler();
        }
コード例 #7
0
        public void SetUp()
        {
            theScript = new StubScript();
            theLoader = new StubScriptLoader();
            theLogger = new InMemoryScriptLog();

            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);

            theReplacer = new VariableReplacer();

            theServices = new InMemoryServiceLocator();

            theGameStream = new GameStream(theGameState);

            var waitForTokenHandler = new WaitForTokenHandler(theGameState, theGameStream);
            var waitForReTokenHandler = new WaitForReTokenHandler(theGameState, theGameStream);
            var matchWaitTokenHandler = new MatchWaitTokenHandler(theGameState, theGameStream);

            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theLogger);
            theServices.Add<ICommandProcessor>(new CommandProcessor(theServices, theReplacer, theLogger));
            theServices.Add<IVariableReplacer>(theReplacer);
            theServices.Add<IIfBlocksParser>(new IfBlocksParser());
            theServices.Add<WaitForTokenHandler>(waitForTokenHandler);
            theServices.Add<WaitForReTokenHandler>(waitForReTokenHandler);
            theServices.Add<MatchWaitTokenHandler>(matchWaitTokenHandler);
            theServices.Add<IIfBlockExecuter>(new IfBlockExecuter(waitForTokenHandler, waitForReTokenHandler, matchWaitTokenHandler));

            theRunner = new ScriptRunner(theServices, theLoader, theLogger);

            theRunner.Create = () => theScript;
        }
コード例 #8
0
        public void SetUp()
        {
            theGameState = new StubGameState();
            theGameServer = new StubGameServer(theGameState);
            theScriptLog = new InMemoryScriptLog();

            theReplacer = new VariableReplacer();

            theLocalVars = new SimpleDictionary<string, string>();

            theServices = new InMemoryServiceLocator();
            theServices.Add<IGameServer>(theGameServer);
            theServices.Add<IGameState>(theGameState);
            theServices.Add<IScriptLog>(theScriptLog);
            theServices.Add<IVariableReplacer>(theReplacer);

            theScriptContext = new ScriptContext("1", "vartoken", CancellationToken.None, theServices, theLocalVars);
            theHandler = new VarTokenHandler();
        }