Dan Rigsby - Coding Up Style

Developer.Speaker.Blogger

New Screencast: Working with Property Grids

Posted by Dan Rigsby on June 29th, 2009

screencast1thumbthumb-thumb1 I have a new 8 min 7 sec training webcast up over working with the PropertyGrid control in Windows Forms applications.

The video is available through JupiterMedia and can be viewed at http://www.internet.com/video/. Just look for the "Developer Video" titled "Working with Property Grids".

Direct links are:
http://www.internet.com/video/?bcpid=1534611832&bclid=1433966034&bctid=27475045001

DotNetKicks Image

Posted in Webcast | No Comments »

Oslo May 2009 CTP: Intellipad Changes

Posted by Dan Rigsby on May 27th, 2009

oslo_thumb3The May 2009 CTP of “Oslo” introduces a lot of new features and enhancements to the existing toolset.  As a developer, my primary “Oslo” tool has been Intellipad.  It does seem much faster and more stable after a little over an hour of use.  Previous CTPs were memory hogs and would occasionally crash.  I will be upgrading all of my demos and work projects over to the latest CTP over the next week, so I will get to see how much more stable it really is.  Here is an overview of some of the UI Change:

Shell

For the most part we have the same familiar interface.  You have the same basic layout shell which is a mixture of a standard application frame and menu bar in one.  Everything else in Intellipad is a workspace window which can be docked any number of ways inside this shell.  The shell itself has a couple of new features:

  1. A new icon  (same icon used by Quadrant)
  2. The build number is now displayed next to the control box
  3. Menu items now appear to use much less white space, display proper “…” labels on items that open new windows, and a few other UI adjustments

image_thumb11

Workspace Window

Each workspace window has its own title bar as always.  The title bar appears to be the same.  We still have the document name, zoom level, a drop down to change “Modes” and a close button.  However, now the the active workspace window is highlighted in “Oslo Green”.  This is a minor change, but really comes in hand when working with multiple documents.

The “Edit” menu item for windows has a number of new features.  Check out the list of commands:

image_thumb14

We have our standard Undo/Redo/Cut/Copy/Paste/Delete/Find/Replace/GotoLine options which we had before, but now we have:

  1. Disable External Changes:Behaviors
    1. Selection Highlight: This is really neat! With this option as you select text in the document, it will be highlighted in “Oslo Green” and other uses of that same text in the same document will also be highlighted in blue.
    2. Error Squiggles: Whether or not to show the red squiggle under errors.  if you turn this off, you will still see errors in the error window, but you will have no visual indicator on the document, nor will you have the error tooltips
    3. Column Indicator:
    4. Link Navigation:
    5. Work Wrap: Wraps the text at the end of the line
    6. Line Numbers: Provides line numbers to the left of the document

This screenshot shows the “error squiggle” and “selection highlighting” in action:
image_thumb16 

There is new a View menu item which generously gives us support for quickly launching the three most important developer windows: Minibuffer, Errors, and Notifications.
image_thumb26

There is also a new Help menu item for displaying an “Intellipad Primer” document in Rich Text mode:
image_thumb25

Mini-Buffer

The mini buffer has change dramatically.  It use to pop up a kind of modal WPF dialog which allowed you to enter in commands.  This would occasionally cause Intellipad to crash on me.  In May CTP, it is now a standard document window where you can enter in commands and see previous commands much like if it were a command line window.

image_thumb18

Some people may dislike this little change, but personally I like this change as it is more consistent with the rest of the UI and user friendly.

DSL Authoring Mode

The “DSL Authoring Mode” is a 3-Windows view inside of Intellipad which contains:

  1. The document containing the DSL
  2. The input: some document were you could enter in data to test against the DSL
  3. The output: The AST tree that was generated from the input via the DSL

This mode is the preferred way to write a DSL as you can see how changes affect the schema in real time.

In previous CTPs you had to launch a Intellipad with special command line options to be able to work in what was known as “DSL Authoring Mode”.  This usually meant selecting “Intellipad (Samples Enabled)” from the start menu instead of just “Intellipad”.  This was annoying at best.  In the May CTP however, you can now enter “DSL Authoring Mode” from the standard launch of Intellipad.  Just open a document in “DSL Grammar Mode”, and there is a new DSL menu item called “Split New Input and Output Views” which launches the 3-Window view.

image_thumb21

image_thumb22

DotNetKicks Image

Posted in Oslo | No Comments »

Oslo May 2009 CTP: Released

Posted by Dan Rigsby on May 27th, 2009

oslo It’s been many long months since the last drop of Oslo (January 2009).  Last night, Chris Sells and others announced the May 2009 CTP of Oslo (version 0.4.2).  Each new CTP brings more features, more documentation, and more stability.  The May CTP holds true with many new features including:

  1. The first public release of Quadrant
  2. Major updates to Intellipad (including a built in authoring mode)
  3. A unified tool set for all “M” languages
  4. A new installer (themed like Intellipad and Quadrant)
  5. UML Domain support (Use Case, Activity, Class, Sequence, Component diagrams, etc) and a loader to import UML diagrams in XMI format into the repository
  6. CLR Domain support and a loader to import .NET assemblies into the repository

I was told that we would have support for most of the command line tools in Intellipad for this release such as being able to compile and deploy to the repository. However, after having played with Intellipad for 30 minutes this morning, I can’t find any of these commands.  They should be some simple customizations via python scripts and modifying some xml files.  Hopefully the team will release these additions as well.

Download the CTP here: http://www.microsoft.com/downloads/details.aspx?FamilyID=827122a5-3ca0-4389-a79e-87af37cbf60d&displaylang=en

Install Experience

The install experience has been greatly improved. (Be sure to install any previous versions first) Here are some screenshots:

image image image
image image image

image

   
DotNetKicks Image

Posted in Oslo | No Comments »

Visual Studio 2010: Extension Manager

Posted by Dan Rigsby on May 21st, 2009

Since PDC 2008 we have been hearing about the Managed Extensibility Framework (MEF) support in Visual Studio 2010.  Now that the Beta has been released, we can start to see how it is coming together.  To access the MEF extensions, just open the Extension Manager from the menu bar: Tools –> Extension Manager.

5-21-2009 1-15-49 PM

It appears that we will have a host of categories for different types extensions.  You can choose from “Installed Extensions” or browse the “Online Gallery”. The major categories are:

  1. Controls
    1. ASP.Net Controls
    2. Framework & Libraries
    3. Sharepoint Controls
    4. Silverlight Controls
    5. Windows Forms Controls
    6. WPF Controls
  2. Templates
    1. Windows Forms
    2. WPF
  3. Tools
    1. Build
    2. Coding
    3. Data
    4. Documentation
    5. Modeling
    6. Other
    7. Performance
    8. Programming & Languages
    9. Reporting
    10. Setup & Deployment
    11. Source Control
    12. Team Development
    13. Testing
    14. Web

Currently there are only 12 extensions available, and none appear to be new UI controls. Some of them are pretty interesting, but I am excited about what this could lead to. You seem to be able to extend quite a few areas of Visual Studio now!

Some of the more interesting existing extensions are:

Intellisense Presenter
A new way to view your intellisense in a WPF fashion.
image
RegEx Editor
Regular expression syntax highlighting, intellisense, in place testing, and more right from your code.
image
Image Insertion
This allows you to insert images into code files.  Great for adding developer documentation, but not sure what else it would be useful for.
image

 

I haven’t been able to find the WPF xml document visualizer that they showed off at PDC 2008. Hopefully this will show up in the gallery soon along with other useful nuggets.

I wonder if this will turn into a platform for pushing out new controls to use in our applications in between releases.  It was disappointing to not find any new controls in the toolbox when working with WinForms or WPF.  It is also unclear about how a developer can submit new extensions that be browsed through the gallery.

DotNetKicks Image

Posted in Visual Studio | 1 Comment »

Entity Framework 4.0: Scalar and Void Functions

Posted by Dan Rigsby on May 20th, 2009

One feature that was sorely missing in the first version of Entity Framework was the automated ability to work with stored procedures that didn’t return back entities.  This could have been sprocs that returned void, a scalar value, or some other custom construct. 

Entity Framework v1

In Entity Framework v1 you could create a “Function Import” from these stored procedures types, but there would be no generated code that would give you access to them directly in the ObjectContext object.  You could only access them via pure Entity SQL.

To add a “Function Import” you would just add the sproc to your entity model as your normally would, then right-click on the “Function Imports” in the “Model Browser”, and select “Add Function Import…”.  This would bring up the following screen which would allow you to add your function.

5-20-2009 10-32-34 AM

If you selected that the function returned an Entity, then you would be able to access that entity in the ObjectContext. However, if you selected scalar or void, then you would have to manually write some kind of Entity SQL.  It would be nice if these “Function Imports” appeared as operations in the ObjectContext as well.

Entity Framework 4.0 Solution

Microsoft finally completed the story for “Function Imports” in Entity Framework 4.0. As you can see in the image below, the “Add Function Import” dialog is virtually the same except for the new option to return a complex type.

5-20-2009 5-42-25 PM

You can select the None and Scalar return types as you could before.  However, when the “Function Import” is created, some new code is injected into the Model code behind file that materializes the stored procedure into an operation on the ObjectContext itself:

public ObjectResult<Nullable<global::System.Int32>> GetProductCountByCategoryId(

    Nullable<global::System.Int32> categoryID)

{

 

    ObjectParameter categoryIDParameter;

    if (categoryID.HasValue)

    {

        categoryIDParameter = new ObjectParameter("CategoryID", categoryID);

    }

    else

    {

        categoryIDParameter = new ObjectParameter(

            "CategoryID", 

            typeof(global::System.Int32));

    }

    return base.ExecuteFunction<Nullable<global::System.Int32>>(

        "GetProductCountByCategoryId", 

        categoryIDParameter);

}

 

A couple of nice things about this are:

  1. No matter what we select as the return type, it wraps it as a Nullable type since a database value can always be null
  2. The results are wrapped in an ObjectResult which makes it consistent with all other queries.

And as we expect, we can directly access these operations in our code:

using (var context = new NorthwindEntities())

{

    ObjectResult<int?> result =

        context.GetProductCountByCategoryId(1);

    

    MessageBox.Show(

        result.FirstOrDefault().Value.ToString());

}

 

New “Execute” operations

If you look at the last line of the code generated by “Add Function Import”, you might notice is making a call to a new method called ExecuteFunction<T>.  This method isn’t marked public, but there are two new methods on ObjectContext that we can use to execute functions:

  1. int ExecuteStoreCommand

    This method seems to work like “ExecuteCommand” and returns in int representing the result

  2. T ExecuteStoreQuery<T>

    This appears to be more of a combination of “ExecuteScalar”, “ExecuteNonQuery”, and “ExecuteReader”.

These methods give us the ability to run any imported stored procedure in a variety of ways.  Most users, will want to just stick with the generated operations, but its always good to have options!

DotNetKicks Image

Posted in Entity Framework | 2 Comments »

New Screencast: Custom Sprocs in Entity Framework

Posted by Dan Rigsby on May 20th, 2009

screencast1thumb-thumb I have a new 8 min 35sec training webcast up over using custom stored procedures in Entity Framework.  This video introduces how to use custom sprocs in your Entity Framework model for inserts, updates, deletes, and custom sprocs for searching.  The video briefly talks about how to work with void and scalar sprocs, but doesn’t get far into these as this is a feature that is getting more attention in the next version of Entity Framework.

The video is available through JupiterMedia and can be viewed at http://www.internet.com/video/. Just look for the "Developer Video" titled "Custom Sprocs in Entity Framework".

Direct links are:
http://www.internet.com/player/index.php?bcpid=1534611832&bclid=1433966034&bctid=22915014001

DotNetKicks Image

Posted in Entity Framework, Webcast | No Comments »

New Webcast: ADO.Net Data Services

Posted by Dan Rigsby on May 19th, 2009

screencast1thumb-thumbI have a new 7 min 55 sec training webcast up over developing ADO.Net DataServices.  This video demonstrates how to create and consume  a simple ADO.Net Data service.

The video is available through JupiterMedia and can be viewed at http://www.internet.com/video/. Just look for the "Developer Video" titled "ADO.Net Data Services".

Direct links are:
http://www.internet.com/video/?bcpid=1534611832&bclid=1433966034&bctid=13662214001

DotNetKicks Image

Posted in Webcast | No Comments »

Entity Framework 4.0: Pluralization

Posted by Dan Rigsby on May 19th, 2009

One of the new features in Entity Framework 4.0 (EF v2) is a service call “Pluralization”.  This service is used to convert names of objects form singular and/or plural forms.  For instance, if you have a table in the database that has a plural name such as “Customers”, then Entity Framework will automatically generate both object Name and Entity Set Name to “Customers” as well.  The result is that in your code, the name will look like this:
 
Customers c = new Customers();

Ideally, it would have been nice for EF to see that the table was a plural name and set the object Name to a singular form.

Now, you may be thinking that this is pretty trivial since you can manually change the generated name, but when when you have dozens or hundreds of tables this can be tedious at best.

To use the PluralizationService when generating an Entity Framework model, you just select the option"Pluralize or singularize generated object names”:

Pluralization

Or if you are using the EDMGen.exe tool, you can opt in using the /pluralize option.

Example

In the Northwind database, all the tables have plural names. (Note: It is typically recommended to name your tables in the singular form).

 Pluralization3

When this database is generated using the PluralizationService, the names are set correctly.

Pluralization1 Pluralization2 

Manually using the PluralizationService

The PluralizationService is in the System.Data.Entity.Design.dll under the System.Data.Entity.Design.PluralizationServices namespace.

Pluralization4

It is an abstract class and hence, can’t be directly instantiated.  However, there is a static CreateService method on the class to access instances of the service for various cultures.  At this time, the only culture implemented is “en-us”.

It would have been very nice if this were implemented at a more core level of .Net since this could potentially be useful for a lot more than just for Entity Framework design.  Here are some examples using the service:

// Create an instance of the service for

// a particular culture (only 'en-us' atm)

PluralizationService ps =

    PluralizationService.CreateService(

         CultureInfo.GetCultureInfo("en-us"));

 

// Convert strings to plural or singular

string pluralName = ps.Pluralize("Goose");

string singularName = ps.Singularize("Territories");

// Note: Correctly returns Geese and Territory

 

// Check if strings are plural or singular

bool isPluralName = ps.IsPlural("Sheep");

bool isSingularName = ps.IsSingular("Sheep");

// Note: Correctly sees both of these as true

Adding your own pluralization mapping

There is an interface using by the PluralizationService called ICustomPluralizationMapping that isn’t publicly exposed.  However, since it is implemented, you can cast the service to this interface and make use of the AddWord method to add your own mapping.Pluralization5

In this example, we add a new word called “Foo” with the plural version being “Foos”:

// Create an instance of the service for

// a particular culture (only 'en-us' atm)

PluralizationService ps =

    PluralizationService.CreateService(

        CultureInfo.GetCultureInfo("en-us"));

 

// Cast to the mapping interface

ICustomPluralizationMapping mapping =

    ps as ICustomPluralizationMapping;

 

// Add a new word mapping

mapping.AddWord("Foo", "Foos");

You could then use the service to generate the metadata or use it in some other context:
EntityModelSchemaGenerator generator =

    new EntityModelSchemaGenerator(

        entityContainer,

        ps);

 

var edm = generator.GenerateMetadata(); 

DotNetKicks Image

Posted in Entity Framework | 3 Comments »

New Webcast: Developing Windows Services

Posted by Dan Rigsby on April 14th, 2009

screencast1-thumb I have a new 6 min 31 sec training webcast up over developing windows services.  This video looks at how to build widows services as well as an approach for easily developing them with “console application” support to help ease development.  It can be a pain to develop a windows service, if you have to constantly keep deploying it just to test it out.

The video is available through JupiterMedia and can be viewed at http://www.internet.com/video/. Just look for the "Developer Video" titled "Developing Windows Services".

Direct links are:
http://link.brightcove.com/services/link/bcpid1431564240/bclid1433966034/bctid10347017001

DotNetKicks Image

Posted in Webcast | No Comments »

ArcReady, MSDN Unleashed, TechNet Unleashed, and IndyNDA – What a Day!

Posted by Dan Rigsby on March 5th, 2009

Are you in the Indianapolis area?  Can spare a day or can you talk your boss into giving you an “education” day? If so, then you should check out the series of events that Microsoft is bringing to town!  Every three months ArcReady and MSDN Unleashed make an appearance in our area, and they’re now joined by TechNet Unleashed. For those who aren’t familiar with these events they are targeted towards specific audiences, but have a high level of value to anyone in the Information Technology Field.

ArcReady - Architecting for the cloud

For our next ArcReady, we will explore a topic on everyone’s mind: Cloud computing. Several industry companies have announced cloud computing services . In October 2008 at the Professional Developers Conference, Microsoft announced the next phase of our Software + Services vision: the Azure Services Platform. The Azure Services Platforms provides a wide range of internet services that can be consumed from both on premises environments or the internet.

Session 1: Cloud Services

In our first session we will explore the current state of cloud services.  We will then look at how applications should be architected for the cloud and explore a reference application deployed on Windows Azure.  We will also look at the services that can be built for on premise application, using .NET Services.  We will also address some of the concerns that enterprises have about cloud services, such as regulatory and compliance issues.

Session 2: Mesh and Live Services

In our second session we will take a slightly different look at cloud based services by exploring Live Mesh and Live Services.  Live Mesh is a data synchronization client that has a rich API to build applications on.  Live services are a collection of APIs that can be used to create rich applications for your customers.  Live Services are based on internet standard protocols and data formats.

Date: March 12,2009
Time: 9:00 – 12:00
Location: Microsoft in Indianapolis, IN
Register: http://tinyurl.com/cup63m

Community Lunch

Whether you are attending ArcReady or the Unleashed Events, we invite you to join us for lunch between 12:00 – 1:00, we will have pizza and soda (food is on a first come / first served basis).

MSDN Unleashed! – Debugging and mobile devices

Enhance your coding capabilities with new tools, tips, and inside secrets from MSDN Events. We’ll start by showing you how to take full advantage of the Visual Studio debugger. We’ll offer some great tips and tricks to help you debug faster and more efficiently, while applying fresh techniques to ramp up your problem solving abilities. Additionally, you’ll see how developing for a Windows Mobile phone leverages your current coding skills and can make it simple to build, deploy and debug cool new devices.

Session 1: Tips & Tricks for the Visual Studio 2008 Debugger

The Visual Studio debugger is a highly underutilized tool for many developers. In this session, you’ll learn how to use it like a pro, while picking up new techniques to fast-forward your problem solving and debugging abilities. We’ll show you how to use advanced breakpoints, advanced watch window / Expression evaluator tricks, modifiers, assertions on the fly, remote debugging, and more. Whether you’re writing C#, VB, WPF, ASP.NET, Windows Forms, or services, we’ll provide tips and tricks that will have you debugging faster and much more efficiently. The debugger is your primary tool for finding bugs, so join us and learn how to make the most of it.

Session 2: Developing for Windows Mobile Devices

Mobile development is growing fast, and Windows Mobile is at the forefront with over 18 million phones shipped last year and many more cutting-edge devices on the way. Visual Studio developers have tremendous opportunities in this space. Why? Developing for a Windows Mobile phone leverages your existing coding experience and takes it to new heights. In this session, we’ll look at some of the coolest new devices, you’ll learn how to set up Visual Studio with the latest SDK and device emulators, and you’ll see how to build, deploy and debug Windows Mobile applications. We’ll also explore how Internet Explorer Mobile 6 provides new AJAX capabilities that offer the richness of the desktop with pan and zoom features tuned for mobile devices.

Date: March 12, 2009
Time: 1:00 – 3:00
Location: Microsoft in Indianapolis, IN
Register: http://tinyurl.com/csvx5m

Technet Unleashed - Windows Server 2008

In this session we will look at Windows Server 2008 and the improvements that have been made to Microsoft’s premier server operating system.  Microsoft Windows Server 2008 is the most advanced Windows Server operating system yet, designed to power the next generation of networks, applications, and Web services. With Windows Server 2008 you can develop, deliver, and manage rich user experiences and applications, provide a highly secure network infrastructure, and increase technological efficiency and value within your organization.

Windows Server 2008 introduces several new capabilities including 64bit virtualization, a robust web and development platform, improvements in networking, security, high availability and disaster recovery.  In addition, there is a new “Core” installation option that reduces the operating system overhead by removing the graphical user interface thus freeing resources and lowering the potential security attack surface.  Come see demonstrations on many of the features in a technical deep dive you won’t want to miss!

Date: March 12,2009
Time: 3:00 – 5:00
Location: Microsoft in Indianapolis, IN
Register:  http://tinyurl.com/aazpcn

IndyNDA – Making your Website “Pop”

Are you tasked with keeping a plain vanilla website up to date?  Larry Clarkin is and he was looking for an excuse to update it with some “jazz”.  We will explore some things to add a little punch to your website (or at least reduce the complications in keeping it up to date).  We will explore Microformats, Webslices, jquery, Virtual Earth and ADO .NET Data Services to update a real website (not some Contoso demo).  If all goes well at the end of the night we will click the publish button.  We will also talk about the importance of knowing some web standards before you start coding!

Date: March 12,2009
Time: 6:00 – 8:00
Location: Junior Achievement Center in Indianapolis, IN
Register: No registration required

DotNetKicks Image

Posted in Community | No Comments »