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)); }
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); } }
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> >()); }
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); }
public IReadOnlyList <ISendable <ITransmittable> > Aegis(IReadOnlyList <IReceived <IUser, ITransmittable> > context) => _aegisPardonFactory.Create(context);
public IReadOnlyList <ISendable <ITransmittable> > Nuke(IReadOnlyList <IReceived <IUser, ITransmittable> > context, Nuke nuke) => _nukeMuteFactory.Create(nuke, context);
public IReadOnlyList <ISendable <ITransmittable> > Visit(ISnapshot <Moderator, PublicMessage> snapshot) => _modCommandFactory.Create(snapshot).Concat(_commandFactory.Create(snapshot)).ToList();
public string OverRustle() => _errorableDownloadFactory.Create("http://api.overrustle.com/api", "", "");