// Implement the TryInvokeMember method of the DynamicObject class for // dynamic member calls that have arguments. public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { StringSearchOption StringSearchOption = StringSearchOption.StartsWith; bool trimSpaces = true; try { if (args.Length > 0) { StringSearchOption = (StringSearchOption)args[0]; } } catch { throw new ArgumentException("StringSearchOption argument must be a StringSearchOption enum value."); } try { if (args.Length > 1) { trimSpaces = (bool)args[1]; } } catch { throw new ArgumentException("trimSpaces argument must be a Boolean value."); } result = GetPropertyValue(binder.Name, StringSearchOption, trimSpaces); return(result == null ? false : true); }
public bool Search(StackHashSearchCriteria searchCriteria) { if (searchCriteria == null) { throw new ArgumentNullException("searchCriteria"); } if (!searchCriteria.ContainsObject(StackHashObjectType.Script)) { return(true); } if (m_ScriptResults == null) { return(false); } foreach (StackHashSearchOption searchOption in searchCriteria.SearchFieldOptions) { if (searchOption.ObjectType != StackHashObjectType.Script) { continue; } StringSearchOption stringSearchOption = searchOption as StringSearchOption; if (stringSearchOption == null) { continue; } // Only search the result lines. bool matchFound = false; foreach (StackHashScriptLineResult cmdOutput in m_ScriptResults) { if (cmdOutput.Search(true, stringSearchOption.Start)) { matchFound = true; } } bool optionMatched = false; if (stringSearchOption.SearchOptionType == StackHashSearchOptionType.StringContains && matchFound) { optionMatched = true; } else if (stringSearchOption.SearchOptionType == StackHashSearchOptionType.StringDoesNotContain && !matchFound) { optionMatched = true; } if (!optionMatched) { return(false); } } return(true); }
private IEnumerable <string> GetPropertyValue(string propertyName, StringSearchOption StringSearchOption = StringSearchOption.StartsWith, bool trimSpaces = true) { StreamReader _sr = null; List <string> _results = new List <string>(); string _line = ""; string _testLine = ""; try { _sr = new StreamReader(p_filePath); while (!_sr.EndOfStream) { _line = _sr.ReadLine(); _testLine = _line.ToUpper(); if (trimSpaces) { _testLine = _testLine.Trim(); } switch (StringSearchOption) { case StringSearchOption.StartsWith: if (_testLine.StartsWith(propertyName.ToUpper())) { _results.Add(_line); } break; case StringSearchOption.Contains: if (_testLine.Contains(propertyName.ToUpper())) { _results.Add(_line); } break; case StringSearchOption.EndsWith: if (_testLine.EndsWith(propertyName.ToUpper())) { _results.Add(_line); } break; } } } catch { _results = null; } finally { if (_sr != null) { _sr.Close(); } } return(_results); }
public List <string> GetPropertyValue(string propertyName, StringSearchOption StringSearchOption = StringSearchOption.StartsWith, bool trimSpaces = true) { StreamReader sr = null; List <string> results = new List <string> (); string line = ""; string testLine = ""; try { sr = new StreamReader(p_filePath); while (!sr.EndOfStream) { line = sr.ReadLine(); testLine = line.ToUpper(); if (trimSpaces) { testLine = testLine.Trim(); } switch (StringSearchOption) { case StringSearchOption.StartsWith: if (testLine.StartsWith(propertyName.ToUpper())) { results.Add(line); } break; case StringSearchOption.Contains: if (testLine.Contains(propertyName.ToUpper())) { results.Add(line); } break; case StringSearchOption.EndsWith: if (testLine.EndsWith(propertyName.ToUpper())) { results.Add(line); } break; } } } catch { results = null; } finally { if (sr != null) { sr.Close(); } } return(results); }
public List<string> GetPropertyValue(string propertyName, StringSearchOption StringSearchOption = StringSearchOption.StartsWith, bool trimSpaces = true) { StreamReader sr = null; var results = new List<string>(); try { sr = new StreamReader(p_filePath); while (!sr.EndOfStream) { string line = sr.ReadLine(); // Perform a case-insensitive search by using the specified search options. string testLine = line.ToUpper(); if (trimSpaces) testLine = testLine.Trim(); switch (StringSearchOption) { case StringSearchOption.StartsWith: if (testLine.StartsWith(propertyName.ToUpper())) results.Add(line); break; case StringSearchOption.Contains: if (testLine.Contains(propertyName.ToUpper())) results.Add(line); break; case StringSearchOption.EndsWith: if (testLine.EndsWith(propertyName.ToUpper())) results.Add(line); break; } } } catch { // Trap any exception that occurs in reading the file and return null. results = null; } finally { if (sr != null) sr.Close(); } return results; }
public List <string> GetPropertyValue(string propertyName, StringSearchOption StringSearchOption = StringSearchOption.StartsWith, bool trimSpaces = true) { StreamReader sr = null; List <string> results = new List <string>(); string line = ""; string testLine = ""; try { sr = new StreamReader(p_filePath); while (!sr.EndOfStream) { line = sr.ReadLine(); // Perform a case-insensitive search by using the specified search options. testLine = line.ToUpper(); if (trimSpaces) { testLine = testLine.Trim(); } switch (StringSearchOption) { case StringSearchOption.StartsWith: if (testLine.StartsWith(propertyName.ToUpper())) { results.Add(line); } break; case StringSearchOption.Contains: if (testLine.Contains(propertyName.ToUpper())) { results.Add(line); } break; case StringSearchOption.EndsWith: if (testLine.EndsWith(propertyName.ToUpper())) { results.Add(line); } break; } } } catch { // Trap any exception that occurs in reading the file and return null. results = null; } finally { if (sr != null) { sr.Close(); } } return(results); }
public ActionResult Search_Async([DataSourceRequest] DataSourceRequest request, string name = "", string headquarters = "", int?statusID = null, int?regulatorID = null, int?CERSID = null, string facilityName = null, string facilityStreet = null, string facilityCity = null, string facilityZipCode = null, int?edtIdentityKey = null, OrganizationOrigin?origin = null, bool custSearch = false, StringSearchOption nameSearchOption = StringSearchOption.Contains, string nameEquals = null) { var organizations = Repository.Organizations.GridSearch( name: name, headquarters: headquarters, statusID: statusID, regulatorID: regulatorID, applySecurityFilter: false, CERSID: CERSID, facilityName: facilityName, facilityStreet: facilityStreet, facilityCity: facilityCity, facilityZipCode: facilityZipCode, edtIdentityKey: edtIdentityKey, origin: origin, nameSearchOption: nameSearchOption, nameEquals: nameEquals ); DataSourceResult result = organizations.ToDataSourceResult(request); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Search_GridBindingChemicals([DataSourceRequest] DataSourceRequest request, StringSearchOption chemicalNameSearchOption, string chemicalName, string casNumber, string cclFQID, bool excludeSynonyms, bool excludeMixtures) { // Default ChemicalLibraryEntry Search to Empty IEnumerable IEnumerable <ChemicalLibrarySearchResult> entities = new List <ChemicalLibrarySearchResult>(); // Only perform the search if they search by at least one parameter - if (!string.IsNullOrWhiteSpace(chemicalName) || !string.IsNullOrWhiteSpace(casNumber) || !string.IsNullOrWhiteSpace(cclFQID)) { entities = Repository.Chemicals.SearchLibrary(chemicalNameSearchOption: chemicalNameSearchOption, name: WebUtility.UrlDecode(chemicalName), casNumber: casNumber, cclFQID: WebUtility.UrlDecode(cclFQID)); if (excludeSynonyms) { entities = entities.Where(e => e.ChemicalNameTypeID != (int)ChemicalNameType.Synonym); } if (excludeMixtures) { entities = entities.Where(e => (e.HMType ?? string.Empty) != "b"); //b=mixture } } DataSourceResult result = entities.ToList().ToDataSourceResult(request); return(Json(result, JsonRequestBehavior.AllowGet)); }