Getting Data Using Interface with Winforms

Background
I've been given the role of rebuilding the primary application from the ground up, with OneClick install in mind. (The current version, does not support OneClick )
One of the main elements or the current system is that a number of data objects (Current user etc) is passed through each class or object as a user navigates the application.

Now that I get the chance to build from the ground up, I've moved these object to placed a single place, which the main form. Then I have created a number of different interface to access the the objects when needed.
The reason I have gone with the approach of adding the objects to the main form, is simple because its always accessible.

Below is an example on how I access the object, using an interface class and methods

Global interface object

private InterfaceProject.IUersInterfaceMainScreenGet interfaceObject ;


Create interface object

public static void createInterfaceObject()
{
try
{

interfaceObject = (InterfaceProject.IUersInterfaceMainScreenGet)System.Windows.Forms.Application.OpenForms["FormName"];
}
catch(Exception e)
{

Logging.Exception(e);
}
}

Get Object

public static DataObjectsProject.LoggedInUserDataObject UserDetails()
{
createInterfaceObject()
if(interfaceObject !=null)
return interfaceObject.GetUserDetails();
else
return null
}
Created: 03/08/2016 Total Comment: 0

Comments

(Not Displayed)
Human validation
Enter 1314 number, before submitting to confirm your human
[Home] [All Blogs] [Contact] [Me]