...'object' does not contain a definition for 'NearbyBranchIds' and no extension method 'NearbyBranchIds' accepting a first argument of type 'object' could be found
Expand|Select|Wrap|Line Numbers
- public class Parser
- {
- public ArrayList ParseBranch(string dataFileLocation)
- {
- var branchList = new ArrayList();
- using (var inData = new StreamReader(dataFileLocation))
- {
- while (!inData.EndOfStream)
- {
- var branch = Branch(inData);
- if (branch != null)
- branchList.Add(branch);
- }
- }
- foreach (var branch in branchList)
- {
- foreach (var branchID in branch.NearbyBranchIds)
- {
- foreach (var nextBranch in branchList)
- {
- if (branch == nextBranch)
- continue;
- if (nextBranch.BranchID == branchID)
- {
- branch.NearbyBranches.Add(nextBranch);
- continue;
- }
- }
- }
- }
- return branchList;
- }
- private Branch Branch(StreamReader inData)
- {
- var branch = new Branch();
- branch.BranchID = Convert.ToInt32(inData.ReadLine());
- branch.Nickname = inData.ReadLine();
- branch.StreetNumber = inData.ReadLine();
- branch.StreetName = inData.ReadLine();
- branch.City = inData.ReadLine();
- branch.County = inData.ReadLine();
- branch.Postcode = inData.ReadLine();
- branch.NearbyBranchIds.Add(Convert.ToInt32(inData.ReadLine()));
- branch.NearbyBranchIds.Add(Convert.ToInt32(inData.ReadLine()));
- branch.NearbyBranchIds.Add(Convert.ToInt32(inData.ReadLine()));
- int categories = Convert.ToInt32(inData.ReadLine());
- for (int i = 0; i < categories; ++i)
- {
- var category = ParseCategory(inData);
- if (category != null)
- branch.Categories.Add(category);
- }
- return branch;
- }
And the constructor:
Expand|Select|Wrap|Line Numbers
- public class Branch
- {
- public int BranchID { get; set; }
- public string Nickname { get; set; }
- public string StreetNumber { get; set; }
- public string StreetName { get; set; }
- public string City { get; set; }
- public string County { get; set; }
- public string Postcode { get; set; }
- public ArrayList NearbyBranchIds { get; private set; }
- public ArrayList NearbyBranches { get; private set; }
- public ArrayList Categories { get; private set; }
- public Branch()
- {
- NearbyBranchIds = new ArrayList();
- NearbyBranches = new ArrayList();
- Categories = new ArrayList();
- }
- }