Click here to Skip to main content
15,900,973 members
Home / Discussions / C#
   

C#

 
AnswerRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 12:05
protectorAspDotNetDev16-Dec-11 12:05 
AnswerRe: Coolest way to do this string operation? Pin
harold aptroot16-Dec-11 12:16
harold aptroot16-Dec-11 12:16 
GeneralRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 12:25
protectorAspDotNetDev16-Dec-11 12:25 
GeneralRe: Coolest way to do this string operation? Pin
harold aptroot16-Dec-11 12:37
harold aptroot16-Dec-11 12:37 
GeneralRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 17:38
mvePIEBALDconsult16-Dec-11 17:38 
GeneralRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 17:52
protectorAspDotNetDev16-Dec-11 17:52 
AnswerRe: Coolest way to do this string operation? Pin
BillWoodruff16-Dec-11 18:09
professionalBillWoodruff16-Dec-11 18:09 
GeneralRe: Coolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 19:32
SledgeHammer0116-Dec-11 19:32 
I won't bore you with the full details of why I'm trying to do this because that'll be a long winded explanation Smile | :) . To summarize it in one sentence: I'm writing an application framework library and I currently instruct users to "copy these 4 lines into your startup code and modify the namespace to handle this specific scenario".

The code they copy is basically 4 lines that look something like:

WpfApplication3.Properties.Settings.Default...

I'd like to update my framework so they no longer have to do that. I already have an 'ApplicationEx' class that they derive from.

So, what I do is, in the ApplicationEx constructor, I do:

string type = this.GetType().ToString(); // this is going to give me something like "WpfApplication3.App"

I then take "WpfApplication3.App" and use the string manipulation stuff above to get the string "WpfApplication3.Properties.Settings".

I then do:

Type t = Type.GetType("WpfApplication3.Properties.Settings"); // Type.GetType is a static method in the Type class

that gives me the type of the settings class. The settings class (as generated in VS) has a static public property called Default that returns the instance, so I simply use reflection to get the PropertyInfo of that property and invoke the getter and viola... I've got an ApplicationSettingsBase reference to the settings class Smile | :) .
GeneralRe: Coolest way to do this string operation? Pin
BillWoodruff16-Dec-11 20:19
professionalBillWoodruff16-Dec-11 20:19 
QuestionHow to deploy thorugh command prompt? Pin
BalasubramanianK15-Dec-11 23:06
BalasubramanianK15-Dec-11 23:06 
AnswerRe: How to deploy thorugh command prompt? Pin
BillWoodruff16-Dec-11 1:17
professionalBillWoodruff16-Dec-11 1:17 
AnswerRe: How to deploy thorugh command prompt? Pin
PIEBALDconsult16-Dec-11 1:57
mvePIEBALDconsult16-Dec-11 1:57 
AnswerRe: How to deploy thorugh command prompt? Pin
Eddy Vluggen16-Dec-11 6:05
professionalEddy Vluggen16-Dec-11 6:05 
QuestionTwain Scanner Interface for .net with multipage support Pin
balakrishnanp15-Dec-11 18:51
balakrishnanp15-Dec-11 18:51 
AnswerRe: Twain Scanner Interface for .net with multipage support Pin
Richard MacCutchan15-Dec-11 22:29
mveRichard MacCutchan15-Dec-11 22:29 
GeneralRe: Twain Scanner Interface for .net with multipage support Pin
Pete O'Hanlon16-Dec-11 0:01
mvePete O'Hanlon16-Dec-11 0:01 
GeneralRe: Twain Scanner Interface for .net with multipage support Pin
Richard MacCutchan16-Dec-11 0:04
mveRichard MacCutchan16-Dec-11 0:04 
GeneralRe: Twain Scanner Interface for .net with multipage support Pin
Pete O'Hanlon16-Dec-11 0:08
mvePete O'Hanlon16-Dec-11 0:08 
GeneralRe: Twain Scanner Interface for .net with multipage support Pin
Richard MacCutchan16-Dec-11 0:17
mveRichard MacCutchan16-Dec-11 0:17 
GeneralRe: Twain Scanner Interface for .net with multipage support Pin
Pete O'Hanlon16-Dec-11 0:21
mvePete O'Hanlon16-Dec-11 0:21 
GeneralRe: Twain Scanner Interface for .net with multipage support Pin
BillWoodruff16-Dec-11 1:14
professionalBillWoodruff16-Dec-11 1:14 
QuestionParse Excel Currency Cell Pin
Saamir15-Dec-11 11:57
Saamir15-Dec-11 11:57 
AnswerRe: Parse Excel Currency Cell Pin
DaveyM6915-Dec-11 13:33
professionalDaveyM6915-Dec-11 13:33 
AnswerRe: Parse Excel Currency Cell Pin
Richard MacCutchan15-Dec-11 22:26
mveRichard MacCutchan15-Dec-11 22:26 
QuestionHow to include child property of LINQ to SQL object? Pin
Goalie3515-Dec-11 11:04
Goalie3515-Dec-11 11:04 

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.