Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
AnswerRe: Deserialize old versions Pin
Mark Salsbery6-Oct-08 8:47
Mark Salsbery6-Oct-08 8:47 
GeneralRe: Deserialize old versions Pin
eggsovereasy6-Oct-08 10:47
eggsovereasy6-Oct-08 10:47 
QuestionWindow Manager Collection Pin
Kevin Marois6-Oct-08 8:09
professionalKevin Marois6-Oct-08 8:09 
AnswerRe: Window Manager Collection Pin
Mark Salsbery6-Oct-08 8:27
Mark Salsbery6-Oct-08 8:27 
GeneralRe: Window Manager Collection Pin
Kevin Marois6-Oct-08 9:56
professionalKevin Marois6-Oct-08 9:56 
QuestionRe: Window Manager Collection Pin
led mike6-Oct-08 10:01
led mike6-Oct-08 10:01 
GeneralRe: Window Manager Collection Pin
Mark Salsbery6-Oct-08 10:35
Mark Salsbery6-Oct-08 10:35 
QuestionDynamic setting of properties from data stream Pin
James R. Twine6-Oct-08 7:07
James R. Twine6-Oct-08 7:07 
   So!  I finally am getting into more and more C#/.NET development, I am wondering if the following is possible using reflection and some other .NET-fu that I now nothing about (yet).

   Here is what I am thinking... Presume I have several streams of CSV data that I want to convert into object form.  While it is possible to parse the CSV and manually assign properties for each value, I have to write specific code for each object and (expected) stream format that I want to process.

   I am wondering if this code can be generic so that I can just pass in the CSV stream, an object, and a set of properties that are on that object, and the code can extract the values, and use reflection (or something) to get at the property by its name, and set the value.  Something like this:
String sCSVString = "<code>Value1,ValueABC</code>,Value2,<code>ValueXYZ</code>";
-----------------------------
//
// Object objMyObject has these string properties, Prop1, Prop2, Prop3, Prop4
//
// This Function Would Use The "params" Parameter Type/Handling...
//
AssignPropertiesFromCSV( sCSVString, objMyObject, "Prop1", "Prop2", null, "Prop4" );

   Where the result would be that objMyObject would have Prop1, Prop2 and Prop4 set to Value1, ValueABC and ValueXYZ respectively, skipping over the Prop3 property due to the null parameter passed in.

   Is it possible to use reflection to dynamically examine objMyObject to find out if it has a Prop1 property, and then set it to a value?

   My guess is that some ORM frameworks may work this way, but I have yet to delve into them and wanted to get a feel for it from the more C#-experienced devs here first.

   While examples are not required, they are welcome.  I just want to know if this is worth looking into or not.

   Thanks!

   Peace!

-=- James
Please rate this message - let me know if I helped or not!<hr></hr>If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles



AnswerRe: Dynamic setting of properties from data stream Pin
Wendelius6-Oct-08 7:58
mentorWendelius6-Oct-08 7:58 
AnswerRe: Dynamic setting of properties from data stream Pin
N a v a n e e t h6-Oct-08 8:00
N a v a n e e t h6-Oct-08 8:00 
GeneralRe: Dynamic setting of properties from data stream Pin
James R. Twine8-Oct-08 1:49
James R. Twine8-Oct-08 1:49 
AnswerRe: Dynamic setting of properties from data stream Pin
Mark Churchill6-Oct-08 17:12
Mark Churchill6-Oct-08 17:12 
GeneralRe: Dynamic setting of properties from data stream Pin
James R. Twine8-Oct-08 1:54
James R. Twine8-Oct-08 1:54 
QuestionData sending/receiving using a dial-up modem and C# Pin
ajorge20086-Oct-08 6:50
ajorge20086-Oct-08 6:50 
AnswerRe: Data sending/receiving using a dial-up modem and C# Pin
N a v a n e e t h6-Oct-08 7:11
N a v a n e e t h6-Oct-08 7:11 
AnswerRe: Data sending/receiving using a dial-up modem and C# Pin
Pedram Behroozi6-Oct-08 7:15
Pedram Behroozi6-Oct-08 7:15 
QuestionWhich is the most used programming language Pin
Christopher Clarke6-Oct-08 6:43
Christopher Clarke6-Oct-08 6:43 
AnswerRe: Which is the most used programming language Pin
User 66586-Oct-08 6:51
User 66586-Oct-08 6:51 
AnswerRe: Which is the most used programming language Pin
N a v a n e e t h6-Oct-08 7:22
N a v a n e e t h6-Oct-08 7:22 
GeneralRe: Which is the most used programming language Pin
led mike6-Oct-08 9:57
led mike6-Oct-08 9:57 
GeneralRe: Which is the most used programming language Pin
Guffa6-Oct-08 22:19
Guffa6-Oct-08 22:19 
AnswerRe: Which is the most used programming language PinPopular
#realJSOP6-Oct-08 8:00
mve#realJSOP6-Oct-08 8:00 
GeneralRe: Which is the most used programming language Pin
Paul Conrad6-Oct-08 9:50
professionalPaul Conrad6-Oct-08 9:50 
GeneralRe: Which is the most used programming language Pin
Pete O'Hanlon6-Oct-08 9:53
mvePete O'Hanlon6-Oct-08 9:53 
JokeRe: Which is the most used programming language Pin
Paul Conrad6-Oct-08 10:04
professionalPaul Conrad6-Oct-08 10: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.