示例#1
0
        public TResult Create <TResult>(string url, string header, string error)
            where TResult : class
        {
            var uniqueError = error + Guid.NewGuid();
            var json        = _errorableDownloadFactory.Create(url, header, uniqueError);

            return(json == uniqueError ? null : _jsonParser.Create <TResult>(json));
        }
示例#2
0
        public override IReadOnlyList <ISendable <ITransmittable> > Create(ISnapshot <Civilian, PublicMessage> snapshot)
        {
            var outbox = new List <ISendable <ITransmittable> >();

            _singleLineSpamPunishmentFactory.Create(snapshot).Apply(s => outbox.AddRange(s));
            _repositoryPunishmentFactory.Create(snapshot).Apply(s => outbox.AddRange(s));
            _selfSpamPunishmentFactory.Create(snapshot).Apply(s => outbox.AddRange(s));
            _longSpamPunishmentFactory.Create(snapshot).Apply(s => outbox.AddRange(s));
            return(_processMaximumPunishment(outbox));
        }
 public override TOutput Create(T input)
 {
     try {
         return(_factory.Create(input));
     } catch (Exception e) {
         _logger.LogError($"Error occured in {nameof(ErrorableFactoryTryCatchDecorator<object, object>)}\r\n" +
                          $"{LogExtraInformation(input)}", e);
         return(_factory.OnErrorCreate);
     }
 }
示例#4
0
        public TResult Create <TResult>(string url, string header, string error)
            where TResult : class
        {
            var uniqueError = error + Guid.NewGuid();
            var xml         = _errorableDownloadFactory.Create(url, header, uniqueError);

            if (xml == uniqueError)
            {
                return(null);
            }
            var serializer = new XmlSerializer(typeof(TResult));

            using (var reader = new StringReader(xml)) {
                return((TResult)serializer.Deserialize(reader));
            }
        }
        public IReadOnlyList <ISendable <ITransmittable> > Create(ISnapshot <Civilian, PublicMessage> snapshot)
        {
            var bans = _punishmentFactory.Create(snapshot);

            if (bans.Any())
            {
                return(bans);
            }
            var latestCivilianCommandTime = _repository.Query(u => u.InMemory.LatestCivilianCommandTime);

            if (_timeService.UtcNow > latestCivilianCommandTime.Add(_settings.CivilianCommandInterval))
            {
                var commands = _commandFactory.Create(snapshot);
                if (commands.Any())
                {
                    _repository.Command(u => u.InMemory.LatestCivilianCommandTime = _timeService.UtcNow);
                }
                return(commands);
            }
            return(new List <ISendable <ITransmittable> >());
        }
示例#6
0
        public PipelineManager(
            IErrorableFactory <string, IReceived <IUser, ITransmittable> > parser,
            IErrorableFactory <IReceived <IUser, ITransmittable>, ISnapshot <IUser, ITransmittable> > snapshotFactory,
            IErrorableFactory <ISnapshot <IUser, ITransmittable>, IReadOnlyList <ISendable <ITransmittable> > > sendableFactory,
            IFactory <IEnumerable <ISendable <ITransmittable> >, IEnumerable <string> > serializer,
            ILogger logger)
        {
            _logger               = logger;
            _parserBlock          = new TransformBlock <string, IReceived <IUser, ITransmittable> >(s => parser.Create(s));
            _snapshotFactoryBlock = new TransformBlock <IReceived <IUser, ITransmittable>, ISnapshot <IUser, ITransmittable> >(r => snapshotFactory.Create(r));
            var sendableFactoryBlock = new TransformBlock <ISnapshot <IUser, ITransmittable>, IReadOnlyList <ISendable <ITransmittable> > >(c => sendableFactory.Create(c), new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = DataflowBlockOptions.Unbounded,
                EnsureOrdered          = false,
            });

            _serializerBlock = new TransformBlock <IReadOnlyList <ISendable <ITransmittable> >, IEnumerable <string> >(r => serializer.Create(r));
            var senderBlock = new ActionBlock <IEnumerable <string> >(ss => ss.ToList().ForEach(s => _sender(s)));

            _parserBlock.LinkTo(DataflowBlock.NullTarget <IReceived <IUser, ITransmittable> >(), s => s == null);
            _parserBlock.LinkTo(_snapshotFactoryBlock);
            _snapshotFactoryBlock.LinkTo(sendableFactoryBlock);
            sendableFactoryBlock.LinkTo(_serializerBlock);
            _serializerBlock.LinkTo(senderBlock);
        }
示例#7
0
 public IReadOnlyList <ISendable <ITransmittable> > Aegis(IReadOnlyList <IReceived <IUser, ITransmittable> > context) => _aegisPardonFactory.Create(context);
示例#8
0
 public IReadOnlyList <ISendable <ITransmittable> > Nuke(IReadOnlyList <IReceived <IUser, ITransmittable> > context, Nuke nuke) => _nukeMuteFactory.Create(nuke, context);
示例#9
0
 public IReadOnlyList <ISendable <ITransmittable> > Visit(ISnapshot <Moderator, PublicMessage> snapshot) =>
 _modCommandFactory.Create(snapshot).Concat(_commandFactory.Create(snapshot)).ToList();
示例#10
0
 public string OverRustle() => _errorableDownloadFactory.Create("http://api.overrustle.com/api", "", "");