コード例 #1
0
        protected override string GetFormattingString(FormattingType type, FormattingPosition position)
        {
            switch (type)
            {
            case FormattingType.Italic:
                return("~");

            case FormattingType.Bold:
                return("*");

            case FormattingType.Underline:
                return("_");

            case FormattingType.Strikethrough:
                return("-");

            case FormattingType.Quote:
                return(string.Empty);

            case FormattingType.Monospace:
                return("`");

            case FormattingType.MonospaceBlock:
                return("```\n");

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
コード例 #2
0
    public void VAR_Discord()
    {
        FormattingType formattingType  = FormattingType.Discord;
        var            formattedEvents = GameweekEventsFormatter.FormatNewFixtureEvents(CreateGoalEvent(removed: true), subscribes => true, formattingType, CreateNoTransfersForGoalScorer());

        foreach (var formatttedEvent in formattedEvents)
        {
            _helper.WriteLine($"{formatttedEvent.Title} {string.Join("\n", formatttedEvent.Details)}");
        }
        Assert.Contains("~~PlayerWebname scored a goal! Рџй№ИЈ~~ (VAR? ­ЪциРђЇРЎђ№ИЈ)", formattedEvents.First().Details);
    }
コード例 #3
0
        public static ICollapseRepresentation GetAlgorithm(FormattingType formattingType) {
            switch (formattingType) {
                case FormattingType.BRACKETS:
                    return new BracketsRepresentationAlgorithm();
                case FormattingType.MARKUP:
                    return new MarkupRepresentationAlgorithm();
                case FormattingType.WHITESPACE:
                    return new WhitespaceRepresentationAlgorithm();
            }

            throw new ArgumentException("Unsupported formatting type");
        }
        public IFilePersonSerializer Create(FormattingType type)
        {
            switch (type)
            {
            case FormattingType.Csv:
                return(new FileCsvPersonSerializer());

            case FormattingType.Json:
                return(new FileJsonPersonSerializer());

            default:
                throw new NotImplementedException();
            }
        }
コード例 #5
0
        public static ICollapseRepresentation GetAlgorithm(FormattingType formattingType)
        {
            switch (formattingType)
            {
            case FormattingType.BRACKETS:
                return(new BracketsRepresentationAlgorithm());

            case FormattingType.MARKUP:
                return(new MarkupRepresentationAlgorithm());

            case FormattingType.WHITESPACE:
                return(new WhitespaceRepresentationAlgorithm());
            }

            throw new ArgumentException("Unsupported formatting type");
        }
コード例 #6
0
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to TextRunFormatting return false.
            TextRunFormatting o = obj as TextRunFormatting;

            if ((System.Object)o == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(Size.Equals(o.Size) &&
                   FormattingType.Equals(o.FormattingType));
        }
コード例 #7
0
 public override int GetHashCode()
 {
     return(Size.GetHashCode()
            ^ FormattingType.GetHashCode());
 }
コード例 #8
0
        public IEnumerable <Message> GetMessages(IEnumerable <Message> allMessages, string subscriber, string text, DateTime fromDate, DateTime toDate, FormattingType fType)
        {
            if (fType == FormattingType.And)
            {
                return(from mess in allMessages
                       where mess.User == subscriber &&
                       mess.Text.Contains(text) &&
                       mess.ReceivingTime.CompareTo(fromDate) >= 0 &&
                       mess.ReceivingTime.CompareTo(toDate) <= 0
                       select mess);
            }

            return(from mess in allMessages
                   where mess.User == subscriber ||
                   mess.Text.Contains(text) ||
                   (mess.ReceivingTime.CompareTo(fromDate) >= 0 && mess.ReceivingTime.CompareTo(toDate) <= 0)
                   select mess);
        }
コード例 #9
0
 private void OnFormattingTypeChanged(object obj, EventArgs eventArgs)
 {
     _formattingType = FormattingTypeComboBox.SelectedIndex == 0 ? FormattingType.And : FormattingType.Or;
     ShowMessages(GetMessages(_mobile.Storage.Messages, SubscriberComboBox.Text, FindMessageTextBox.Text, FromDateTimePicker.Value, ToDateTimePicker.Value, _formattingType));
 }
コード例 #10
0
    public static List <FixtureEventMessage> FormatNewFixtureEvents(List <FixtureEvents> newFixtureEvents, Func <StatType, bool> subscribesToStat, FormattingType formattingType, TauntData tauntData = null)
    {
        var formattedStrings     = new List <FixtureEventMessage>();
        var statFormatterFactory = new StatFormatterFactory(tauntData, formattingType);

        newFixtureEvents.ForEach(newFixtureEvent =>
        {
            var eventMessages = newFixtureEvent.StatMap
                                .Where(stat => subscribesToStat(stat.Key))
                                .SelectMany(stat => statFormatterFactory.Create(stat.Key).Format(stat.Value))
                                .WhereNotNull()
                                .MaterializeToArray();
            if (eventMessages.Any())
            {
                formattedStrings.Add(new($"{GetScore(newFixtureEvent)}", Formatter.BulletPoints(eventMessages)));
            }
        });

        return(formattedStrings);
    }
コード例 #11
0
        public IEnumerable <Message> GetMessages(IEnumerable <Message> allMessages, string subscriber, string text, DateTime fromDate, DateTime toDate, FormattingType fType)
        {
            if (fType == FormattingType.And)
            {
                return(allMessages.Where(m =>
                                         m.User == subscriber &&
                                         m.Text.Contains(text) &&
                                         m.ReceivingTime.CompareTo(fromDate) >= 0 &&
                                         m.ReceivingTime.CompareTo(toDate) <= 0));
            }

            return(allMessages.Where(m =>
                                     m.User == subscriber ||
                                     m.Text.Contains(text) ||
                                     (m.ReceivingTime.CompareTo(fromDate) >= 0 && m.ReceivingTime.CompareTo(toDate) <= 0)));
        }
コード例 #12
0
 private IFilePersonSerializer CreateTarget(FormattingType type)
 {
     return(CreateFactory().Create(type));
 }
コード例 #13
0
ファイル: RegularFormatter.cs プロジェクト: fplbot/fplbot
 public RegularFormatter(IDescribeEvents describer, FormattingType formattingType)
 {
     _describer      = describer;
     _formattingType = formattingType;
 }
コード例 #14
0
ファイル: MessageFormatter.cs プロジェクト: lulzzz/BaggyBot-2
 /// <summary>
 /// Returns the formatting string expected by the chat server for the given formatting type.
 /// </summary>
 /// <param name="type">The type of formatting that should be done.</param>
 /// <param name="position">The position of the formatter in the text block to be formatted.</param>
 /// <returns></returns>
 protected abstract string GetFormattingString(FormattingType type, FormattingPosition position);
コード例 #15
0
ファイル: StatFormatterFactory.cs プロジェクト: fplbot/fplbot
 public StatFormatterFactory(TauntData tauntData, FormattingType formattingType)
 {
     _tauntData      = tauntData;
     _formattingType = formattingType;
 }
コード例 #16
0
ファイル: TauntyFormatter.cs プロジェクト: fplbot/fplbot
 public TauntyFormatter(IDescribeTaunts describer, TauntData tauntData, FormattingType formattingType)
 {
     _describer      = describer;
     _tauntData      = tauntData;
     _formattingType = formattingType;
 }
コード例 #17
0
 private IFilePersonSerializer CreateTarget(FormattingType type)
 {
     return(FilePersonSerializerFactory.Instance.Create(type));
 }