Как мы находим интерфейсы, которые включают интерфейсы?
I need to find classes that use the interface, and I need to access the properties within those classes. How can I follow a path? Thank you for your help.
using System.Drawing; namespace HesapMakinesi.Interfaces { public interface IHesaplama { byte Genişlik { get; set; } byte Yukseklik { get; set; } string Butonİsmi { get; set; } Color ButonRengi { get; set; } Color ButonİsimRengi { get; set; } int LocacationX { get; set; } int LocationY { get; set; } float Sayi1 { get; set; } float Sayi2 { get; set; } float IslemYap(); } } public class Toplama : IHesaplama { public float Sayi1 { get; set; } public float Sayi2 { get; set; } public byte Genişlik { get; set; } public byte Yukseklik { get; set; } public string Butonİsmi { get; set; } public Color ButonRengi { get; set; } public Color ButonİsimRengi { get; set; } public int LocacationX { get; set; } public int LocationY { get; set; } public Toplama() { Genişlik = 30; Yukseklik = 30; Butonİsmi = "+"; ButonRengi = Color.Gray; ButonİsimRengi = Color.Black; LocacationX = 100; LocationY = 100; } public float IslemYap() { return Sayi1 + Sayi2; } }
There is a separate class in other operations, such as the aggregation class. All of them have a common interface. Well;
private void Form1_Load(object sender, EventArgs e) { }
What should I write between these blocks that all classes using the interface should be added to the automatic calculation machine.
Что я уже пробовал:
var result = new List<Type>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var type in assembly.GetTypes()) { if (typeof(IHesaplama).IsAssignableFrom(type)) { result.Add(type); } } }
I tried this code but couldn't reach the classes using the interface.