private IEnumerable <ISecurity> CreateSecurities( IEnumerable <SecurityInfo> securityInfos, CountryRepository countryRepository, IMonitor monitor ) { var result = new List <ISecurity>(); foreach (var securityInfo in securityInfos) { var securityOpt = monitor.DefaultIfFails("Validating security", delegate { if (String.IsNullOrEmpty(securityInfo.Name)) { throw new ApplicationException("Name is not specified."); } if (String.IsNullOrEmpty(securityInfo.ShortName)) { throw new ApplicationException("Short name is not specified."); } ISecurity security; if (String.IsNullOrWhiteSpace(securityInfo.LookThruFund)) { Country country = null; if (String.IsNullOrEmpty(securityInfo.IsoCountryCode)) { throw new ApplicationException("Country code is not specified."); } try { country = countryRepository.GetCountry(securityInfo.IsoCountryCode); } catch (CountryNotFoundException) { country = new Country(securityInfo.IsoCountryCode, securityInfo.AsecCountryName); } var stock = new CompanySecurity( securityInfo.Id, securityInfo.Ticker, securityInfo.ShortName, securityInfo.Name, country, securityInfo.IssuerId, securityInfo.SecurityType, securityInfo.Currency, securityInfo.Isin, securityInfo.IsoCountryCode ); security = stock; } else { var fund = new Fund( securityInfo.Id, securityInfo.Name, securityInfo.ShortName, securityInfo.Ticker, securityInfo.IssuerId, securityInfo.SecurityType, securityInfo.Currency, securityInfo.Isin, securityInfo.IsoCountryCode ); security = fund; } return(security); }); if (securityOpt == null) { continue; } result.Add(securityOpt); } return(result); }
public BottomUpPortfolio(String id, String name, Fund fund) { this.Id = id; this.Name = name; this.Fund = fund; }
public void Resolve(Fund fund) { this.FundOpt = fund; }