0

Inspired by:
NServiceBus.Configure.With().Log4Net(a => a.YourProperty = "value");

I want to use something similar as configuration, suggestions are welcome. My biggest problem is that I can't quite figure out how to use the parameter input...

What exactly is going on here? NServiceBus uses Log4Net, as instance? set with YourProperty = value?

Please abstract from the NServiceBus etc. I've just provided that as foundation for the discussion.

2
  • 1
    See this question which explains what is going on (and discusses if this is a good idea or not) Commented Oct 19, 2010 at 20:41
  • .Attributes(style => "width:100%") I think it's another style, since you are not using a property here, but a style which is not strong typed anywhere. Commented Oct 19, 2010 at 21:14

1 Answer 1

1

The lambda is creating an expression tree, which is not code but metadata about what the lambda shall do.

Therefore you can then "take apart" the lambda and see what properties, methods etc. would have been accessed on that instance (which never existed, since it is a definition only).

Google for "expression tree .net" and you'll find a lot of info on the topic.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Lucero, Thank you pointing me to a search engine called Google whhoooo What you told me I was fully aware of, but I was interested in knowing what the method looked like that actually could handle such input and how it handles it :)
Hi Lucero... I think I begin to understand now... but I've a question though! How can I set the value? I have written expressions for, well years, kindof... but they uses an equal, this one uses property. Should it be something like: Expression<Func<TSource, string>> predicate
Sorry if I posted something you already knew. Many people are not aware that lambdas are not compiled to IL code directly by the C# compiler, but that they in fact are an abstract syntax tree which can be parsed, modified and finally compiled to IL. As for accessing properties, have a look at msdn.microsoft.com/en-us/library/… (sorry, another lame link to MSDN ;) )

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.