guneysus
6/16/2015 - 1:11 PM

Reflection.cs

Reflection.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Windows.Forms;


namespace ConsoleX
{
    class Program
    {
        static void Main(string[] args)
        {
            Type tip = typeof(Personel);
            var data = tip.GetMembers();
            foreach (var d in data)
            {
                var s = string.Format("{0} {1}", d.GetType(), d.Name);
                Console.WriteLine(s);
            }


            Assembly assembly = Assembly.LoadFile(System.IO.Path.GetFullPath(@"..\..\..\Hibrid.exe"));
            Type[] types = assembly.GetTypes();

            foreach (Type type in types)
            {
                //if (type is Form)
                if (type.BaseType !=null && type.BaseType.FullName == "System.Windows.Forms.Form")
                {
                    Form runTimeForm = assembly.CreateInstance(type.FullName) as Form;
                    Form runTimeForm2 = Activator.CreateInstance(type) as Form;
                    runTimeForm2.ShowDialog();
                }
            }
            Console.ReadLine();
        }
    }

    public abstract class Insan
    {
        public bool cinsiyet { get; set; }
    }

    public class Personel : Insan
    {
        public int Id { get; set; }
        public string Ad { get; set; }
        public string Soyad { get; set; }
    }
}