Milos Solution Platform (External Blog)

The Milos Solution Platform is .NET's premier platform for building business applications. This blog is meant for developers who use or evaluate Milos. This blog is used to share tidbits of information provided by the Milos developers at EPS. Many of the posts put the spotlight on new features. We generally recommend that all Milos users (developers) at least scan this blog to keep up with the Milos news.

Content Area Footer

Tuesday, January 06, 2009
Dynamic Property and Method Access

The upcoming version of Milos has a nifty little enhancement in the ObjectHelper class: It makes it easier to dynamically access/set properties and invoke methods. This is useful in scenarios that can otherwise only be handled with Reflection.

Example: Consider a scenario where a customer object is provided by some external system (perhaps from a dynamic language) and you need to access or set a name property. This can now be done like so in Milos:

object customer = GetCustomerObjectFromSomewhere();
string firstName = EPS.Utilities.ObjectHelper.GetPropertyValue<string>(customer, "FirstName");
EPS.Utilities.ObjectHelper.SetPropertyValue(customer, "LastName", "Smith");

Note that these methods are also available as extension methods. To use the extension methods, the EPS.Utilities namespace has to be included at a file level, by putting the following using statement at the top of your source file:

using EPS.Utilities;

Now, the above code can be simplified to the following:

object customer = GetCustomerObjectFromSomewhere();
string firstName = customer.GetPropertyValue<string>("FirstName");
customer.SetPropertyValue("LastName", "Smith");

Milos now also makes it easier to invoke methods dynamically. For instance, one can call a method ont he same object like so:

string name = customer.InvokeMethod<string>("GetFullName", null); 

Note that the second parameter is an array of parameters that get passed to the method. For instance, if the GetFullName() method takes an integer and a string parameter, it could be passed like so:

object[] parameters = { 0, "Test" };
string name = customer.InvokeMethod<string>("GetFullName", parameters); 

Note that C# 4.0 (once released) will provide features to also make it easier to do these things. In C# 4.0, the following syntax would be valid:

dynamic customer = GetCustomerObjectFromSomewhere();
string firstName = customer.FirstName;
customer.LastName = "Smith";
string name = customer.GetFullName(1, "Test");

The example used here, with the Customer object dynamically retrieved somewhere is one scenario where this is useful. There are other scenarios as well, where generic code is written that can operate on types that are defined elsewhere. Data binding scenarios are one example.


Posted @ 9:47 AM by Egger, Markus ( -
Comments (15)


RE: Dynamic Property and Method Access
Tuesday, June 21, 2011 9:45 PM by new era -

I may be notified whenever a new post has been made. I have subscribed to your rss feed which must do the trick! Have a nice day!

mac makeup
Tuesday, August 16, 2011 4:07 AM by mac makeup -

Bad luck often brings good luck.

RE: Dynamic Property and Method Access
Wednesday, September 21, 2011 8:00 AM by Android developer -

Interesting blog and its so impressive, i really enjoyed to read your information, i think your blog easily to get good branding and more traffics , because every one to likes your blogs. thanks for your wonderful informative post.

RE: Dynamic Property and Method Access
Thursday, October 27, 2011 12:04 AM by Door latches -

Hello there, I enjoyed reading your post, thanks for this ……. I have noticed one in your pages, it takes so long to load ?

RE: Dynamic Property and Method Access
Tuesday, November 08, 2011 6:41 PM by SWF Converter for Mac -

Preparation: Free download and install Mac SWF Video Converter, launch it.

Sheath/ Column Wedding Dress
Friday, November 18, 2011 2:02 AM by Sheath/ Column Wedding Dress -

As much work as it was doing most of it DIY, it was totally worth it in the end. Plus, having amazing vendors makes it SO much better! We worked hard up until the day of, then they took over for us,fg so we didn’t have to do a thing except enjoy each other and our friends and family.

Price of Silver Per Ounce
Friday, December 30, 2011 10:35 PM by how to get rid of lice -

There is obviously a lot to know about this.I think you made some good points in Features also.

RE: Dynamic Property and Method Access
Friday, December 30, 2011 10:36 PM by how to get rid of dark circles fast -

you are right when you say this.Hats off man,what a superlative knowledge you have on this subject.hope to see more work of yours.thanks

RE: Dynamic Property and Method Access
Monday, August 07, 2017 1:49 AM by cheap pandora

Looking to get her a unique jewellery gift with a personal touch? PANDORA offers a wide range of options that allow you to create something special that she will treasure forever.

RE: Dynamic Property and Method Access
Monday, August 21, 2017 2:14 AM by ssg -

PANDORA bracelet can be their own combination, the bracelet on the chain and the[url=]pandora charm bracelets on sale[/url] chain is used to separate the chain, and then string together. You can first visit the official website model  and then to[url= disney pandora charms 2017]pandora limited edition charms 2017[/url]the store to buy, decorated with gold, silver, glass, enamel and other materials of different shapes,bracelets have gold, [url= pandora charm discount for sale]sterling silver birthstone bracelet[/url]silver, fabric, leather and other materials can choose.

RE: Dynamic Property and Method Access
Thursday, March 29, 2018 2:13 AM by Do My Paper For Me

The most fascinating piece of this article begins here as the perplexing dynamic property class contains the center usage of our dynamic properties idea. I should say that we utilized a similar idea to speak to dynamic properties of the content component and organizing objects inside our item for content archive content control.

RE: Dynamic Property and Method Access
Tuesday, April 24, 2018 9:45 AM by entrusted essay writing service online

I would like to use this new method accessing coding in my servers. I have been using the older version off this same, which is released way back some 5 years back. This very good news to the people like me who are using this method accessing coding in our computer now will get new version of it.

Firestarter Guide
Monday, June 25, 2018 7:56 AM by JamesSmith -

Firestarter app is the magic stick that let you enjoy all the Android content on your fire TV. Firestarter app launches Android apps on Amazon Fire TV.

RE: Dynamic Property and Method Access
Monday, August 06, 2018 3:04 AM by -

Thank you for your work on the blog! You're doing a good job!

Best web Hosting Services
Saturday, November 10, 2018 4:59 AM by Kylie Williams -

You always share all the good and useful information for us. I really got so impressed with your article. Thanks

Post a Comment:

Comment Title (required)

Your Name (optional)

Your Email (optional)

Your Web Site (optional)

Your Comment (required)








Syndication RSS 2.0 RSS 2.0

All My Blogs:
My personal blogs:
Dev and Publishing Dev and Publishing
Travel and Internat. Living Travel and Internat. Living
Other blogs I contribute to:
Milos Blog (US) Milos Blog (US)
VFPConv. Dev Blog (US) VFPConv. Dev Blog (US)
VFPConv. Dev Blog (DE) VFPConv. Dev Blog (DE)


Blog Archives
All Blog Posts

    November (1)
    July (2)
    February (2)
    January (1)
    December (1)
    October (3)
    June (1)
    April (3)
    February (1)
    January (1)
    December (1)
    October (2)
    September (2)
    July (1)
    June (2)
    May (4)
    April (6)
    March (8)
    February (3)
    January (2)
    December (2)
    November (2)




This Blog is powered by MilosTM Collaboration Components.