A
Andrus
Winforms UI assembly has static FormManager.FormCreator method which creates
forms taking entity as parameter.
I need to pass this method to business objects in business assembly so that
business methods can also create
forms but does not have reference to UI assembly.
I tried code below but got compile errows shown in comments.
How to fix ?
Andrus.
////// This code is in Entry, Winforms UI assembly and has references to
business assembly
using System.Windows.Forms;
public delegate void ActivateEntityForm<TEntity>();
class test
{
static void Main()
{
//Invalid expression term '>'
new
Customer().DoBusinessLogicAndShowResultFormsUsingFormManager(FormManager.FormCreator<>);
}
}
public static class FormManager
{
public static void FormCreator<TEntity>()
{
Form f = new Form();
f.Text = typeof(TEntity).Name;
f.Show();
}
}
/// Code below resides in business assembly and should not have references
to assembly above
class Customer
{
public void
DoBusinessLogicAndShowResultFormsUsingFormManager<TChildEntity>(
ActivateEntityForm<TChildEntity> formCreator)
{
//The variable 'x' cannot be used with type arguments
formCreator<Childentity1>();
formCreator<Childentity2>();
}
}
class Childentity1 { }
class Childentity2 { }
forms taking entity as parameter.
I need to pass this method to business objects in business assembly so that
business methods can also create
forms but does not have reference to UI assembly.
I tried code below but got compile errows shown in comments.
How to fix ?
Andrus.
////// This code is in Entry, Winforms UI assembly and has references to
business assembly
using System.Windows.Forms;
public delegate void ActivateEntityForm<TEntity>();
class test
{
static void Main()
{
//Invalid expression term '>'
new
Customer().DoBusinessLogicAndShowResultFormsUsingFormManager(FormManager.FormCreator<>);
}
}
public static class FormManager
{
public static void FormCreator<TEntity>()
{
Form f = new Form();
f.Text = typeof(TEntity).Name;
f.Show();
}
}
/// Code below resides in business assembly and should not have references
to assembly above
class Customer
{
public void
DoBusinessLogicAndShowResultFormsUsingFormManager<TChildEntity>(
ActivateEntityForm<TChildEntity> formCreator)
{
//The variable 'x' cannot be used with type arguments
formCreator<Childentity1>();
formCreator<Childentity2>();
}
}
class Childentity1 { }
class Childentity2 { }