Solved

How to extend/modify a C# object dynamically

Posted on 2009-04-08
4
480 Views
Last Modified: 2012-05-06
I'm looking for a way to allow the users of my C# .NET WinForms application to extend its business domain without having me make manual changes to the VS Project.
Here is an example:
Let's say, we have an application called "Friends List" that helps keep track of one's friends.
In this application there is an object named "Person", which has a single public property "FIrstName".
Now, let's assume that there is a second application called "List Maker" that present the user with a simple form to allow add more properties to the "Person" (i.e. "Last Name", "Address", etc...)
Once such additions are made, the "List Maker" application would, in fact, make changes to the existing "Person" class by adding the "Last Name" and "Address" public properties to it.
Then the "List Maker" application would recompile the "Friends List" project, so, the next time the user run it, the Person will have those added properties.
I think, this could be accomplished with a help of the CSharpCodeProvider class.
I'm just not sure how to do this.

-Eugene
0
Comment
Question by:eugene-g
  • 2
4 Comments
 
LVL 15

Expert Comment

by:spprivate
ID: 24102169
The way I would do is to have a parent class called person and then provide a child class which inherits from person with additional properties and do all the operations on the child class object
0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 24102413
Have a look at the discussion here. It might be helpful:

http://forums.asp.net/t/1362348.aspx
0
 

Author Comment

by:eugene-g
ID: 24107378
Is there a way to compile a C# solution without having Visual Studio installed?
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 24245595
Of course that's possible. Using C# compiler from a command line. Have a look:

http://www.softsteel.co.uk/tutorials/cSharp/lesson18.html

It's also possible to use tools like nant to "build" (compile) your solution. You may search for nant on internet. Have a look at simple example:

http://nant.sourceforge.net/release/latest/help/fundamentals/buildfiles.html
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System.Security 2 27
Set value of dynamically created checkboxlist 2 31
transaction in asp.net, sql server 6 31
tableview is not updating 1 7
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question