Пример #1
0
        /// <summary>Initializes a new instance of the <see cref="FileWriterActor"/> class.</summary>
        /// <param name="fileWriter">The file writer.</param>
        /// <param name = "systemConfiguration" ></param>
        public FileWriterActor(IFileWriter fileWriter, ISystemConfiguration systemConfiguration)
        {
            _fileWriter          = fileWriter;
            _systemConfiguration = systemConfiguration;
            Receive <FileWriterMessages.CreateFile>(
                o =>
            {
                try
                {
                    _fileWriter.CreateFile(o.FileName, o.StopIfDestinationFileExists);
                    Sender.Tell(new ValidatorMessages.FileCreated());
                    _actorDictionary = o.ActorDict;
                    Become(WaitingForheader);
                }
                catch (Exception e)
                {
                    _log.Error($"Cannot create file:{o.FileName}", e);
                    Sender.Tell(new ValidatorMessages.CannotCreateFile());
                }
            });

            Receive <FileWriterMessages.Timer>(
                t =>
            {
                /* swallow */
            });
        }