Professional Documents
Culture Documents
СпNET ЛБ2
СпNET ЛБ2
Кафедра ЕОМ
Лабораторна робота №2
з дисципліни «Спеціальні розділи програмування на .NET»
на тему:
"ДОСЛІДЖЕННЯ МЕХАНІЗМІВ ВІДДЗЕРКАЛЕННЯ ТА ЗАСОБІВ
ДИНАМІЧНОГО ГЕНЕРУВАННЯ КОДУ"
Виконав: Прийняв:
ст.гр. СПм-19-2 Федорченко В. М.
Слісаренко М.В.
Харків 2020
Мета роботи:
1. Створити збірку (* .dll), що містить типи (тип) описує задану предметну область:
Employee.cs
using System;
namespace CNnet_Lab1.Models
{
//Общая информация о сотруднике
public class Employee
{
public int Id { get; private set; }
public string FullName { get; private set; }
public string Address { get; private set; }
public string Telephone { get; private set; }
public string OtherInfo { get; private set; }
public Employee(int id, string address, string fullname, string telephone, string otherInfo=null)
{
Id = id;
Address = address;
if (string.IsNullOrEmpty(fullname))
{
throw new Exception("Employee should have a Name");
}
FullName = fullname;
if (string.IsNullOrEmpty(telephone))
{
throw new Exception("Employee should have a Telephone");
}
Telephone = telephone;
OtherInfo = otherInfo ?? string.Empty;
}
public override string ToString()
{
return $"Id: {Id}, FullName: {FullName}, Address: {Address}, Telephone: {Telephone}, OtherInfo:
{OtherInfo}";
}
}
}
Organization.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CNnet_Lab1.Models
{
//Оганизация
public class Organization
{
private List<Employee> _employees = new List<Employee>();
public int OrganizationId { get; private set; }
public string OrganizationName { get; private set; }
public IEnumerable<Employee> Employees { get => _employees; }
public void AddEmployee(int id,string address,string fullName, string telephone, string otherInfo=null)
{
var existingEmployee = _employees.SingleOrDefault(x => x.Id == id);
if(existingEmployee != null)
{
throw new Exception("Employee with such Id already exists");
}
var employee = new Employee(id, address, fullName, telephone, otherInfo);
_employees.Add(employee);
}
}
}
Program.cs
using System;
using CNnet_Lab1.Models;
namespace OrganizationChecker
{
public class Program
{
static void Main(string[] args)
{
var organization = new Organization(1,"Sevaastol");
Console.ReadLine();
}
}
}
Реалізувати клас призначеного для користувача атрибуту. Застосувати для
користувача атрибут до типу з збірки * .dll
2. Створити збірку (* .exe), що реалізує роботу з бібліотекою, збірку бібліотеки
завантажити динамічно відповідно до варіанта:
1 - метод Load;
2 - метод LoadFrom.
1.3 Висновки:
В ході даної роботи були виконані завдання відповідно до поставленої мети.
Результати виконання завдання представлені у звіті.