{"id":63,"date":"2009-02-26T15:48:56","date_gmt":"2009-02-26T14:48:56","guid":{"rendered":"https:\/\/ridgesolutions.ie\/?p=63"},"modified":"2009-03-25T08:45:31","modified_gmt":"2009-03-25T07:45:31","slug":"dual-personality-property-with-lambdas-in-net","status":"publish","type":"post","link":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/","title":{"rendered":"Dual Personality Properties with Lambdas in .NET"},"content":{"rendered":"<p>Some time ago (!) <a href=\"https:\/\/ridgesolutions.ie\/index.php\/2008\/08\/07\/programatically-converting-a-literal-into-an-equivalent-lambda-expression-in-c30\/\">I wrote about<\/a>\u00a0an investigation\u00a0that I had carried out into how a literal value\u00a0could be mapped to and stored as a lambda expression\/delegate in C#.\u00a0 This was important for me at the time because I needed\u00a0to find some\u00a0way to have a &#8216;value&#8217; and a &#8216;value rule&#8217;\u00a0appear the same to callers.\u00a0 I wanted to define a type whose value when queried could either come from\u00a0the evaluation of a\u00a0previously specified &#8216;rule&#8217; or could simply be retrieved from\u00a0a real, previously stored value\u00a0&#8211; without the caller knowing the difference at all.<\/p>\n<p>\u00a0<\/p>\n<p>This type of concept is common in functional and logic programming languages &#8211; in these languages the separation between functionality (code) and data is very blurry, what is data one minute can become code the next,\u00a0and visa verse.\u00a0 It is harder to achieve (at a high level) in procedural languages but the addition of lambda expressions in .NET 3.0 brings us a a lot\u00a0closer (in .NET 3.0)!<\/p>\n<p>\u00a0<\/p>\n<p>The following might help to demonstrate how such a type might work,\u00a0imagine a generic class\u00a0called DualProp whose job is to yield a typed value when requested, this value could have been previously stored as a real value or could be obtaind by evaluating a previously specified lambda expression:<\/p>\n<p>\u00a0<\/p>\n<pre>[code lang=\"csharp\"]\r\n    \/\/ Create an integer property\r\n    var speed = new DualProp();\r\n\r\n    \/\/ set it to 3\r\n    speed = 3;\r\n\r\n    \/\/ Create an bool property, whose value depends\r\n    \/\/ on the speed's value.\r\n    var visible = new DualProp();\r\n\r\n    \/\/ visible only true if speed &gt; 5\r\n    visible.Lambda = () =&gt; speed &gt; 5;\r\n\r\n    \/\/ Check visible's value ( this results in the\r\n    \/\/ stored delegated being evaluated)\r\n    if (visible == true)\r\n        Console.WriteLine(\"It is visible\");\r\n    else\r\n        Console.WriteLine(\"It is invisible\");\r\n\r\n    \/\/ Set speed to 8, sould now be visible\r\n    speed = 8;\r\n\r\n    \/\/ Try again, it should be visible now\r\n    if (visible == true)\r\n        Console.WriteLine(\"It is visible\");\r\n    else\r\n        Console.WriteLine(\"It is invisible\");\r\n\r\n    \/\/ now just set visible's value to false\r\n    visible = false;\r\n\r\n    \/\/ And check it's value again, should be invisible\r\n    if (visible == true)\r\n        Console.WriteLine(\"It is visible\");\r\n    else\r\n        Console.WriteLine(\"It is invisible\");\r\n[\/code]<\/pre>\n<p>\u00a0<\/p>\n<p>Two properties are defined, an integer property called &#8216;speed&#8217; and a bool property called &#8216;visible&#8217;.\u00a0 Visible&#8217;s value depends on the evaluation of the delegate compiled from the lambda expression that was assigned to it:<\/p>\n<pre>[code lang=\"csharp\"] visible.Lambda = () =&gt; speed &gt; 5; [\/code]<\/pre>\n<p>So when queried, visible&#8217;s value is &#8216;true&#8217; if speed&#8217;s current value is greater than 5.<\/p>\n<p>This scheme should allow us to build up whole sets of properties some of whose values are real and others whose are dynamically computed based on the values of others.\u00a0 The values on which the lambda expressions depend can themselves be real or computed.<\/p>\n<p>\u00a0<\/p>\n<p>This type of set-up\u00a0could be very handy, especially when used\u00a0as part of a data driven\u00a0user interface. \u00a0A data driven user interface is typically laid out and behaves in accordance with some specified meta-data, this meta-data is usually static (no meta-rules, just meta-data!).\u00a0\u00a0Employing a scheme such as this should allow us to specify meta-data which can be dynamic, in that some of the meta-data can dynamically change based on applying &#8216;rules&#8217; to some of the real data.<\/p>\n<p>\u00a0<\/p>\n<p>Imagine a CAD\/CAM system for a laser drilling machine, it will have various logical tools defined that represent the different laser cutting tools onm the laser cutting machine. The\u00a0laser tool&#8217;s various parameters can be viewed and changed on the CAD\/CAM interface via a data driven property-page type interface. As usual the meta-data for this interface will specify a list of parameters along with some other data like:<\/p>\n<p>\u00a0<\/p>\n<ul>\n<li>Name &#8211; Attribute&#8217;s Name<\/li>\n<li>Type &#8211; Attribute&#8217;s Type (Number\/Boolean\/String etc.)<\/li>\n<li>Visibility &#8211; Is this Attribute visible for editing<\/li>\n<li>ReadOnly &#8211; Can the attribute&#8217;s value be changed?<\/li>\n<li>Min &#8211; Attribute&#8217;s Minimum allowed value<\/li>\n<li>Max &#8211; Attribute&#8217;s Maximum allowed value<\/li>\n<li>HelpString &#8211; Some help text for the attribute<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<p>Rule based properties should allow us to do things like set the min\u00a0&amp; max values based on another parameter&#8217;s value or force a parameter to be read-only based on the value of yet another parameter (by specifying a rule for the visibility attribute).\u00a0 Anyway, I hope to expand on this in a future post.<\/p>\n<p>\u00a0<\/p>\n<p>Meanwhile, Here is the code for the DualProp class:<\/p>\n<pre>[code lang=\"csharp\"]\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Linq.Expressions;\r\n\r\n\/\/ (c) 2009 Kevin Godden, Ridge Solutions.\r\npublic class DualProp\r\n{\r\n    \/\/ The property's delegate, which will\r\n    \/\/ be evaluated whenever the property's value\r\n    \/\/ is queried.\r\n    private Func _lambda = null;\r\n\r\n    \/\/ Map the passed value (of type T) to a lambda and\r\n    \/\/ then compile to a delegate.\r\n    private Func ToLambda(T val)\r\n    {\r\n        var body = Expression.Constant(val);\r\n        var exp = Expression.Lambda&gt;(body, null);\r\n\r\n        return (Func)exp.Compile();\r\n    }\r\n\r\n    \/\/ Given a value of type T, convert it\r\n    \/\/ to a corresponding lambda delegate\r\n    \/\/ and store it.\r\n    private void SetValue(T val)\r\n    {\r\n        _lambda = ToLambda(val);\r\n    }\r\n\r\n    \/\/ Set for _lambda, used when we want\r\n    \/\/ to specify a property 'rule' rather\r\n    \/\/ than a literal value.\r\n    public Func Lambda\r\n    {\r\n        set { _lambda = value; }\r\n    }\r\n\r\n    \/\/ Constructors\r\n    public DualProp()\r\n    {\r\n    }\r\n\r\n    \/\/ Construct with value\r\n    public DualProp(T val)\r\n    {\r\n        SetValue(val);\r\n    }\r\n\r\n    \/\/ Construct with a 'rule' (lambda\/delegate)\r\n    public DualProp(Func lambda)\r\n    {\r\n        _lambda = lambda;\r\n    }\r\n\r\n    \/\/ Allows us to assign a value directly to\r\n    \/\/ a DualProp i.e. --&gt;\r\n    \/\/ DualProp dualProperty = new DualProp();\r\n    \/\/ dualProperty = 10;\r\n    public static implicit operator DualProp(T val)\r\n    {\r\n        return new DualProp(val);\r\n    }\r\n\r\n    \/\/ Allows us to query a DualProp's value directly\r\n    \/\/ i.e. --&gt;\r\n    \/\/ DualProp dualProperty = new DualProp(10);\r\n    \/\/ int value = dualProp;\r\n    public static implicit operator T(DualProp sp)\r\n    {\r\n        return sp._lambda();\r\n    }\r\n}\r\n[\/code]<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago (!) I wrote about\u00a0an investigation\u00a0that I had carried out into how a literal value\u00a0could be mapped to and stored as a lambda expression\/delegate in C#.\u00a0 This was important for me at the time because I needed\u00a0to find some\u00a0way to have a &#8216;value&#8217; and a &#8216;value rule&#8217;\u00a0appear the same to callers.\u00a0 I wanted [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[57,61,60,59,71],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-tech-stuff","tag-net","tag-csharp","tag-data-driven-ui","tag-delegate","tag-lambda"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a &#039;value&#039; and a &#039;value rule&#039; appear the same to callers. I wanted\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Kevin Godden\"\/>\n\t<meta name=\"google-site-verification\" content=\"Kyj52YLp6GOPA44PVBffo9fjW8rgWHYYRF0ZYjfy6ss\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Systems and Embedded Software Engineering, Ireland. | Some thoughts of a busy Computer Engineer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Dual Personality Properties with Lambdas in .NET\" \/>\n\t\t<meta property=\"og:description\" content=\"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a &#039;value&#039; and a &#039;value rule&#039; appear the same to callers. I wanted\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2009-02-26T14:48:56+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2009-03-25T07:45:31+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Dual Personality Properties with Lambdas in .NET\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a &#039;value&#039; and a &#039;value rule&#039; appear the same to callers. I wanted\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#article\",\"name\":\"Dual Personality Properties with Lambdas in .NET\",\"headline\":\"Dual Personality Properties with Lambdas in .NET\",\"author\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/ridge_logo1.jpg\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#articleImage\",\"width\":400,\"height\":81},\"datePublished\":\"2009-02-26T15:48:56+00:00\",\"dateModified\":\"2009-03-25T08:45:31+00:00\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#webpage\"},\"articleSection\":\"Tech Stuff, .NET, c#, Data Driven UI, delegate, lambda\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.ridgesolutions.ie\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/tech-stuff\\\/#listItem\",\"name\":\"Tech Stuff\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/tech-stuff\\\/#listItem\",\"position\":2,\"name\":\"Tech Stuff\",\"item\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/tech-stuff\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#listItem\",\"name\":\"Dual Personality Properties with Lambdas in .NET\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#listItem\",\"position\":3,\"name\":\"Dual Personality Properties with Lambdas in .NET\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/category\\\/tech-stuff\\\/#listItem\",\"name\":\"Tech Stuff\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\",\"name\":\"Ridge Solutions, Software Development and Software Engineering, Ireland.\",\"description\":\"Some thoughts of a busy Computer Engineer\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/wp-content\\\/uploads\\\/2013\\\/09\\\/ridge_logo1.jpg\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#organizationLogo\",\"width\":400,\"height\":81},\"image\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/\",\"name\":\"Kevin Godden\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d2833f41e59a25cf2a9741a05ec383bfdd278762a5e0798a90940e7ab0a107a2?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Kevin Godden\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#webpage\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/\",\"name\":\"Dual Personality Properties with Lambdas in .NET\",\"description\":\"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\\\/delegate in C#. This was important for me at the time because I needed to find some way to have a 'value' and a 'value rule' appear the same to callers. I wanted\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/2009\\\/02\\\/26\\\/dual-personality-property-with-lambdas-in-net\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/index.php\\\/author\\\/kgodden\\\/#author\"},\"datePublished\":\"2009-02-26T15:48:56+00:00\",\"dateModified\":\"2009-03-25T08:45:31+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#website\",\"url\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/\",\"name\":\"Ridge Solutions, Software Development and Software Engineering, Ireland.\",\"description\":\"Some thoughts of a busy Computer Engineer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.ridgesolutions.ie\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Dual Personality Properties with Lambdas in .NET","description":"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a 'value' and a 'value rule' appear the same to callers. I wanted","canonical_url":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"Kyj52YLp6GOPA44PVBffo9fjW8rgWHYYRF0ZYjfy6ss","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#article","name":"Dual Personality Properties with Lambdas in .NET","headline":"Dual Personality Properties with Lambdas in .NET","author":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author"},"publisher":{"@id":"https:\/\/www.ridgesolutions.ie\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/www.ridgesolutions.ie\/wp-content\/uploads\/2013\/09\/ridge_logo1.jpg","@id":"https:\/\/www.ridgesolutions.ie\/#articleImage","width":400,"height":81},"datePublished":"2009-02-26T15:48:56+00:00","dateModified":"2009-03-25T08:45:31+00:00","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#webpage"},"isPartOf":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#webpage"},"articleSection":"Tech Stuff, .NET, c#, Data Driven UI, delegate, lambda"},{"@type":"BreadcrumbList","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie#listItem","position":1,"name":"Home","item":"https:\/\/www.ridgesolutions.ie","nextItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/tech-stuff\/#listItem","name":"Tech Stuff"}},{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/tech-stuff\/#listItem","position":2,"name":"Tech Stuff","item":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/tech-stuff\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#listItem","name":"Dual Personality Properties with Lambdas in .NET"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#listItem","position":3,"name":"Dual Personality Properties with Lambdas in .NET","previousItem":{"@type":"ListItem","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/tech-stuff\/#listItem","name":"Tech Stuff"}}]},{"@type":"Organization","@id":"https:\/\/www.ridgesolutions.ie\/#organization","name":"Ridge Solutions, Software Development and Software Engineering, Ireland.","description":"Some thoughts of a busy Computer Engineer","url":"https:\/\/www.ridgesolutions.ie\/","logo":{"@type":"ImageObject","url":"https:\/\/www.ridgesolutions.ie\/wp-content\/uploads\/2013\/09\/ridge_logo1.jpg","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#organizationLogo","width":400,"height":81},"image":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author","url":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/","name":"Kevin Godden","image":{"@type":"ImageObject","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d2833f41e59a25cf2a9741a05ec383bfdd278762a5e0798a90940e7ab0a107a2?s=96&d=mm&r=g","width":96,"height":96,"caption":"Kevin Godden"}},{"@type":"WebPage","@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#webpage","url":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/","name":"Dual Personality Properties with Lambdas in .NET","description":"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a 'value' and a 'value rule' appear the same to callers. I wanted","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.ridgesolutions.ie\/#website"},"breadcrumb":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/#breadcrumblist"},"author":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author"},"creator":{"@id":"https:\/\/www.ridgesolutions.ie\/index.php\/author\/kgodden\/#author"},"datePublished":"2009-02-26T15:48:56+00:00","dateModified":"2009-03-25T08:45:31+00:00"},{"@type":"WebSite","@id":"https:\/\/www.ridgesolutions.ie\/#website","url":"https:\/\/www.ridgesolutions.ie\/","name":"Ridge Solutions, Software Development and Software Engineering, Ireland.","description":"Some thoughts of a busy Computer Engineer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.ridgesolutions.ie\/#organization"}}]},"og:locale":"en_US","og:site_name":"Systems and Embedded Software Engineering, Ireland. | Some thoughts of a busy Computer Engineer","og:type":"article","og:title":"Dual Personality Properties with Lambdas in .NET","og:description":"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a 'value' and a 'value rule' appear the same to callers. I wanted","og:url":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/","article:published_time":"2009-02-26T14:48:56+00:00","article:modified_time":"2009-03-25T07:45:31+00:00","twitter:card":"summary","twitter:title":"Dual Personality Properties with Lambdas in .NET","twitter:description":"Some time ago (!) I wrote about an investigation that I had carried out into how a literal value could be mapped to and stored as a lambda expression\/delegate in C#. This was important for me at the time because I needed to find some way to have a 'value' and a 'value rule' appear the same to callers. I wanted"},"aioseo_meta_data":{"post_id":"63","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-09-13 18:55:53","updated":"2025-07-15 20:33:20","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.ridgesolutions.ie\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.ridgesolutions.ie\/index.php\/category\/tech-stuff\/\" title=\"Tech Stuff\">Tech Stuff<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tDual Personality Properties with Lambdas in .NET\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.ridgesolutions.ie"},{"label":"Tech Stuff","link":"https:\/\/www.ridgesolutions.ie\/index.php\/category\/tech-stuff\/"},{"label":"Dual Personality Properties with Lambdas in .NET","link":"https:\/\/www.ridgesolutions.ie\/index.php\/2009\/02\/26\/dual-personality-property-with-lambdas-in-net\/"}],"_links":{"self":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":0,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ridgesolutions.ie\/index.php\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}