static void Main(string[] args) { Console.WriteLine("--------- Класс Parrot ---------"); Reflector.GetAssemblyInfo("Lab04.Parrot"); Reflector.GetPublicCtors("Lab04.Parrot"); Console.WriteLine("Все общедоступные публичные методы класса: "); foreach (var i in Reflector.GetPublicMethods("Lab04.Parrot")) { Console.WriteLine(i); } Console.WriteLine("\tПоля и свойства класса: "); foreach (var i in Reflector.GetInfoFieldProperty("Lab04.Parrot")) { Console.WriteLine(i); } Console.WriteLine("\tИнтерфейсы"); foreach (var i in Reflector.GetInterface("Lab04.Parrot")) { Console.WriteLine(i); } Console.WriteLine("Методы, содержащие параметр типа int: "); Reflector.GetMethodByType("Lab04.Parrot", typeof(int)); Console.WriteLine("Invoke: "); Reflector.InvokeMethod("Lab04.Parrot", "Eat"); Console.WriteLine("--------- Класс Fish ---------"); Reflector.GetAssemblyInfo("Lab06.Fish"); Reflector.GetPublicCtors("Lab06.Fish"); Console.WriteLine("Все общедоступные публичные методы класса: "); foreach (var i in Reflector.GetPublicMethods("Lab06.Fish")) { Console.WriteLine(i); } Console.WriteLine("\tПоля и свойства класса: "); foreach (var i in Reflector.GetInfoFieldProperty("Lab06.Fish")) { Console.WriteLine(i); } Console.WriteLine("\tИнтерфейсы"); foreach (var i in Reflector.GetInterface("Lab06.Fish")) { Console.WriteLine(i); } Console.WriteLine("Методы, содержащие параметр типа strng: "); Reflector.GetMethodByType("Lab06.Fish", typeof(string)); Console.WriteLine("Invoke: "); Reflector.InvokeMethod("Lab06.Fish", "Sleep"); var i1 = Reflector.Create(typeof(Lab04.Parrot)); var i2 = Reflector.Create(typeof(Lab06.Fish)); var i3 = Reflector.Create(typeof(System.Int32)); Console.WriteLine(i1 + "\n" + i2 + "\n" + i3); }
static void Main(string[] args) { Console.WriteLine("----------------------------------------------------class1--------------------------------"); Vector vc = new Vector(1, 2, 3, 4, 5, 6); Console.WriteLine(Reflector.GetAssemblyInfo(vc.GetType())); if (Reflector.IsPublishConstructors(vc.GetType())) { Console.WriteLine("Class has constructor..."); } else { Console.WriteLine("Constructor in clas not found..."); } Console.WriteLine("Methods:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetMetodsInfo(vc.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Console.WriteLine("Fields:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetFieldInfo(vc.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Console.WriteLine("Interfaces:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetInterfaceInfo(vc.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Reflector.OutputMetodsNameFromParamType(vc.GetType()); Console.WriteLine("----------------------------------------------------class2--------------------------------"); //----------------------------------------- Owner ow = new Owner(); Console.WriteLine(Reflector.GetAssemblyInfo(ow.GetType())); if (Reflector.IsPublishConstructors(ow.GetType())) { Console.WriteLine("Class has constructor..."); } else { Console.WriteLine("Constructor in clas not found..."); } Console.WriteLine("Methods:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetMetodsInfo(ow.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Console.WriteLine("Fields:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetFieldInfo(ow.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Console.WriteLine("Interfaces:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetInterfaceInfo(ow.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Reflector.OutputMetodsNameFromParamType(ow.GetType()); Console.WriteLine("----------------------------------------------------standart class--------------------------------"); List <int> l = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8 }; Console.WriteLine(Reflector.GetAssemblyInfo(l.GetType())); if (Reflector.IsPublishConstructors(l.GetType())) { Console.WriteLine("Class has constructor..."); } else { Console.WriteLine("Constructor in clas not found..."); } Console.WriteLine("Methods:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetMetodsInfo(l.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Console.WriteLine("Fields:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetFieldInfo(l.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Console.WriteLine("Interfaces:"); Console.WriteLine("------------------------------------"); foreach (var i in Reflector.GetInterfaceInfo(l.GetType())) { Console.WriteLine(i); } Console.WriteLine("------------------------------------"); Reflector.OutputMetodsNameFromParamType(l.GetType()); object[] param = new object[1]; using (FileStream fstream = File.OpenRead($"data.txt")) { // преобразуем строку в байты byte[] array = new byte[fstream.Length]; // считываем данные fstream.Read(array, 0, array.Length); // декодируем байты в строку string textFromFile = System.Text.Encoding.Default.GetString(array); param[0] = Convert.ToInt32(textFromFile); } Reflector.Invoke(l, "Add", param); Random rand = new Random(); param[0] = rand.Next(); Reflector.Invoke(l, "Add", param); Console.ReadLine(); }