public AddressParsingTests() { var abbrs = new Abbreviations(); var regex = new RegexCache(abbrs); _handler = new AddressParsing.Handler(regex, abbrs, new Mock <ILogger>().Object); }
/// <summary> /// Extracts speak abbreviations from the abbreviations /// file and adds them to the phrases file. Removes 'favorite' /// phrases from the abbreviations file. /// </summary> /// <param name="abbreviationsFile">input abbreviations file</param> /// <param name="phrasesFile">output phrases file</param> private static void extractPhrases(String abbreviationsFile, String phrasesFile) { var abbreviations = new Abbreviations(); bool retVal = abbreviations.Load(abbreviationsFile); if (!abbreviations.AbbreviationList.Any() || !retVal) { return; } var phrases = File.Exists(phrasesFile) ? Phrases.Load(phrasesFile) : new Phrases(); foreach (var abbreviation in abbreviations.AbbreviationList) { if (abbreviation.Mode == Abbreviation.AbbreviationMode.Speak && !String.IsNullOrEmpty(abbreviation.Expansion)) { var phrase = new Phrase { Text = abbreviation.Expansion }; if (abbreviation.Mnemonic.StartsWith("**")) { phrase.Favorite = true; } phrases.Add(phrase); } } phrases.Save(phrasesFile); var count = 0; while (true) { bool found = false; foreach (var abbreviation in abbreviations.AbbreviationList) { if (abbreviation.Mnemonic.StartsWith("**")) { abbreviations.Remove(abbreviation.Mnemonic); found = true; count++; break; } } if (!found) { if (count > 0) { abbreviations.Save(abbreviationsFile); } break; } } }
/// <summary> /// Gets the competitor's abbreviation in the specified language or a null reference /// </summary> /// <param name="culture">A <see cref="CultureInfo" /> specifying the language of the abbreviation</param> /// <returns>The competitor's abbreviation in the specified language or a null reference</returns> public string GetAbbreviation(CultureInfo culture) { // no need to call GetOrLoadCompetitor() since already called before populating dictionary return(Abbreviations.ContainsKey(culture) ? Abbreviations[culture] : null); }
public void Main() { IAtomContainer mol = null; #region Abbreviations abrv = new Abbreviations { // add some abbreviations, when overlapping (e.g. Me,Et,tBu) first one wins "[Na+].[H-] NaH", "*c1ccccc1 Ph", "*C(C)(C)C tBu", "*CC Et", "*C Me" }; // maybe we don't want 'Me' in the depiction abrv.SetEnabled("Me", false); // assign abbreviations with some filters int numAdded = abrv.Apply(mol); // generate all but don't assign, need to be added manually // set/update the CDKPropertyName.CtabSgroups property of mol var sgroups = abrv.Generate(mol); #endregion #region 1 // https://www.github.com/openbabel/superatoms abrv.LoadFromFile("obabel_superatoms.smi"); #endregion }
/// <summary>Retrieves the Abbreviations.</summary> /// <param name="value">The value.</param> /// <param name="formatted">The formatting toggle.</param> /// <returns>The <see cref="Abbreviations" />.</returns> public static Abbreviations GetAbbreviations(long value, bool formatted) { int _count = formatted ? GetStepCount(value) : 0; Abbreviations _abbreviations = (Abbreviations)_count; return(_abbreviations); }
public void TestAbbreviationsClassDoNotFindUnexisting() { { Abbreviations abbs = new Abbreviations(); // Assert Assert.AreEqual("not found", abbs.FindExplanationFor("jne"), "FindExplanation should return 'not found' if the abbreviation does not exist!"); } }
public void TestAbbreviationsClassHasAbbs() { { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("np", "no problem"); // Assert Assert.AreEqual(true, abbs.HasAbbreviation("np"), "HasAbbrebiation should find the added abbreviation!"); } }
public void TestAbbreviationsClassFindExpNP() { { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("np", "no problem"); // Assert Assert.AreEqual("no problem", abbs.FindExplanationFor("np"), "FindExplanation should find the explanation!"); } }
public void TestAbbreviationsClassFindExpETC() { { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("etc", "et cetera"); // Assert Assert.AreEqual("et cetera", abbs.FindExplanationFor("etc"), "FindExplanation should find the explanation!"); } }
public void TestAbbreviationsClassFindExpJNE() { { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("jne", "ja niin edelleen"); // Assert Assert.AreEqual("ja niin edelleen", abbs.FindExplanationFor("jne"), "FindExplanation should find the explanation!"); } }
public void Start() { // playfab = new PlayFabManager(); gamedata = new GameValues(); ab = new Abbreviations(); timertext.text = timer.ToString("0"); timericon.gameObject.SetActive(false); upgrades.StartUpgrades(); }
public ViewModelAbbreviations() { _abbreviations = Abbreviations.Instance; _abbreviationCollection = new ObservableCollection <Abbreviation>(); AbbreviationCode = ""; AbbreviationPhrase = ""; _notifier = new TaskNotifier(this); SelectionMode = false; _loadAbbreviations(); }
/// <summary>Initializes a new instance of the <see cref="Bytes" /> class.</summary> public Bytes() { _abbreviated = false; _abbreviations = Abbreviations.B; _fileSizeTypes = FileSizeTypes.Bytes; _formatted = true; _formattedSize = 0; _totalSize = 0; Update(_totalSize); }
/// <summary>Update the structure.</summary> /// <param name="value">The total bytes value.</param> private void Update(long value) { _formattedSize = value; _totalSize = value; if (_formatted) { _formattedSize = FormatBytes(_totalSize); } _fileSizeTypes = GetFileSizeType(_totalSize, _formatted); _abbreviations = ConvertToAbbreviation(_fileSizeTypes); }
public ViewModelMessage() { _notifier = new TaskNotifier(this); _selectionStart = 0; _selectionLength = 0; _message = ""; _oldMessage = ""; _oldSelectionStart = 0; _abbreviations = Abbreviations.Instance; _settings = Settings.Instance; _abbreviationDictionary = new Dictionary <string, string>(); _loadAbbreviations(); _voiceBox = new VoiceBox(); }
/// <summary>Get the full size type.</summary> /// <param name="abbreviations">The abbreviation.</param> /// <returns>The <see cref="FileSizeTypes" />.</returns> public static FileSizeTypes ConvertToSizeType(Abbreviations abbreviations) { FileSizeTypes _fileSizeTypes; switch (abbreviations) { case Abbreviations.B: { _fileSizeTypes = FileSizeTypes.Bytes; break; } case Abbreviations.KB: { _fileSizeTypes = FileSizeTypes.Kilobytes; break; } case Abbreviations.MB: { _fileSizeTypes = FileSizeTypes.Megabytes; break; } case Abbreviations.GB: { _fileSizeTypes = FileSizeTypes.Gigabytes; break; } case Abbreviations.TB: { _fileSizeTypes = FileSizeTypes.Terabytes; break; } case Abbreviations.PB: { _fileSizeTypes = FileSizeTypes.Petabytes; break; } default: { throw new ArgumentOutOfRangeException(nameof(abbreviations), abbreviations, null); } } return(_fileSizeTypes); }
/// <summary>Get the abbreviation of the size type.</summary> /// <param name="fileSizeTypes">The size type.</param> /// <returns>The <see cref="Abbreviations" />.</returns> public static Abbreviations ConvertToAbbreviation(FileSizeTypes fileSizeTypes) { Abbreviations _abbreviations; switch (fileSizeTypes) { case FileSizeTypes.Bytes: { _abbreviations = Abbreviations.B; break; } case FileSizeTypes.Kilobytes: { _abbreviations = Abbreviations.KB; break; } case FileSizeTypes.Megabytes: { _abbreviations = Abbreviations.MB; break; } case FileSizeTypes.Gigabytes: { _abbreviations = Abbreviations.GB; break; } case FileSizeTypes.Terabytes: { _abbreviations = Abbreviations.TB; break; } case FileSizeTypes.Petabytes: { _abbreviations = Abbreviations.PB; break; } default: { throw new ArgumentOutOfRangeException(nameof(fileSizeTypes), fileSizeTypes, null); } } return(_abbreviations); }
/// <summary> /// Constructs and return a <see cref="string"/> containing details of the current instance /// </summary> /// <returns>A <see cref="string"/> containing details of the current instance</returns> protected override string PrintC() { var abbreviations = string.Join(", ", Abbreviations.Select(x => x.Key.TwoLetterISOLanguageName + ":" + x.Value)); var associatedPlayers = string.Empty; if (AssociatedPlayers != null && AssociatedPlayers.Any()) { associatedPlayers = string.Join(", ", AssociatedPlayers.Select(s => s.Id + ": " + s.GetName(_cultures.First()))); associatedPlayers = $", AssociatedPlayers=[{associatedPlayers}]"; } var reference = _referenceId?.ReferenceIds == null || !_referenceId.ReferenceIds.Any() ? string.Empty : _referenceId.ReferenceIds.Aggregate(string.Empty, (current, item) => current = $"{current}, {item.Key}={item.Value}").Substring(2); return($"{base.PrintC()}, Gender={Gender}, Reference={reference}, Abbreviations=[{abbreviations}]{associatedPlayers}"); }
/// <summary> /// Creates the singleton instance of the Abbreviations manager /// </summary> /// <returns>true on success</returns> private static bool createAbbreviationsManager() { bool retVal = true; if (isEnabled(StartupFlags.Abbreviations)) { AppAbbreviations = new Abbreviations(); retVal = AppAbbreviations.Load(); if (!retVal) { setCompletionStatus("Abbreviations load error. Abbreviations will be disabled", false); } } return(retVal); }
/// <summary> /// Constructs and return a <see cref="string"/> containing details of the current instance /// </summary> /// <returns>A <see cref="string"/> containing details of the current instance</returns> protected override string PrintC() { var abbreviations = string.Join(", ", Abbreviations.Select(x => x.Key.TwoLetterISOLanguageName + ":" + x.Value)); var associatedPlayersStr = string.Empty; var associatedPlayerIds = _competitorCI?.GetAssociatedPlayerIds(); if (!associatedPlayerIds.IsNullOrEmpty()) { associatedPlayersStr = string.Join(", ", associatedPlayerIds); associatedPlayersStr = $", AssociatedPlayers=[{associatedPlayersStr}]"; } var reference = _referenceId?.ReferenceIds == null || !_referenceId.ReferenceIds.Any() ? string.Empty : _referenceId.ReferenceIds.Aggregate(string.Empty, (current, item) => current = $"{current}, {item.Key}={item.Value}").Substring(2); return($"{base.PrintC()}, Gender={Gender}, Reference={reference}, Abbreviations=[{abbreviations}]{associatedPlayersStr}"); }
/// <summary> /// Constructs and return a <see cref="string"/> containing details of the current instance /// </summary> /// <returns>A <see cref="string"/> containing details of the current instance</returns> protected override string PrintF() { var countryNames = string.Join(", ", Countries.Select(x => x.Key.TwoLetterISOLanguageName + ":" + x.Value)); var abbreviations = string.Join(", ", Abbreviations.Select(x => x.Key.TwoLetterISOLanguageName + ":" + x.Value)); var associatedPlayers = string.Empty; if (AssociatedPlayers != null && AssociatedPlayers.Any()) { associatedPlayers = string.Join(", ", AssociatedPlayers.Select(s => s.ToString("f"))); associatedPlayers = $", AssociatedPlayers=[{associatedPlayers}]"; } var reference = References == null ? string.Empty : References.ToString("f"); return($"{base.PrintF()}, Countries=[{countryNames}], Reference={reference}, Abbreviations=[{abbreviations}], IsVirtual={IsVirtual}{associatedPlayers}"); }
private void AddRole(string name, string role, SocketCommandContext context, string name2 = "") { try { string parsedRole = Abbreviations.First(x => x.Value.Contains(role)).Key; var user = FindUser(name, context); if (parsedRole != "Mr. és Miss Eötvös") { var channel = FindChannel(GameRoles[parsedRole], context); channel.AddPermissionOverwriteAsync(user, new Discord.OverwritePermissions(1049600, 0)); context.Channel.SendMessageAsync(name + " jogot kapott a " + channel.Name + " szobához."); } else { Player player2 = Players.Find(p => p.Username == name2 || p.Nickname == name2); player2.AddRole(parsedRole); context.Channel.SendMessageAsync(name + " és " + name2 + " mostantól Mr. és Miss Eötvös."); } Player player = Players.Find(p => p.Username == name || p.Nickname == name); if (player == null) { player = new Player(user.Username, user.Nickname, parsedRole); Players.Add(player); } else { player.AddRole(parsedRole); } } catch (Exception ex) { if (ex.GetType() == typeof(UserNotFoundException)) { throw; } else { throw new AddRoleException("Hiba a szerep kiosztásakor. :frowning:"); } } }
public virtual double MatchCertainty(ITextResourceCollection textResource, string text) { text = text.ToLower(); var id = Id.ToString().ToLower(); var name = Name.Localise(textResource).ToLower(); var abbrev = Abbreviations?.Localise(textResource).ToLower().Split(','); return(new List <double> { id == text ? 0.95 : 0, name == text ? 0.9 : 0, abbrev?.Any(a => a == text) ?? false ? 0.9 : 0, id.StartsWith(text) ? 0.75 : 0, name.StartsWith(text) ? 0.7 : 0, id.Contains(text) ? 0.55 : 0, name.Contains(text) ? 0.5 : 0, id.Without(" ") == text.Without(" ") ? 0.35 : 0, name.Without(" ") == text.Without(" ") ? 0.3 : 0, id.Without(" ").StartsWith(text.Without(" ")) ? 0.15 : 0, name.Without(" ").StartsWith(text.Without(" ")) ? 0.1 : 0, }.Max()); }
public void TestAbbreviationsClassFindExpNP() { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("np", "no problem"); Assert.Equal("no problem", abbs.FindExplanationFor("np")); }
public void TestAbbreviationsClassFindExpJNE() { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("jne", "ja niin edelleen"); Assert.Equal("ja niin edelleen", abbs.FindExplanationFor("jne")); }
public void TestAbbreviationsClassDoNotFindUnexisting() { Abbreviations abbs = new Abbreviations(); Assert.Equal("not found", abbs.FindExplanationFor("jne")); }
public void GetDescription() { var description = Abbreviations.GetDescription(Abbreviations.Abbreviation.IPF); }
//sends messages, checks validation and writes messages on a .csv file private void SendButtonClick() { //lists that hold text found in the text List <string> hashtags = new List <string>(); List <string> mentions = new List <string>(); List <string> quarantined = new List <string>(); List <string> sirs = new List <string>(); Abbreviations abbreviations = new Abbreviations(); //Check if textboxes are empty if (string.IsNullOrWhiteSpace(HeaderTextBox) || (string.IsNullOrWhiteSpace(BodyTextBox))) { MessageBox.Show("Please fill in the header and body textboxes appropriately", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Check if the message is an Sms with validations else if ((HeaderTextBox[0] == 'S') && (HeaderTextBox.Length == 10)) { for (int id = 1; id < HeaderTextBox.Length; id++) { if (!char.IsDigit(HeaderTextBox[id])) { MessageBox.Show("Message Id should contain only numbers.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } int findspace = BodyTextBox.IndexOf(" "); string stopAt; //space found then write twitter sender id and continue with message if (findspace > 0) { stopAt = BodyTextBox.Substring(0, findspace); string sms_sender = stopAt; //check for a valid mobile phone number string phoneNumber = @"^(\+[0-9]{15})$"; if (!Regex.IsMatch(sms_sender, phoneNumber) && (sms_sender.Length < 15)) { MessageBox.Show("SMS message body must begin with the senders international phone number.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Assign sms sender and body to strings string sms_body = BodyTextBox.Substring(16); //check text length if ((sms_body.Length <= 140) && (sms_body.Length > 0)) { sms_body = abbreviations.ExpandSMS(sms_body); // create new sms message Sms message = new Sms() { Header = HeaderTextBox, Sender = sms_sender, Body = sms_body, MType = "Sms" }; //Save sms message to Json format SaveToFile save = new SaveToFile(); var smslist = save.LoadJsonSms(); smslist.Add(message); string resultJson = JsonConvert.SerializeObject(smslist); File.WriteAllText("sms.json", resultJson); //check if json file exists if (!File.Exists("sms.json")) { MessageBox.Show("Error while saving\n" + save.ErrorCode); } else { MessageBox.Show("Sms Message Send and saved", "Success", MessageBoxButton.OK); save = null; } //prints message MessageBox.Show($"Message type: {message.MType}" + $"\nMessageID: {message.Header}" + $"\nSender: {message.Sender}" + $"\nText: {message.Body}", "Your" + message.MType + "message have been send", MessageBoxButton.OK); } else { MessageBox.Show("Sms text must be up to 140 characters long or empty!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Sms body should start with a valid international phone number", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } //check if it is a Twitter message with validations else if ((HeaderTextBox[0] == 'T') && (HeaderTextBox.Length == 10)) { for (int id = 1; id < HeaderTextBox.Length; id++) { //valid messageID? if (!char.IsDigit(HeaderTextBox[id])) { MessageBox.Show("Message Id type letter must be followed by 9 numberic characters. Please try again!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } //checks if the sender twitterID is typed first in body if (BodyTextBox[0] == '@') { int findspace = BodyTextBox.IndexOf(" "); string stopAt; //space found then write twitter sender id and continue with message if (findspace > 0) { stopAt = BodyTextBox.Substring(0, findspace); string tweet_sender_id = stopAt; string tweetid = @"^@?(\w){1,15}$"; if (Regex.IsMatch(tweet_sender_id, tweetid)) { int space = BodyTextBox.IndexOf(" "); string tweet_body = BodyTextBox.Substring(space + 1); if ((tweet_body.Length <= 140) && (tweet_body.Length > 0)) { tweet_body = abbreviations.ExpandTweet(tweet_body); //save any mentions found in tweet body to a list foreach (Match match in Regex.Matches(input: tweet_body, pattern: @"(?<!\w)@\w+")) { mentions.Add(match.Value); File.AppendAllText("mentions.csv", match.Value + Environment.NewLine); } //save any hashtags found in tweet body to a list foreach (Match match in Regex.Matches(input: tweet_body, pattern: @"(?<!\w)#\w+")) { hashtags.Add(match.Value); File.AppendAllText("hashtags.csv", match.Value + Environment.NewLine); } //add new twitter message Tweet message = new Tweet() { Header = HeaderTextBox, Sender = tweet_sender_id, Body = tweet_body, MType = "Tweet" }; //Save file to Json format SaveToFile save = new SaveToFile(); var tweetlist = save.LoadJsonTweet(); tweetlist.Add(message); string resultJson = JsonConvert.SerializeObject(tweetlist); File.WriteAllText("tweet.json", resultJson); //check if json file exists if (!File.Exists("tweet.json")) { MessageBox.Show("Error while saving\n" + save.ErrorCode); } else { MessageBox.Show("Tweet Message Send and saved", "Success", MessageBoxButton.OK); save = null; } //print message MessageBox.Show($"Message type: {message.MType}" + $"\nMessageID: {message.Header}" + $"\nSender: {message.Sender}" + $"\nText: {message.Body}", "Your" + message.MType + "message have been send", MessageBoxButton.OK); //print hashtag list and mention list var hashtagslist = string.Join(Environment.NewLine, hashtags); MessageBox.Show("Trending List:" + Environment.NewLine + hashtagslist, "Hashtag List", MessageBoxButton.OK, MessageBoxImage.Asterisk); var mentionslist = string.Join(Environment.NewLine, mentions); MessageBox.Show("Mention List:" + Environment.NewLine + mentionslist, "Mention List", MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show("Tweet text must be no longer than 140 characters and cant be empty!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Tweet Body must begin with your Twitter ID. @ followed by maximum 15 characters", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Please allow a space after your TwitterID!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Tweet Body must begin with senders TwitterID. (ex. @AlexAn) ", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } //check for email validations else if ((HeaderTextBox[0] == 'E') && (HeaderTextBox.Length == 10)) { for (int id = 1; id < HeaderTextBox.Length; id++) { //check if the 9 characters are digits if (!char.IsDigit(HeaderTextBox[id])) { MessageBox.Show("Message Id should contain only numbers.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } int findspace = BodyTextBox.IndexOf(" "); int findFullStop = BodyTextBox.IndexOf(". "); string stopAtFullStop; string stopAt; //space found then write email address and continue with subject if (findspace > 0) { stopAt = BodyTextBox.Substring(0, findspace); string sender_email = stopAt; if (IsValidEmail(sender_email)) { if (findFullStop > 0) { stopAtFullStop = BodyTextBox.Substring(findspace, findFullStop - findspace); string email_subject = stopAtFullStop; string SIRPattern = "^ +[S|s]+[I|i]+[R|r]+ \\d{2}/\\d{2}/\\d{2}$"; if ((Regex.IsMatch(email_subject, SIRPattern)) && (email_subject.Length <= 20)) { string bodyStartAtFullStop = BodyTextBox.Substring(findFullStop + 1); string email_body = bodyStartAtFullStop; if ((email_body.Length <= 1029) && (email_body.Length > 0)) { foreach (Match match in Regex.Matches(input: email_body, pattern: @"\b\d\d-\d\d-\d\d\b|\bTheft\b")) { sirs.Add(match.Value); File.AppendAllText("sir.csv", match.Value + Environment.NewLine); } // add links found to a list foreach (Match match in Regex.Matches(input: email_body, pattern: @"\b(?:https?://|www\.)\S+\b")) { quarantined.Add(match.Value); File.AppendAllText("quarantined.csv", match.Value + Environment.NewLine); } //replace links found within email body email_body = Regex.Replace(email_body, @"\b(?:https?://|www\.)\S+\b", "<URL Quarantined>"); //creates new email message SIR message = new SIR() { Header = HeaderTextBox, Sender = sender_email, Subject = email_subject, Body = email_body, MType = "SIR" }; //Save email message to json SaveToFile save = new SaveToFile(); var sirlist = save.LoadJsonSir(); sirlist.Add(message); string resultJson = JsonConvert.SerializeObject(sirlist); File.WriteAllText("sir.json", resultJson); //check if file exists if (!File.Exists("sir.json")) { MessageBox.Show("Error while saving\n" + save.ErrorCode); } else { MessageBox.Show("SIR Message Send and saved", "Success", MessageBoxButton.OK); save = null; } //print message MessageBox.Show($"Message type: {message.MType}" + $"\nMessageID: {message.Header}" + $"\nSender: {message.Sender}" + $"\nMessage Subject:{message.Subject}" + $"\nText:{message.Body}", "Your" + message.MType + "message have been send", MessageBoxButton.OK); //print quarantined URLs var quarantinedlist = string.Join(Environment.NewLine, quarantined); MessageBox.Show("Quarantined urls List:" + Environment.NewLine + quarantinedlist, "Quarantined URL(s) added to the List", MessageBoxButton.OK, MessageBoxImage.Asterisk); var sirs_list = string.Join(Environment.NewLine, sirs); MessageBox.Show("Sir List:" + Environment.NewLine + sirs_list, "Sir List", MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show("SIR Body text must be no longer than 1028 characters!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else if (email_subject.Length <= 20) { string bodyStartAtFullStop = BodyTextBox.Substring(findFullStop + 1); string email_body = bodyStartAtFullStop; if (email_body.Length <= 1029) { // add links found to a list foreach (Match match in Regex.Matches(input: email_body, pattern: @"\b(?:https?://|www\.)\S+\b")) { quarantined.Add(match.Value); File.AppendAllText("quarantined.csv", match.Value + Environment.NewLine); } //replace links found within email body email_body = Regex.Replace(email_body, @"\b(?:https?://|www\.)\S+\b", "<URL Quarantined>"); //creates new email message Email message = new Email() { Header = HeaderTextBox, Sender = sender_email, Subject = email_subject, Body = email_body, MType = "Email" }; //Save file to Json format SaveToFile save = new SaveToFile(); var emaillist = save.LoadJsonEmail(); emaillist.Add(message); string resultJson = JsonConvert.SerializeObject(emaillist); File.WriteAllText("email.json", resultJson); //check if file exists if (!File.Exists("email.json")) { MessageBox.Show("Error while saving\n" + save.ErrorCode); } else { MessageBox.Show("Email Message Send and saved", "Success", MessageBoxButton.OK); save = null; } //print message MessageBox.Show($"Message type: {message.MType}" + $"\nMessageID: {message.Header}" + $"\nSender: {message.Sender}" + $"\nMessage Subject:{message.Subject}" + $"\nText:{message.Body}", "Your" + message.MType + "message have been send", MessageBoxButton.OK); //print quarantined URLs var quarantinedlist = string.Join(Environment.NewLine, quarantined); MessageBox.Show("Quarantined urls List:" + Environment.NewLine + quarantinedlist, "Quarantined URLs List", MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { MessageBox.Show("Email Body text must be no longer than 1028 characters!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Email Subject must be no longer than 20 characters!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Please mind that subject should be less than 20 characters long, and remember to seperate subject and message with a full stop and a space!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Email Body must begin with a valid Email address.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Email Body must begin with a valid Email address followed by a space.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("MessageID is not valid. Please enter a valid messageID maximum 10 characters long.\n" + "First character will indicate the message type and the rest must be numeric characters.\n" + "ex. S123456789 for SMS, T876543210 for Tweets, E147258360 for Emails!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } }
public void TestAbbreviationsClassFindExpETC() { Abbreviations abbs = new Abbreviations(); abbs.AddAbbreviation("etc", "et cetera"); Assert.Equal("et cetera", abbs.FindExplanationFor("etc")); }
/// <summary> /// Gets the competitor's abbreviation in the specified language or a null reference /// </summary> /// <param name="culture">A <see cref="CultureInfo" /> specifying the language of the abbreviation</param> /// <returns>The competitor's abbreviation in the specified language or a null reference</returns> public string GetAbbreviation(CultureInfo culture) { return(Abbreviations.ContainsKey(culture) ? Abbreviations[culture] : null); }