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); } }
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); }
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(); } }
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 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)); }
public override int GetHashCode() { return(Size.GetHashCode() ^ FormattingType.GetHashCode()); }
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); }
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)); }
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); }
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))); }
private IFilePersonSerializer CreateTarget(FormattingType type) { return(CreateFactory().Create(type)); }
public RegularFormatter(IDescribeEvents describer, FormattingType formattingType) { _describer = describer; _formattingType = formattingType; }
/// <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);
public StatFormatterFactory(TauntData tauntData, FormattingType formattingType) { _tauntData = tauntData; _formattingType = formattingType; }
public TauntyFormatter(IDescribeTaunts describer, TauntData tauntData, FormattingType formattingType) { _describer = describer; _tauntData = tauntData; _formattingType = formattingType; }
private IFilePersonSerializer CreateTarget(FormattingType type) { return(FilePersonSerializerFactory.Instance.Create(type)); }