private static string EntryPrefix(LookupEntry entry) { switch(entry) { case LookupEntry.Amount: return "<TRNAMT>"; case LookupEntry.Checknum: return "<CHECKNUM>"; case LookupEntry.Date: return "<DTPOSTED>"; case LookupEntry.Memo: return "<MEMO>"; case LookupEntry.Payee: return "<NAME>"; default: return $"<{entry}>"; } }
public Option LookupOption(string s, object parent = null) { if (String.IsNullOrEmpty(s)) { return(null); } LookupEntry entry = LookupEntries.FirstOrDefault(item => item.Comparer(s, item)); if (entry != null) { entry.Option.Parent = parent; return(entry.Option); } return(null); }
private static bool ArgsComparer(string key, LookupEntry lookupEntry) { if (key.StartsWith(lookupEntry.AltName)) { if (key.Length == lookupEntry.AltName.Length) { return(true); } if (lookupEntry.Option.WantsArg && key.Length == lookupEntry.AltName.Length + 1 && key[lookupEntry.AltName.Length] == '_') { return(true); } } return(false); }
public Entry(LookupEntry entry, string value) : this(EntryPrefix(entry), value) { }
public void AddEntry(LookupEntry entry, string value) { entries.Add(new Entry(entry, value)); }
private static bool OptAltComparer(string key, LookupEntry lookupEntry) { return(IsEq(key, lookupEntry.Option.Name) || IsEq(key, lookupEntry.AltName)); }