I am new to design patterns and need help:
i have an application where i have following Models:
LoginModel:
public string EmailAddress {get;set;}
public string Password {get;set;}
UsersModel:
public string EmailAddress {get;set;}
public string FullName {get;set;}
public int UserID {get;set;}
public int RoleID {get;set;}
public string RoleName {get;set;}
DefectSheetModel:
Public string DefectSheetName {get;set;}
public int> DefectSheetID {get;set;}
public string Comments {get;set;}
and many other Models with different properties altogether.
My question is, what is the best way to implement Factory (or Abstract Factory) pattern in my application using an Interface.
what i did is - created an empty Interface and inherited in eacha nd every model class.
created a Factory class with a method called Create which returns me that Interface type always. and based on the user request i created a switch case and return that particular concrete types (model) from the Factory.Create() method.
but i cannot use any properties as these were not defined in base interface.
I request you to let me know whether i can go with factory pattern with this condition or not.
would be great if someone explain the best real world example of how to use factory in ASP.NET mvc application.
Aucun commentaire:
Enregistrer un commentaire