I am working on Windows Phone 8 application.
I have a Windows Phone Class Library project(Called Base) and Windows Phone App(called child).
In my Base project i have a class which has methods and static variables.
Eg:
Class Settings
{
public static string AppName = "Base";
public virtual List<String> TabDetails()
{
List<String> TabDetails = new List<string>();
helpTabDetails.Add("AAA");
helpTabDetails.Add("BBB");
return helpTabDetails;
}
}
Now in my child app i am just linking this class (by pressing ALT when we are dragging and dropping we can link the class image etc ... i am not adding a reference in th references folder).
Now in my Base those were the default settings of my app, but i want to change those settings if REQUIRED, if i DONT REQUIRE to change then the default settings should be applied to my child app.
NOTE: My Base will have all the class related to my app, but my child app will only contain the app specific settings class.
How can i acheive this ?
EDIT
More specific:
In my Base:
Class Demo : Settings
{
AppName = "XYX"
override TabDetails() and give new implemntation
}
Now in my Child app if i am OVERRIDING these static variables or methods then it should pick those values, but how to acheive that ?
Ok so after a long chat, Finally got to get the requirement the OP was looking for.
In simple terms:
AppSettings
DefaultSettings
implements this interfaceCustomSettings
could or could not be present in the project which also would implement the AppSettings
interfaceQuestion is how to check and use ChildSettings
if present else use DefaultSettings
Solution:
Use reflection and check for the type's presence and if available to use it.
AppSettings appSettings;
var customSettingsType = Type.GetType("POCChild.ChildSettings");
if (customSettingsType == null)
appSettings = new DefaultSettings();
else
appSettings = (AppSettings)Activator.CreateInstance(customSettingsType);
Debug.WriteLine(appSettings.getAppName());
where "POCChild.ChildSettings"
is the Namespace.ClassName