Click here to Skip to main content
15,891,372 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generic parameter/reflection problem Pin
Pete O'Hanlon10-Jul-07 2:32
mvePete O'Hanlon10-Jul-07 2:32 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 2:41
Bekjong10-Jul-07 2:41 
AnswerRe: Generic parameter/reflection problem Pin
Chintan.Desai10-Jul-07 2:08
Chintan.Desai10-Jul-07 2:08 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 2:22
Bekjong10-Jul-07 2:22 
GeneralRe: Generic parameter/reflection problem Pin
Le centriste10-Jul-07 2:38
Le centriste10-Jul-07 2:38 
AnswerRe: Generic parameter/reflection problem Pin
AFSEKI10-Jul-07 6:26
AFSEKI10-Jul-07 6:26 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 22:05
Bekjong10-Jul-07 22:05 
AnswerRe: Generic parameter/reflection problem Pin
AFSEKI11-Jul-07 22:04
AFSEKI11-Jul-07 22:04 
No, you won't be creating a new Form each time. It was just an example,
you can replace:

pool.Add("myformid", new LoginForm());
pool.Add("myAboutformid", new AboutForm());

as

pool.Add("myformid", myAlreadyCreatedLoginForm);
pool.Add("myAboutformid", myAlreadyCreatedAboutForm());

also:

GetForm(...) code I sent you does not create anything. Do you see any "new" keyword in the code/or am I blind?

Result:

- You have an assembly created in you bin\debug folder in which your Forms are also embedded. This is your store to create the Forms at run-time. You want to store some configuration related to your forms, so what you need is to store this configuration like size and location somewhere like an xml file. If you've done it(you've written Some basic data(location, position) can be retrieved from a file), then you want to get a Form from the pool. Then your pool is the one which is responsible of returning an instance of the Form type if there is already one, created in pre-call to GetForm(...) or you want to create a new instance with the configuration parameters stored using reflection. If this is what you want:

// The configurtation of the Form you serialize/deserialize
public class FormConfig : ConfigurationProperty /*or string, or xml file, or whatever you want */
{
}

public T GetForm<t>(string form_id) where T: Form
{
if(pool.ContainsKey(form_id))
{
return pool[form_id] as T;
}
else
{
// you may have a look at other overloaded method(s) of Activator.CreateInstance
return Activator.CreateInstance(T, new object[]{GetConfig(typeof(mySerializedForm))}) as T;
}
}

public FormConfig GetConfig(string key)
{
return ..... // return the deserialized config
}
public FormConfig GetConfig(Type key)
{
return ..... // return the deserialized config
}

"Peace at home, peace in the world"
Mustafa Kemal Atatürk(the founder of the Republic of Turkey and its first President.))
GeneralRe: Generic parameter/reflection problem Pin
Bekjong11-Jul-07 22:38
Bekjong11-Jul-07 22:38 
AnswerRe: Generic parameter/reflection problem Pin
AFSEKI11-Jul-07 23:58
AFSEKI11-Jul-07 23:58 
QuestionOPC communication in C# Pin
k reddy10-Jul-07 1:38
k reddy10-Jul-07 1:38 
AnswerRe: OPC communication in C# Pin
AlessandroOPC6-Apr-09 4:59
AlessandroOPC6-Apr-09 4:59 
QuestionShare DB on LAN Pin
mehrdadc4810-Jul-07 1:22
mehrdadc4810-Jul-07 1:22 
AnswerRe: Share DB on LAN Pin
Christian Graus10-Jul-07 1:24
protectorChristian Graus10-Jul-07 1:24 
GeneralRe: Share DB on LAN Pin
mehrdadc4810-Jul-07 1:33
mehrdadc4810-Jul-07 1:33 
GeneralRe: Share DB on LAN Pin
Colin Angus Mackay10-Jul-07 1:44
Colin Angus Mackay10-Jul-07 1:44 
GeneralRe: Share DB on LAN Pin
originSH10-Jul-07 1:48
originSH10-Jul-07 1:48 
QuestionWIN APP ON LAN Pin
Banjo Ayorinde10-Jul-07 0:54
Banjo Ayorinde10-Jul-07 0:54 
AnswerRe: WIN APP ON LAN Pin
Christian Graus10-Jul-07 1:19
protectorChristian Graus10-Jul-07 1:19 
QuestionRemove Duplicates in Datatable Pin
kibromg10-Jul-07 0:52
kibromg10-Jul-07 0:52 
AnswerRe: Remove Duplicates in Datatable Pin
Christian Graus10-Jul-07 1:20
protectorChristian Graus10-Jul-07 1:20 
AnswerRe: Remove Duplicates in Datatable Pin
Chintan.Desai10-Jul-07 2:19
Chintan.Desai10-Jul-07 2:19 
GeneralRe: Remove Duplicates in Datatable Pin
kibromg10-Jul-07 4:53
kibromg10-Jul-07 4:53 
AnswerRe: Remove Duplicates in Datatable Pin
AFSEKI10-Jul-07 6:28
AFSEKI10-Jul-07 6:28 
QuestionNEED CRYSTAL REPORT EXPERT Pin
Banjo Ayorinde10-Jul-07 0:47
Banjo Ayorinde10-Jul-07 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.