/// <summary>
        ///     Initializes a new instance of the <see cref="T:System.Object" /> class using the current
        ///     directory for the settings path.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when one or more required arguments are null.
        /// </exception>
        /// <param name="container"> The container to use for inversion of control. </param>
        /// <param name="engineName"> Name of the chat engine. </param>
        public AimlStatementHandler(
            [NotNull] IObjectContainer container,
            [NotNull] string engineName)
        {
            //- Validate
            if (engineName.IsEmpty()) { throw new ArgumentNullException(nameof(engineName)); }
            if (container == null) { throw new ArgumentNullException(nameof(container)); }

            // Set up simple internal fields
            Container = container;
            _console = container.TryProvide<IConsole>();
            _chatHistory = new ChatHistoryProvider(container);

            // Create and set up the chat engine
            ChatEngine = new ChatEngine(container, engineName);

            // Register the engine so other places can find it
            ChatEngine.RegisterAsProvidedInstance(container);

            // Create basic chat helpers / ancillary classes
            _user = new User(Resources.ChatUserName.NonNull());
            _chatHandlerProvider = new ChatHandlersProvider(container, ChatEngine);

            InitializeChatEngine();
        }
Exemple #2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="chatEngine" /> is <see langword="null" />.</exception>
        internal ChatProcessor([NotNull] ChatEngine chatEngine)
        {
            if (chatEngine == null) { throw new ArgumentNullException(nameof(chatEngine)); }

            // Store helpers
            _chatEngine = chatEngine;
            _tagFactory = new TagHandlerFactory(chatEngine);
            _aimlLoader = new AimlLoader(chatEngine);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ChatEngineLibrarian" /> class.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="chatEngine" /> is <see langword="null" />.</exception>
        internal ChatEngineLibrarian([NotNull] ChatEngine chatEngine)
        {
            //-Validate
            if (chatEngine == null)
            {
                throw new ArgumentNullException(nameof(chatEngine));
            }

            _chatEngine = chatEngine;

            // Initialize settings dictionaries
            GlobalSettings = new SettingsManager();
            GenderSubstitutions = new SettingsManager();
            SecondPersonToFirstPersonSubstitutions = new SettingsManager();
            FirstPersonToSecondPersonSubstitutions = new SettingsManager();
            Substitutions = new SettingsManager();
        }