//Expeced SPANISH~ENGLISH internal static Phrase Factory(string p, bool reverseOrder, string defn, VerbDefinition associatedVerb = null, string filesource = null) { p = p.TrimStart(' '); p = p.TrimEnd(' '); int f = p.IndexOf("~"); string es = p.Substring(0, f); string en = p.Substring(f + 1); Phrase ph = reverseOrder ? new Phrase(es, en, associatedVerb, associatedVerb != null ? associatedVerb.ToString() : defn) : new Phrase(en, es, associatedVerb, associatedVerb != null ? associatedVerb.ToString() : defn); _allPhrases.Add(ph); if (!String.IsNullOrEmpty(filesource)) { if (!_phraseSourceMap.ContainsKey(filesource)) { _phraseSourceMap[filesource] = new List <Phrase>(); } _phraseSourceMap[filesource].Add(ph); } return(ph); }
private Phrase(string EN, string ES, VerbDefinition av = null, string notes = null, string filesource = null) { if (String.IsNullOrEmpty(EN)) { throw new ArgumentException("English segment of phrase is null"); } if (String.IsNullOrEmpty(ES)) { throw new ArgumentException("Spanish segment of phrase is null"); } English = EN; Spanish = ES; AssociatedVerb = av; Notes = notes; //look for additional EN notes int i = English.IndexOf("{"); int j = English.IndexOf("}"); if (i >= 0 && j > 0 && j > i) { Notes += ">>" + English.Substring(i + 1, j - 1 - i); //Remove from English segment English = EN.Substring(0, i); } }