• Products
  • Download
  • Purchase
  • Support
  • Company
Actipro Software company logo
Twitter Follow Actipro RSS Subscribe (RSS Feed)

The Actipro Blog

Tag Cloud

  • blog
  • docking
  • editors
  • intelliprompt
  • micro charts
  • navigation
  • propertygrid
  • ribbon
  • shared library
  • silverlight
  • syntaxeditor
  • themes
  • views
  • web site
  • winforms
  • winrt
  • wpf

Latest Twitter News

May 14, 2012 at 2:50 PM
IntelliPrompt code snippet features have been added to our VS-like code editor control for #WPF and #Silverlight. http://t.co/1IchOJrr

May 10, 2012 at 9:40 PM
Our new Micro Charts control products for #WPF and #Silverlight are out now. Come build some dashboards with them! http://t.co/EEERvff0

May 7, 2012 at 6:47 AM
Today we look at bar charts, for our upcoming #WPF, #Silverlight, and #WinRT Micro Charts product. http://t.co/gxHuPS6B

May 4, 2012 at 6:25 AM
See a gallery of micro area charts in our upcoming release for #WPF, #Silverlight, and #WinRT. http://t.co/qDXGwW8B

May 3, 2012 at 6:32 AM
See a variety of line charts that are easy to make with our upcoming #WPF, #Silverlight, #WinRT Micro Charts product. http://t.co/mbkX6tJd

Twitter Follow us on Twitter

Month List

  • 2012
    • May (9)
    • April (6)
    • March (11)
    • February (11)
    • January (2)
  • 2011
    • December (2)
    • November (7)
    • October (2)
    • September (1)
    • August (5)
    • July (3)
    • June (6)
    • May (5)
    • April (8)
    • March (4)
    • February (5)
    • January (9)
  • 2010
    • December (9)
    • November (10)
    • October (4)
    • September (8)
    • August (12)
    • July (9)
    • June (7)
    • May (6)
    • April (7)
    • March (6)
    • February (6)
    • January (4)
  • 2009
    • December (2)
    • November (2)
    • October (12)
    • September (3)
    • August (11)
    • July (10)
    • June (6)
    • May (3)
    • April (7)
    • March (6)
    • February (8)
    • January (10)
  • 2008
    • December (10)
    • November (2)
    • October (3)
    • September (5)
    • August (5)
    • July (8)
    • June (4)
    • May (4)
    • April (10)
    • March (8)
    • February (1)
    • January (2)

Category List

  • RSS feed for ActiproActipro (321)
  • RSS feed for Blog SummaryBlog Summary (15)
  • RSS feed for GeneralGeneral (43)
  • RSS feed for In developmentIn development (164)
  • RSS feed for New featuresNew features (155)
  • RSS feed for New productNew product (38)
  • RSS feed for PromotionPromotion (2)
  • RSS feed for SilverlightSilverlight (90)
  • RSS feed for Tips and tricksTips and tricks (4)
  • RSS feed for Visual Studio 2008Visual Studio 2008 (2)
  • RSS feed for Windows FormsWindows Forms (22)
  • RSS feed for Windows VistaWindows Vista (10)
  • RSS feed for WinRTWinRT (9)
  • RSS feed for WPFWPF (257)
  • RSS feed for XAMLXAML (23)

About Us

Actipro Software is a leading provider of .NET user interface controls for the WPF, Silverlight, and WinForms frameworks, and is most well-known for their SyntaxEditor syntax-highlighting code editor control.

Please take some time to learn more about us and our product offerings.

SyntaxEditor .NET Languages Add-on - Lambda Expression IntelliPrompt

June 30, 2011 at 2:20 PM
by Bill Henning (Actipro)

PostBannerSyntaxEditorDevNotes3

We’ve been adding some more updates to the SyntaxEditor .NET Languages Add-on for WPF/Silverlight in preparation for what might be the final 2011.1 maintenance release, and some of these are really exciting. 

Today I’d like to show a couple highly requested features for the add-on:  automated IntelliPrompt for lambda expressions and generic method type parameter inference.  That’s a mouthful, but it’s really helpful for advanced coders.  Let’s see some examples of how it works.

Generic Method Type Parameter Inference

Generic methods are C#/VB methods that have type parameters.  Generic methods can be invoked in one of two ways.  In the first way, you explicitly indicate the type arguments.  In the second way, you don’t indicate type arguments.  Instead, the compiler figures them out based on the parameters that are passed to the method.

Lambdas1

In the screenshot above we have defined an Echo generic method that takes a T type parameter and returns a T value.  Our sample implementation just returns the same value that is passed in.

Back on line 9, we declare a variable called echo that gets implicitly typed from the result of the Echo method invocation.  We could have explicitly called the Echo method like: Echo<int>(1).  However in the sample we chose to implicitly call it instead.  Our resolver engine knows that we passed an integer literal to the method.  It figures out that Echo’s T type argument is an int and thus an int is the return value.  Then echo gets implicitly typed as an int, which we can see when we hover over it on the next line. 

That is a simple case of how generic method type parameter inference works.  Let’s get more complex:

Lambdas2

Here we have a generic method GetFirstOrDefault which is simply executing the LINQ FirstOrDefault method on the collection and returning the result.  But look at the code above it.  We implicitly declare an integer list.  We then call our generic method, passing in the list, and the first variable is assigned the result.  Finally, we call Console.WriteLine and pass in first.

You can see this scenario is very complex and the resolver handles it perfectly.  It figures out that first is an int and shows the proper Console.WriteLine overload that takes a single int.

Lambda Expressions

Let’s check out new lambda expression features.  Lambda expressions are anonymous functions that can contain expressions and statements.  Here’s a quick sample:

Lambdas3

In the screenshot above, we’ve declared a dbl variable that is a System.Func<int, int> delegate type.  We’re going to assign a lambda expression that doubles a number to the dbl variable.  Our resolver is able to see that num is being assigned to a delegate whose single parameter is an int parameter, and thus knows that num is an int.  The completion list we see is for the int type.

Now let’s see a sample of combining all the concepts discussed above… LINQ extension methods!

Lambdas4

Here we declare a variable list that is a list of strings.  Then we call the Enumerable.Where LINQ extension method on it and pass a lambda expression predicate in.  As we hover over the i lambda expression parameter, you can see the resolver properly identified it as a string.

Lambdas5

The item variable is implicitly declared as the FirstOrDefault result of the Where method call.  Now let’s hover over Console.WriteLine and we see that it correctly picks the overload that takes a string parameter.

Summary

You can see that these new resolver features are pretty incredible and make the editing experience (especially with LINQ extension methods) so much nicer.  All of these features are the building blocks for further query expression enhancements.

The new features described above are ready to go for the next WPF and Silverlight maintenance releases.

Tags: wpf, silverlight, syntaxeditor, intelliprompt
Filed under: Actipro, New features, Silverlight, WPF
Submit to DotNetKicks...
Permalink | Comments (1)

Related posts

SyntaxEditor grammar/AST framework part 3: Creating a grammar for the Simple languageIn the previous post we gave a detailed introduction to symbols, EBNF terms, and how you can transla...SyntaxEditor .NET Languages Add-on IntelliPrompt ImprovementsWe just released build 275 of SyntaxEditor and its add-ons.  This build has a lot of minor twea...SyntaxEditor .NET Languages Add-on: Working Towards Automated IntelliPrompt We’ve been hard at work over the past several weeks on the SyntaxEditor .NET Languages Add-on, for...

Comments

July 1, 2011 at 00:22  

trackback

Actipro Blog 2011 Q2 Posting Summary

Actipro Blog 2011 Q2 Posting Summary

The Actipro Blog - WPF, Silverlight, and WinForms Development

Comments are closed
Copyright © 1999-2012 Actipro Software LLC. All rights reserved.
Home Actipro Software | Products | Download | Contact Us