public virtual double GetMultiplier(string securityName) { double multiplier = 0; if (!string.IsNullOrEmpty(securityName)) { SecurityLookUp lookup = securityLookUps.Where(x => string.Compare(x.Name.ToLower(), securityName.ToLower()) == 0).FirstOrDefault(); if (lookup != null) { // run another multiplier = lookup.Multiplier; } else // run another pass using contains { lookup = securityLookUps.Where(x => string.Compare(x.Alias.ToLower(), securityName.ToLower()) == 0).FirstOrDefault(); if (lookup == null) { lookup = securityLookUps.Where(x => securityName.ToLower().Contains(x.Name.ToLower())).FirstOrDefault(); } if (lookup != null) { multiplier = lookup.Multiplier; } } } return(multiplier); }
public virtual KeyValuePair <string, string> GetSecurityValues(string securityName) { KeyValuePair <string, string> kvp = new KeyValuePair <string, string>(); if (!string.IsNullOrEmpty(securityName)) { SecurityLookUp lookup = securityLookUps.Where(x => (!string.IsNullOrEmpty(x.Alias) && string.Compare(x.Alias.ToLower(), securityName.ToLower()) == 0) || string.Compare(x.Name.ToLower(), securityName.ToLower()) == 0).FirstOrDefault(); if (lookup != null) { kvp = new KeyValuePair <string, string>(lookup.Name, lookup.SecurityType); } else // run another pass using contains { string strippedSecurityName = StripInvalidCharacters(securityName.ToLower()); lookup = securityLookUps.Where(x => strippedSecurityName.ToLower().Contains(StripInvalidCharacters(x.Name.ToLower()))).FirstOrDefault(); // reverse lookup if (lookup == null) { lookup = securityLookUps.Where(x => (!string.IsNullOrEmpty(x.Alias) && StripInvalidCharacters(x.Alias.ToLower()).Contains(strippedSecurityName)) || StripInvalidCharacters(x.Name.ToLower()).Contains(StripInvalidCharacters(securityName.ToLower()))).FirstOrDefault(); if (lookup == null) { lookup = securityLookUps.Where(x => IsNameMatchByAlgorithm(x.Alias, securityName)).FirstOrDefault(); if (lookup == null) { lookup = securityLookUps.Where(x => IsNameMatchByAlgorithm(x.Name, securityName)).FirstOrDefault(); } } } if (lookup != null) { if (!string.IsNullOrEmpty(lookup.Alias)) { kvp = new KeyValuePair <string, string>(lookup.Alias, lookup.SecurityType); } else { kvp = new KeyValuePair <string, string>(lookup.Name, lookup.SecurityType); } selectedIndex = securityLookUps.IndexOf(lookup); } } } return(kvp); }
public string GetSecurityNameByType(string securityType) { string securityName = string.Empty; if (!string.IsNullOrEmpty(securityType)) { SecurityLookUp lookup = securityLookUps.Where(x => string.Compare(securityType, x.SecurityType) == 0).FirstOrDefault(); if (lookup != null) { securityName = lookup.Name; } } return(securityName); }
public virtual string GetSecurityType(string securityName) { string securityType = string.Empty; if (!string.IsNullOrEmpty(securityName)) { //SecurityLookUp lookup = securityLookUps.Where(x => string.Compare(x.Name.ToLower(), securityName.ToLower()) == 0).FirstOrDefault(); SecurityLookUp lookup = securityLookUps.Where(x => string.Compare(x.Name.ToLower(), securityName.ToLower()) == 0).FirstOrDefault(); if (lookup != null) { securityType = lookup.SecurityType; } else // run another pass using contains { lookup = securityLookUps.Where(x => securityName.ToLower().Contains(x.Name.ToLower())).FirstOrDefault(); if (lookup != null) { securityType = lookup.SecurityType; } } } return(securityType); }