Пытаюсь подключить через библиотеку, но пишет, что GroupRepository недоступен из-за уровня защиты.
namespace CourseWork
{
class Program
{
static void Main(string[] args)
{
var groups = new Library.GroupRepository.;
var subjects = new SubjectRepository();
var audiences = new RoomsRepository();
var planner = new PlanRepository();
groups.Adding(new Group() { ID = 1, Flow = "ИС", GroupNum = 91 });
groups.Adding(new Group() { ID = 2, Flow = "ИС", GroupNum = 92 });
groups.Adding(new Group() { ID = 3, Flow = "ИС", GroupNum = 93 });
subjects.Adding(new Subject() { ID = 1, Lesson = "Physics", Teacher = "Fedotov V.V.", Type = "lecture", Hours = 5 });
subjects.Adding(new Subject() { ID = 2, Lesson = "Physics", Teacher = "Marchenko I.P.", Type = "practice", Hours = 5 });
subjects.Adding(new Subject() { ID = 3, Lesson = "Physics", Teacher = "Ignatenko О.М", Type = "practice", Hours = 8 });
subjects.Adding(new Subject() { ID = 4, Lesson = "Physics", Teacher = "Liakhovetskiy O.D.", Type = "practice", Hours = 8 });
subjects.Adding(new Subject() { ID = 5, Lesson = "Math", Teacher = "Zhuk V.A.", Type = "lecture", Hours = 9 });
subjects.Adding(new Subject() { ID = 6, Lesson = "Math", Teacher = "Orel K.M.", Type = "lecture", Hours = 5 });
subjects.Adding(new Subject() { ID = 7, Lesson = "Math", Teacher = "Pelekhata O.B.", Type = "practice", Hours = 5 });
subjects.Adding(new Subject() { ID = 8, Lesson = "Programming", Teacher = "Muha I.P.", Type = "lecture", Hours = 5 });
subjects.Adding(new Subject() { ID = 9, Lesson = "Programming", Teacher = "Brodin O.M.", Type = "practice", Hours = 5 });
subjects.Adding(new Subject() { ID = 10, Lesson = "OOS", Teacher = "Yarovoy V.M.", Type = "lecture", Hours = 2 });
subjects.Adding(new Subject() { ID = 11, Lesson = "OOS", Teacher = "Khramchenlo N.I.", Type = "practice", Hours = 1 });
subjects.Adding(new Subject() { ID = 12, Lesson = "English", Teacher = "Shevchenko I.O.", Type = "practice", Hours = 5 });
subjects.Adding(new Subject() { ID = 13, Lesson = "English", Teacher = "Borysova M.Y.", Type = "practice", Hours = 5 });
subjects.Adding(new Subject() { ID = 14, Lesson = "History", Teacher = "Kostyleva O.K.", Type = "lecture", Hours = 1 });
subjects.Adding(new Subject() { ID = 15, Lesson = "History", Teacher = "Buzan I.P.", Type = "practice", Hours = 5 });
audiences.Adding(new Room() { ID = 1, Number = 102, Lesson = "Physics", Type = "lecture" });
audiences.Adding(new Room() { ID = 2, Number = 107, Lesson = "Programming", Type = "lecture" });
audiences.Adding(new Room() { ID = 3, Number = 112, Lesson = "OOS", Type = "practice" });
audiences.Adding(new Room() { ID = 4, Number = 217, Lesson = "Physics", Type = "practice" });
audiences.Adding(new Room() { ID = 5, Number = 102, Lesson = "Math", Type = "lecture" });
audiences.Adding(new Room() { ID = 6, Number = 118, Lesson = "Math", Type = "practice" });
audiences.Adding(new Room() { ID = 7, Number = 133, Lesson = "OOS", Type = "lecture" });
audiences.Adding(new Room() { ID = 8, Number = 115, Lesson = "Physics", Type = "practice" });
audiences.Adding(new Room() { ID = 9, Number = 36, Lesson = "Programming", Type = "practice" });
audiences.Adding(new Room() { ID = 10, Number = 123, Lesson = "English", Type = "practice" });
audiences.Adding(new Room() { ID = 11, Number = 223, Lesson = "History", Type = "practice" });
audiences.Adding(new Room() { ID = 12, Number = 102, Lesson = "History", Type = "lecture" });
planner.Adding(new Plan() { Day = "Monday", GroupID = 1, AudienceID = 1, SubjectID = 4 });
planner.Adding(new Plan() { Day = "Monday", GroupID = 1, AudienceID = 4, SubjectID = 2 });
planner.Adding(new Plan() { Day = "Monday", GroupID = 1, AudienceID = 2, SubjectID = 8 });
planner.Adding(new Plan() { Day = "Tuesday", GroupID = 1, AudienceID = 2, SubjectID = 8 });
planner.Adding(new Plan() { Day = "Tuesday", GroupID = 1, AudienceID = 1, SubjectID = 1 });
planner.Adding(new Plan() { Day = "Tuesday", GroupID = 1, AudienceID = 5, SubjectID = 5 });
planner.Adding(new Plan() { Day = "Wendnesday", GroupID = 1, AudienceID = 10, SubjectID = 13 });
planner.Adding(new Plan() { Day = "Wednesday", GroupID = 1, AudienceID = 9, SubjectID = 9 });
planner.Adding(new Plan() { Day = "Thursday", GroupID = 1, AudienceID = 7, SubjectID = 10 });
planner.Adding(new Plan() { Day = "Thursday", GroupID = 1, AudienceID = 3, SubjectID = 11 });
planner.Adding(new Plan() { Day = "Friday", GroupID = 1, AudienceID = 12, SubjectID = 14 });
planner.Adding(new Plan() { Day = "Friday", GroupID = 1, AudienceID = 11, SubjectID = 15 });
planner.Adding(new Plan() { Day = "Monday", GroupID = 2, AudienceID = 10, SubjectID = 12 });
planner.Adding(new Plan() { Day = "Monday", GroupID = 2, AudienceID = 9, SubjectID = 9 });
planner.Adding(new Plan() { Day = "Monday", GroupID = 2, AudienceID = 2, SubjectID = 8 });
planner.Adding(new Plan() { Day = "Tuesday", GroupID = 2, AudienceID = 2, SubjectID = 8 });
planner.Adding(new Plan() { Day = "Tuesday", GroupID = 2, AudienceID = 1, SubjectID = 1 });
planner.Adding(new Plan() { Day = "Tuesday", GroupID = 2, AudienceID = 5, SubjectID = 5 });
planner.Adding(new Plan() { Day = "Wednesday", GroupID = 2, AudienceID = 10, SubjectID = 12 });
planner.Adding(new Plan() { Day = "Wednesday", GroupID = 2, AudienceID = 6, SubjectID = 7 });
planner.Adding(new Plan() { Day = "Thursday", GroupID = 2, AudienceID = 7, SubjectID = 10 });
planner.Adding(new Plan() { Day = "Thursday", GroupID = 2, AudienceID = 9, SubjectID = 9 });
planner.Adding(new Plan() { Day = "Friday", GroupID = 2, AudienceID = 12, SubjectID = 14 });
planner.Adding(new Plan() { Day = "Friday", GroupID = 2, AudienceID = 4, SubjectID = 2 });
audiences.Notify += DisplayMessage;
groups.Notify += DisplayMessage;
subjects.Notify += DisplayMessage;
planner.Notify += DisplayMessage;
string day = null;
while (true)
{
Console.WriteLine("Choose a day");
Console.WriteLine("Monday - 1, Tuesday - 2, Wednesday - 3, Thursday - 4, Friday - 5, Week - 6, Exit - 10");
int d = Convert.ToInt32(Console.ReadLine());
if (d == 1)
{
day = "Monday";
}
if (d == 2)
{
day = "Tuesday";
}
if (d == 3)
{
day = "Wednesday";
}
if (d == 4)
{
day = "Thursday";
}
if (d == 5)
{
day = "Friday";
}
if (d == 6)
{
Console.WriteLine("Choose a group");
var g = groups.FindAll();
foreach (var i in g)
{
Console.WriteLine($"ID = {i.ID} {i.Flow} - {i.GroupNum}");
}
Console.WriteLine("Enter id");
var id = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i < 5; i++)
{
switch (i)
{
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
}
planner.Choose(planner, groups, subjects, audiences, day, id);
}
break;
}
if (d == 10)
{
break;
}
Console.WriteLine("Choose a group");
var gr = groups.FindAll();
foreach (var i in gr)
{
Console.WriteLine($"ID = {i.ID} {i.Flow} - {i.GroupNum}");
}
Console.WriteLine("Enter id");
var groupid = Convert.ToInt32(Console.ReadLine());
planner.Choose(planner, groups, subjects, audiences, day, groupid);
}
Console.ReadKey();
}
public static void DisplayMessage(string message)
{
Console.WriteLine(message);
}
}
}
namespace Library
{
interface IRepository<T> where T : class
{
IEnumerable<T> FindAll();
void Adding(T id);
void Removing(int id);
T FindByID(int id);
} }
namespace Library
{
public class GroupRepository : IRepository<Group>
{
public delegate void Handler(string message);
public event Handler Notify;
List<Group> groups { set; get; }
GroupRepository()
{
groups = new List<Group>();
}
GroupRepository(IEnumerable<Group> grooups)
{
groups = new List<Group>(grooups);
}
public void Adding(Group group)
{
groups.Find((x) => x.ID == group.ID);
if (group.ID < 0)
{
throw new IndexOutOfRangeException("Index out of range");
}
if (groups.Exists((x) => x.ID == group.ID))
{
throw new InvalidOperationException("The group with this id has already exists!");
}
if (groups.Exists((x) => x.GroupNum == group.GroupNum && groups.Exists((y) => y.Flow == group.Flow)))
{
throw new InvalidOperationException("The group of the speciality has already exists!");
}
groups.Add(group);
}
public void Removing(int id)
{
var c = groups.Find((x) => x.ID == id);
if (id < 0 || id == 0)
{
throw new IndexOutOfRangeException("Index out of range");
}
groups.Remove(c);
Notify?.Invoke($"Group {c.GroupNum}-{c.Flow} was removed");
}
public IEnumerable<Group> FindAll()
{
foreach (var gr in groups)
{
yield return gr;
}
}
public Group FindByID(int id)
{
groups.Find((x) => x.ID == id);
if (id < 0 || id == 0)
{
throw new IndexOutOfRangeException("Index out of range");
}
return groups[id - 1];
}
public void Update(Group group)
{
var ind = groups.FindIndex((x) => x.ID == group.ID);
if (ind == -1)
{
throw new InvalidOperationException("Item not exists");
}
groups[ind] = group;
Notify?.Invoke($"Group {group.GroupNum}-{group.Flow} was updated");
}
}
}
new Library.GroupRepository()