i know whats is happening and why its throwing an error (it does not find GetBrokenRules method because its List) but the reason i posted this question here is to ask for a better design, can anybody guide me here please?
i am working on Facilities class (List..../Building/Floor)
error:
Error 3 'System.Collections.Generic.List' does not contain a definition for 'GetBrokenRules' and no extension method 'GetBrokenRules' accepting a first argument of type 'System.Collections.Generic.List' could be found (are you missing a using directive or an assembly reference?)
error on >>> else if (Campus.GetBrokenRules().Count > 0)
is there any better way to desing my GetBrokenRules() ?
ICampus, IBuilding, IFloor consists of the following
public interface ICampus
{
List<BrokenBusinessRule> GetBrokenRules();
int Id { get; }
string Name { get; }
}
public interface IFacilities
{
List<BrokenBusinessRule> GetBrokenRules();
List<ICampus> Campus { get; }
List<IBuilding> Building { get; }
List<IFloor> Floor { get; }
}
public class Facilities : IFacilities
{
private List<ICampus> _campus;
private List<IBuilding> _building;
private List<IFloor> _floor;
public List<ICampus> Campus
{
get { return _campus; }
}
public List<IBuilding> Building
{
get { return _building; }
}
public List<IFloor> Floor
{
get { return _floor; }
}
public Facilities(List<ICampus> campus, List<IBuilding> building, List<IFloor> floor)
{
_campus = campus;
_building = building;
_floor = floor;
}
public List<BrokenBusinessRule> GetBrokenRules()
{
List<BrokenBusinessRule> brokenRules = new List<BrokenBusinessRule>();
if (Campus == null)
brokenRules.Add(new BrokenBusinessRule("Facility Campus", "Must have at least one Campus"));
else if (Campus.GetBrokenRules().Count > 0)
{
AddToBrokenRulesList(brokenRules, Campus.GetBrokenRules());
}
if (Building == null)
brokenRules.Add(new BrokenBusinessRule("Facility Building", "Must have at least one Building"));
else if (Building.GetBrokenRules().Count > 0)
{
AddToBrokenRulesList(brokenRules, Building.GetBrokenRules());
}
if (Floor == null)
brokenRules.Add(new BrokenBusinessRule("Facility Floor", "Must have at least one Floor"));
else if (Floor.GetBrokenRules().Count > 0)
{
AddToBrokenRulesList(brokenRules, Floor.GetBrokenRules());
}
}
}