NameSpacedeki tüm class isimlerini öğrenme ve NameSpaceden Form Açmakaynak ->
https://stackoverflow.com/questions/949246/how-can-i-get-all-classes-within-a-namespace
1-) C# RMOS - Metot
private Type[] GetTypesInNamespace(Assembly assembly, string nameSpace)
{
return
assembly.GetTypes()
.Where(t => String.Equals(t.Namespace, nameSpace, StringComparison.Ordinal))
.ToArray();
}
2-) Kullanımı
Type[] typelist = GetTypesInNamespace(Assembly.GetExecutingAssembly(), "OrderTakerUltimate.Source");
for (int i = 0; i < typelist.Length; i++)
{
Console.WriteLine(typelist[i].Name);
}
3-) eğer .Net 2.0 kullanıyorsan
Assembly myAssembly = typeof(< Namespace >.< someClass >).GetTypeInfo().Assembly;
Type[] typelist = GetTypesInNamespace(myAssembly, "<Namespace>");
for (int i = 0; i < typelist.Length; i++)
{
Console.WriteLine(typelist[i].Name);
}
4-) NameSpace'den Form Açma
var form = Activator.CreateInstance(Type.GetType("OrderTakerUltimate.Source." + Form_adi)) as Form;
form.ShowDialog();
5-) ikinci maddenin "2-)" özelleşmiş hali yani Formu açmak için böyle yapabilirsin . Varsa açar
string Form_adi = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["rForm_ad"]).ToString();
Type[] typelist = GetTypesInNamespace(Assembly.GetExecutingAssembly(), MyNameSpace);
for (int i = 0; i < typelist.Length; i++)
{
var form = Activator.CreateInstance(Type.GetType(MyNameSpace + "." + typelist[i].Name)) as Form;
Console.WriteLine(typelist[i].Name+"-"+ form.Text);
if (typelist[i].Name.Equals(Form_adi))
{
form.ShowDialog();
break;
}
}