Welcome to the .NET Developers Blog
This is an aggregated blog of .NET developers.
If you have a blog about Microsoft, .NET, XAML, WPF, Silverlight, etc... development
add your blog here.
Email me for any suggestions and feedback.
Minh T. Nguyen
|
|
|
The new ASP.NET website
Jon Galloway
- Posted 3/11/2010 1:24 AM
|
|
We launched a major refresh of the ASP.NET website today. It was really exciting to be a part of the update process, working with lots of very talented people including Scott Guthrie and Scott Hanselman. It’s a pretty major update, including: - New site-wide design
- Redesigned Home page and Getting Started sections which streamline the experience for those who are new to ASP.NET
- Revised and updated content areas for both ASP.NET Web Forms and MVC
- Reviewed, re-categorized, and where appropriate, archived tutorial and video content. That was a pretty major undertaking, as some of that content had been around since ASP.NET 2.0
As you’d expect, Scott Hanselman has a great overview of what’s changed site-wide, but I’d like to highlight a few areas I was most involved with – the MVC Content area and a major update to the Community Projects / Open Source page. ASP.NET/MVC changes The ASP.NET MVC section was the new kid on the block on the ASP.NET website, so the asp.net/mvc page had less of a visual change than many of the other top-level pages. A lot of the work was in streamlining and prioritizing content, so you can (hopefully) find what you want faster, and there are new video introductions like Scott’s How Best To Learn ASP.NET MVC. Here’s what it used to look like – content links on top, blog posts on the bottom, book links on the right.  In addition to cleaning up and updating the top content, we merged in the top asp.net/mvc/learn content now, and moved the blog content to the community page. This should increase the content relevance and point you towards more video / tutorial content by topic.  We some substantial changes to asp.net/mvc/learn. The previous page hit you with a wall of text and links, and the sub-pages were more of the same. It was a lot of information, but it wasn’t really categorized or prioritized in a way that helped you find what you were looking for. I reviewed literally hundreds of pages of content (video and tutorial) to categorize, pick the top content to feature on top level pages, and find outdated content that should be archived. Here’s how the asp.net/mvc/learn page used to look:  Now that we’ve got the categories links on the asp.net/mvc page, they link to specific focus areas, like this asp.net/mvc/fundamentals page:  Keeping in mind that ASP.NET MVC 2 is due out soon, you should expect more changes here. For instance, I’ve been working hard on a new tutorial project with Scott Guthrie that will be finished soon, and I’ll be publishing a series of videos and tutorial articles covering that. The new Open Source / Community Projects Page Honestly, I’m most excited about one page in the site: the Open Source ASP.NET projects page. I got to run with this one, gathering input from a lot of open sourcey folks at Microsoft, compiling tons of links and project descriptions, and working with project owners when they didn’t have a published “Twitter pitch” description of their site published. This page is not beautiful – it’s a long list of links and text. We’ve got some future changes to the site that will help us with the presentation, but as it is now, I’ll admit that it’s not a beautiful webpage. And yet, it’s a thing of beauty. It made my day to see this kind of thing on Twitter: “Wow, an official Microsoft website listing open source tools for .NET. Didn’t think I’d see the day.” There’s a great open source community around ASP.NET open source, and it’s great to get the word out. This kind of thing is what the ASP.NET community is all about. Yes, this kind of effort is fraught with peril. There are tons of .NET open source projects out there, how do we manage the list, adding relevant projects and keeping them updated as they change names every week (oh, you silly open source folk, you)? I’m still figuring that out. I was warned this would be a challenge, and I accept it wholeheartedly, because it’s important. The alternative – not doing the page because it’s hard – is much worse. Let me know if I missed any that you think are important. I can’t add every project to the list, or it’ll grow large and useless, but I do want to make sure we capture a good sample. Note: I put a lot of work into this page, but it wouldn’t have been part of this release without Terri Morton’s help. She really saw the value in it and helped push it through when it really could have slipped from this release – thanks, Terri! Awesome? Awesomer. Is the site perfect? No, it’s not. But I hope you’ll agree that it’s a lot better. We’ve got a lot more planned for this year, and this is the first step. 
|
Naming PowerPoint Components With A VSTO Add-In
Tim Murphy
- Posted 3/10/2010 10:10 PM
|
|
Note: Cross posted from Coding The Document.
Permalink
Sometimes in order to work with Open XML we need a little help from other tools. In this post I am going to describe a fairly simple solution for marking up PowerPoint presentations so that they can be used as templates and processed using the Open XML SDK.
Add-ins are tools which it can be hard to find information on. I am going to up the obscurity by adding a Ribbon button. For my example I am using Visual Studio 2008 and creating a PowerPoint 2007 Add-in project. To that add a Ribbon Visual Designer. The new ribbon by default will show up on the Add-in tab.
Add a button to the ribbon. Also add a WinForm to collect a new name for the object selected. Make sure to set the OK button’s DialogResult to OK. In the ribbon button click event add the following code.
ObjectNameForm dialog = new ObjectNameForm();
Selection selection = Globals.ThisAddIn.Application.ActiveWindow.Selection;
dialog.objectName = selection.ShapeRange.Name;
if (dialog.ShowDialog() == DialogResult.OK)
{
selection.ShapeRange.Name = dialog.objectName;
}
This code will first read the current Name attribute of the Shape object. If the user clicks OK on the dialog it save the string value back to the same place.
Once it is done you can retrieve identify the control through Open XML via the NonVisualDisplayProperties objects. The only problem is that this object is a child of several different classes. This means that there isn’t just one way to retrieve the value. Below are a couple of pieces of code to identify the container that you have named.
The first example is if you are naming placeholders in a layout slide.
foreach(var slideMasterPart in slideMasterParts)
{
var layoutParts = slideMasterPart.SlideLayoutParts;
foreach(SlideLayoutPart slideLayoutPart in layoutParts)
{
foreach (assmPresentation.Shape shape in slideLayoutPart.SlideLayout.CommonSlideData.ShapeTree.Descendants<assmPresentation.Shape>())
{
var slideMasterProperties =
from p in shape.Descendants<assmPresentation.NonVisualDrawingProperties>()
where p.Name == TokenText.Text
select p;
if (slideMasterProperties.Count() > 0)
tokenFound = true;
}
}
}
The second example allows you to find charts that you have named with the add-in.
foreach(var slidePart in slideParts)
{
foreach(assmPresentation.Shape slideShape in slidePart.Slide.CommonSlideData.ShapeTree.Descendants<assmPresentation.Shape>())
{
var slideProperties = from g in slidePart.Slide.Descendants<GraphicFrame>()
where g.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.Name == TokenText.Text
select g;
if(slideProperties.Count() > 0)
{
tokenFound = true;
}
}
}
Together the combination of Open XML and VSTO add-ins make a powerful combination in creating a process for maintaining a template and generating documents from the template. 
|
Capture a memory dump using Adplus 'hang' dump.
Steve Schofield
- Posted 3/10/2010 9:11 PM
|
|
Here is the syntax to capture a memory dump using adplus (part of the debugging tools). FYI if you need to capture a ultra large w3wp process, you will need to increase the ping timeout inside IIS so the dump doesn't fail. IIS will detect a ping failure, and recycle before the memory dump has finished writing to disk. I've used this since IIS DebugDiag doesn't work on 64 bit of windows server 2008.
|
PowerShell 2.0 – Partial Application of Functions and Cmdlets
Oisin Grehan
- Posted 3/10/2010 6:36 PM
|
|
This is unashamedly a post for developers, in particular those with an interest in
functional languages. With the advent of PowerShell 2.0, some of you may have noticed
that ScriptBlocks - which I suppose could also be called anonymous functions or lambdas
- gained a new method: GetNewClosure.
Closures are one of the essential tools for functional programming., something I’ve
been trying to learn more about over the last few years. I don’t really have an opportunity
to use it in work other than the hybrid trickery available in C# 3.0, but I have been
tinkering a lot with PowerShell 2.0 to see if some of the tricks of the functional
trade could be implemented. It’s just a shell language, but there are some nice features
in there that enable a wide variety of funky stuff.
Partial Application
In a nutshell, partial application of a function is when you pass in only some of
the parameters and get a function back that can accept the remaining parameters:
# define a simple function
function test {
param($a, $b, $c);
"a: $a; b: $b; c:$c"
}
# partially apply with -c parameter
$f = merge-parameter (gcm test) -c 5
# partially apply with -c and -a then execute with -b (papp is an alias)
& (papp (papp (gcm test) -c 3) -a 2) -b 7
# partially apply the get-command cmdlet with -commandtype
# and assign the result to a new function
si function:get-function (papp (gcm get-command) -commandtype function)
This is by no means a complete implementation of a partial application framework for
powershell. The merge-parameter function (aliased to papp) currently only works with
the default parameterset and does not mirror any of the parameteric attributes in
the applied function or cmdlet. I'm not saying it couldn't do that, but this is purely
a proof of concept. The module is listed below and is also available from PoshCode
at http://poshcode.org/1687
# save as functional.psm1 and drop into your module path
Set-StrictMode -Version 2
$commonParameters = @("Verbose",
"Debug",
"ErrorAction",
"WarningAction",
"ErrorVariable",
"WarningVariable",
"OutVariable",
"OutBuffer")
<#
.SYNOPSIS
Support function for partially-applied cmdlets and functions.
#>
function Get-ParameterDictionary {
[outputtype([Management.Automation.RuntimeDefinedParameterDictionary])]
[cmdletbinding()]
param(
[validatenotnull()]
[management.automation.commandinfo]$CommandInfo,
[validatenotnull()]
[management.automation.pscmdlet]$PSCmdletContext = $PSCmdlet
)
# dictionary to hold dynamic parameters
$rdpd = new-object Management.Automation.RuntimeDefinedParameterDictionary
try {
# grab parameters from function
if ($CommandInfo.parametersets.count > 1) {
$parameters = $CommandInfo.ParameterSets[[string]$CommandInfo.DefaultParameterSet].parameters
} else {
$parameters = $CommandInfo.parameters.getenumerator() | % {$CommandInfo.parameters[$_.key]}
}
$parameters | % {
write-verbose "testing $($_.name)"
# skip common parameters
if ($commonParameters -like $_.Name) {
write-verbose "skipping common parameter $($_.name)"
} else {
$rdp = new-object management.automation.runtimedefinedparameter
$rdp.Name = $_.Name
$rdp.ParameterType = $_.ParameterType
# tag new parameters to match this function's parameterset
$pa = new-object system.management.automation.parameterattribute
$pa.ParameterSetName = $PSCmdletContext.ParameterSetName
$rdp.Attributes.Add($pa)
$rdpd.add($_.Name, $rdp)
}
}
} catch {
Write-Warning "Error getting parameter dictionary: $_"
}
# return
$rdpd
}
<#
.SYNOPSIS
Function that accepts a FunctionInfo or CmdletInfo reference and one or more parameters
and returns a FunctionInfo bound to those parameter(s) and their value(s.)
.DESCRIPTION
Function that accepts a FunctionInfo or CmdletInfo reference and one or more parameters
and returns a FunctionInfo bound to those parameter(s) and their value(s.)
Any parameters "merged" into the function are removed from the available parameters for
future invocations. Multiple chained merge-parameter calls are permitted.
.EXAMPLE
First, we define a simple function:
function test {
param($a, $b, $c, $d);
"a: $a; b: $b; c:$c; d:$d"
}
Now we merge -b parameter into functioninfo with the static value of 5, returning a new
functioninfo:
ps> $x = merge-parameter (gcm test) -b 5
We execute the new functioninfo with the & (call) operator, passing in the remaining
arguments:
ps> & $x -a 2 -c 4 -d 9
a: 2; b: 5; c: 4; d: 9
Now we merge two new parameters in, -c with the value 3 and -d with 5:
ps> $y = merge-parameter $x -c 3 -d 5
Again we call $y with the remaining named parameter -a:
ps> & $y -a 2
a: 2; b: 5; c: 3; d: 5
.EXAMPLE
Cmdlets can also be subject to partial application. In this case we create a new
function with the returned functioninfo:
ps> si function:get-function (merge-parameter (gcm get-command) -commandtype function)
ps> get-function
.PARAMETER _CommandInfo The FunctionInfo or CmdletInfo into which to merge (apply)
parameter(s.) The parameter is named with a leading underscore character to prevent
parameter collisions when exposing the targetted command's parameters and dynamic
parameters. .INPUTS FunctionInfo or CmdletInfo .OUTPUTS FunctionInfo #> function
Merge-Parameter { [OutputType([Management.Automation.FunctionInfo])] [CmdletBinding()]
param( [parameter(position=0, mandatory=$true)] [validatenotnull()] [validatescript({
($_ -is [management.automation.functioninfo]) -or ` ($_ -is [management.automation.cmdletinfo])
})] [management.automation.commandinfo]$_Command ) dynamicparam { # strict mode compatible
check for parameter if ((test-path variable:_command)) { # attach input functioninfo's
parameters to self Get-ParameterDictionary $_Command $PSCmdlet } } begin { write-verbose
"merge-parameter: begin" # copy our bound parameters, except common ones $mergedParameters
= new-object 'collections.generic.dictionary[string,object]' $PSBoundParameters #
remove our parameters, leaving only target function/CommandInfo's args to curry in
$mergedParameters.remove("_Command") > $null # remove common parameters $commonParameters
| % { if ($mergedParameters.ContainsKey($_)) { $mergedParameters.Remove($_) > $null
} } } process { write-verbose "merge-parameter: process" # temporary function name
$temp = [guid]::NewGuid() $target = $_Command # splat our fixed named parameter(s)
and then splat remaining args $partial = { [cmdletbinding()] param() # begin dynamicparam
dynamicparam { $targetRdpd = Get-ParameterDictionary $target $PSCmdlet # remove fixed
parameters $mergedParameters.keys | % { $targetRdpd.remove($_) > $null } $targetRdpd
} begin { write-verbose "i have $($mergedParameters.count) fixed parameter(s)." write-verbose
"i have $($targetrdpd.count) remaining parameter(s)" } # end dynamicparam process
{ $boundParameters = $PSCmdlet.MyInvocation.BoundParameters # remove common parameters
(verbose, whatif etc) $commonParameters | % { if ($boundParameters.ContainsKey($_))
{ $boundParameters.Remove($_) > $null } } # invoke command with fixed parameters
and passed parameters (all named) . $target @mergedParameters @boundParameters if
($args) { write-warning "received $($args.count) arg(s) not part of function." } }
} # emit function/CommandInfo new-item -Path function:$temp -Value $partial.GetNewClosure()
} end { # cleanup rm function:$temp } } new-alias papp Merge-Parameter -force Export-ModuleMember
-Alias papp -Function Merge-Parameter, Get-ParameterDictionary
Have fun[ctional]!
|
Eindrücke vom dotnetpro powerday zum Thema CCD
Martin Hey
- Posted 3/10/2010 12:48 PM
|
Ein professioneller Softwareentwickler - was kennzeichnet ihn eigentlich? Mit dieser Frage starten Ralf Westphal und Stefan Lieser, wenn sie erklären, worum es bei der Clean-Code-Developer-Initiative eigentlich geht. Und genau so beginnt auch die Keynote des dotnetpro powerdays zum Thema CCD, der am 09.03.2010 in München. Die Antworten aus dem Publikum sind sehr vielseitig: "Man hat Erfahrung.", "Man schreibt wiederverwendbaren Code", "Jemand ist bereit, einem Geld für die Leistung zu geben", "Man schreibt Code, den andere verstehen" hört man Wortmeldungen aus allen Richtungen. Aber sind das wirklich die Kriterien? "Wiederverwendbarkeit? - Ich möchte keinen Klempner, der Dinge wieder verwendet, weil das professionell ist", meint Ralf und macht damit klar: Nicht das sind die Kriterien für Professionalität, sondern eine Mischung aus Bewusstheit und Prinzipien. Mit viel Witz und mehren verschenkten Mausmatten als Belohnung für interessante Antworten führen die beiden durch die Keynote und bringen so jedem das Thema näher.
Klar ist, die beiden wissen was sie rüberbringen wollen und vertreten da auch ihre Meinung recht konsequent. Selbst langjährige und erfahrene Entwickler betrachten Probleme mal aus einem anderen Blickwinkel, wenn Aussagen wie "Wozu brauche ich einen Debugger – meine Tests zeigen mir doch, wo der Fehler ist", "Zum Erstellen einer Softwarearchitektur braucht man keine Tools – nur ein Flipchart" im Raum stehen - und wenn uns jemand nach einer Software-Architektur für ein Warenwirtschaftssystem gefragt hat, haben wir dann nicht alle mit einem einzigen "großen Kreis mit Bubbel in der Mitte" auf dem Flipchartpapier geantwortet? "Wie vermeide ich Abhängigkeiten?", war die Frage, die einen Abstecher in Richtung Event Based Programming mit den Hauptakteuren "Paula Portal", "Anton Adapter", "Frieda Filter" und "Zacharias Zähler" bescherte, die gemeinsam die Codezeilen einer Datei zählten, während "König Kunde" sich einen neuen Kaffee holte.
Der Nachmittag bestand dan darin, eine "Brownfield-Anwendung" mit Gummistiefeln zu betreten und im Sinne von CCD sauber zu machen. Leider musste ich nach der Ermittlung der guten und schlechten Eigenschaften der Anwendung die Veranstaltung verlassen, weil sonst mein Flieger ohne mich gestartet wäre, aber ich denke das anschließende Refactoring der Anwendung war auch noch sehr interessant.
Ja, ich mag die Art von Stefan und Ralf, wie sie solche Veranstaltungen durchführen - mal ganz unabhängig davon, ob es eine kostenpflichtige Veranstaltung wie der CCD-Powerday oder eine kostenfreie wie Usergroup-Treffen oder OpenSpaces sind. Durch diese Art wird man abseits vom täglichen Geschäft mal dazu animiert, neue Wege einzuschlagen oder anders an ein Thema heranzugehen. Und unabhängig davon, ob man CCD unterstützt oder nicht - die Notwendigkeit professionell zu arbeiten gibt es durchaus und die sollte auch immer im Hinterkopf sein. Und die Initative hin zur Professionalität unterstütze ich aus vollster Überzeugung.
|
MongoDB provider for Blogengine.net, saving a Post – Part 2
Hernan Garcia
- Posted 3/10/2010 12:31 PM
|
|
Yesterday we created our first method in the MongoDbProvider, our implementation of
BlogProvider. We created a few supporting classes, but we don’t have test for those
classes. We recognize that we went a little bit too far in our coding. We got carry
away and we started to implement a little bit more than needed to make the test pass.
So let’s fix that. First we need to see our first test passing. We run it expecting
to fail to save and load the post but we have a different Exception thrown.
If we look at the code we notice that we made a big mistake in the Mongo class. We
declared a _server private field but we are initializing a local server variable.
So when calling Disconnect on _server inside the Dispose method we get the NullReferenceException.
Let’s write a test to reproduce that bug at the unit level and see what else we can
fix in that class.
Looking at it we discover a few dependencies that can be brake. First we create an
IMongoMapperFactory interface and we make MongoMapperFactory to implement it.
There is another dependency, the name of the database to use. We made both parameters
for the constructor inverting
the dependencies.
1: public MongoDb(IMongoMapperFactory
mongoMapperFactory, string dbName)
2: {
3: _mongoMapperFactory = mongoMapperFactory;
4: _dbName = dbName;
5: }
We also changed the Insert method:
1: publicvoid Insert<TEntity>(TEntity
entity)
2: {
3: var document = _mongoMapperFactory.GetMapper<TEntity>().Map(entity);
4: Db(db=> db.GetCollection(entity.GetType().Name+"Docs").Insert(document));
5: }
Notice that the private Db method now takes an Action<Database>
1: privatevoid Db(Action<Database>
action)
2: {
3: using (var
server = getServer())
4: {
5: var db = server.getDB(_dbName);
6: action.Invoke(db);
7: }
8: }
9:
10: private Mongo
getServer()
11: {
12: var server = new Mongo();
13: server.Connect();
14: return server;
15: }
And the newly created getServer() helper method to clean up the code. We also made
some changes on the query method but I will leave that for the next post.
Our passing test result indicates some success.
Next: Mapping from Document to Entity and back.


|
Extending WikiPlex with Scope Augmenters
Matt Hawley
- Posted 3/10/2010 11:07 AM
|
|
[In addition to blogging, I am also using Twitter. Follow me: @matthawley] Another extension point with WikiPlex is Scope Augmenters. Scope Augmenters allow you to post process the collection of scopes to further augment, or insert/remove, new scopes prior to being rendered. WikiPlex comes with 3 out-of-the-box Scope Augmenters that it uses for indentation, tables, and lists. For reference, I'll be explaining… (read more)
|
Mythbusters - Windows Update Will Explode Your PC
Damir Tomicic
- Posted 3/10/2010 9:03 AM
|
|
Kay (for Windows™) Giza versuchte in seinem Blog-Beitrag [1] zu klären was
an den urbanen Mythen rund um Windows (& Co.) Update wahr und was Fiktion ist.
Ganz ohne Spezialeffekte, dafür mit viel Herz und Sachkenntnis. Wer seine aktuelle
Rolle bei Microsoft zur Beurteilung seiner Kompetenz zum Thema nimmt, sollte eines
nicht außer Acht lassen - Kay (for Windows™) Giza war bereits vor seinem
Eintritt bei Microsoft ein Windows MVP und ein ausgewiesener Systemexperte. In jedem
Fall eine sehr nette Zusammenfassung zum Thema.
[1] http://www.giza-blog.de/MythosEntzaubertMicrosoftUpdateWindowsUpdateOfficeUpdate.aspx
Die zahlreichen Reaktionen und Kommentare bestätigen offensichtlich die Wichtigkeit
des Themenschwerpunkts. Mich persönlich bewegt es nicht sonderlich emotional. In unserem
Unternehmen sind diese Tätigkeiten weitestgehend automatisiert, durch unser internationales
Admin-Team eingerichtet und erfolgen auch im Hintergrund. Ab und zu muß ich etwas
länger beim Herunterfahren warten, bis die letzten Updates nun auch installiert sind,
von einer Arbeitsbeeinträchtigung ist unter Windows 7 keine Rede.
|
More Analytics, Analysis, and Correlation
Adron Hall
- Posted 3/10/2010 7:26 AM
|
|
I was listening away to some ear blistering metal, as I often do, and an ad really jumped out at me.  If you can?t see what is written in the HTC ad to the right, click on the image. What is displayed is a cross-correlation of several points of analytics data. Before I jump right in and start explaining each point, think about what is going on with this ad. This is by no means just some simple ad, there are a number of things going on here. First data point. Sprint & HTC, or whoever it is that put this ad together, has retrieved my listening favorites from Pandora. Just looking at the bands listed shows that to be self evident. This also seems to be the most obvious piece of data they could have collected about me, since I am logged into Pandora. This is probably achieved by some web services or other API that Pandora provides advertisers. The second data point is not immediately noticeable. I am still at a loss to explain where they retrieved this data point. What is it? Concert dates for bands. Each of the bands listed in the HTC app that is displayed is a coming show. Matter of fact, it almost seemed like they had shown me my own HTC, except I don't own one. :) Now my location data, I am suspecting probably came from Pandora too, but it is the third point regardless. All together the ad utilizes geo-positional location, my Pandora music preferences, and pulls local concerts from another source (maybe a Pandora listing too?). This is a perfect use of preferences to display things that are truly relevant to me. In addition, they may have just helped to sell me on a new phone for my personal line. I am up for a replacement and anything that runs Google Droid seems cool, but I?ll admit, with the sneak peaks at Windows 7 Mobile that I've seen and the proposed ability to use Silverlight ? I WILL BE switching from the iPhone when that is released.
|
Creating a Lazy Sequence of Directory Descendants in F#
Oliver Sturm
- Posted 3/10/2010 3:53 AM
|
|
It seems to turn into a shoot-out: listing directories is suddenly en-vogue! :-)
So, Craig Andera posted this code in written in Clojure, which lists some directories lazily, and Chris Sells thought he could do that in C#, too.
I thought these code examples all look rather verbose – in the case of Clojure because in that way rather typical for Java, the APIs are pretty verbose to use, and in the case of C# because of all the syntactic, well, ahem, necessities, as well as the fact that there’s no language feature for integrating nested sequences seamlessly.
Keeping it nice and simple, in F# that example can look like this:
open System.IO
let rec GetDirectoryDescendants(path) =
seq {
yield! Directory.GetFiles(path)
for subdir in Directory.GetDirectories(path) do
yield! GetDirectoryDescendants(subdir)
}
For one thing, this code only contains what’s needed, like the Clojure code does – no namespaces, class declarations, loads of curlies, …. nice. Second, the “yield!” statement. There’s also “yield", without the “!", in F#, and the difference is that while yield returns a single element for inclusion in the sequence, yield! takes an entire sequence and returns it one by one into the “upper level” sequence.
You could argue that’s the same thing the C# code does as well, and you would be right, in a way. But the F# way is much shorter, more concise, and the code doesn’t break down again to the level of the sequence element. Functional languages like these things – by using map instead of a for(each) loop, you have a well-known pattern to apply, and the reader of your code has to read less to see what exactly is going on. In the same way, by using yield! it is obvious what I’m doing without finding the code inside the foreach loop and confirming that all it does is, again, yield.
|
Flattening a Jagged Array with LINQ
Patrick Steele
- Posted 3/9/2010 7:27 PM
|
|
Today I had to flatten a jagged array. In my case, it was a string[][] and I needed to make sure every single string contained in that jagged array was set to something (non-null and non-empty). LINQ made the flattening very easy. In fact, I ended up making a generic version that I could use to flatten any type of jagged array (assuming it's a T[][]): private static IEnumerable<T> Flatten<T>(IEnumerable<T[]> data)
{
return from r in data from c in r select c;
}
Then, checking to make sure the data was valid, was easy:
var flattened = Flatten(data);
bool isValid = !flattened.Any(s => String.IsNullOrEmpty(s));
You could even use method grouping and reduce the validation to:
bool isValid = !flattened.Any(String.IsNullOrEmpty);

|
USA Driving Tour, Day 2ish: Shopping, Frys and Mystere
Mitch Denny
- Posted 3/9/2010 4:13 PM
|
I traded up my crutches for a wheelchair today as our credit card came under heavy fire taking advantage of the strong Australian dollar and getting down to some serious shopping. My strong suspicion is that the only reason Shelley suggested the wheelchair was so that she would have someone to pile the boxes of [...]
|
TQuery and RequestLive in Delphi 7:
Senthil Kumar B
- Posted 3/9/2010 10:48 AM
|
|
TQuery component in Delphi enables your applications to use SQL syntax to access data from the database like paradox,Oracle etc.
We perform the following steps to use the TQuery component .
1. Create the TQuery Component.This can be done either by dropping the component on top the designer or during the runtime
Eg :
var
Query1 : TQuery;
Query1 := TQuery1.Create(nil);
2. More >
|
EntitySpaces 2010 Better Handling of Schemas
Mike Griffin
- Posted 3/8/2010 6:59 PM
|
We hope to announce a release date for EntitySpaces 2010 very soon.
We now handle schema and better and allow you to have the same table or view name
in multiple schemas. You can see the Address table selected twice
(in different schemas) in the Custom Template to the right. They will both create
an Address.cs file so you would need to generate each schema into a different folder,
but it’s great that this all works now.
We working our way through the wish list and we have switched to the Tarma Installer
which we really like.
From Mobile Devices to large scale enterprise solutions in need of
serious transaction support, EntitySpaces can meet your needs. Whether you’re writing
an ASP.NET application with Medium Trust requirements, a Silverlight/WCF application,
a Mono application, or a Windows.Forms application,
the EntitySpaces architecture is there for you. EntitySpaces is provider independent,
which means that you can run the same binary code against any of the supported databases.
EntitySpaces is available in both C# and VB.NET. EntitySpaces uses no reflection,
no XML files, and sports a tiny foot print of less than 200k. Pound for pound, EntitySpaces
is one tough, dependable .NET architecture.
EntitySpaces LLC
Persistence Layer and Business Objects for Microsoft .NET
http://www.entityspaces.net
|
When SharePoint Matters: OneResponse
Jan Tielens
- Posted 3/8/2010 2:21 PM
|
|
Two weeks ago I was in Iceland, talking about SharePoint 2010 at TM Software (some photos here :-) ). During the course, some students showed me a pretty cool public SharePoint 2007 site that they have been working on: OneResponse (http://oneresponse.info). OneResponse is the site the United Nations uses to collaborate and share information during catastrophes such as the recent earthquake in Haiti. Besides of the fact that the site is implemented really well, it must be pretty cool to know that your work will have such a big impact. Well done guys, it was a pleasure to be your guest!
|
NET Framework 3.5 & NET Framework 4.0
Anand Patel
- Posted 3/7/2010 10:28 PM
|
The .NET Framework is an integral Windows component that supports building and running the next generation of applications and XML Web services. The .NET Framework is hearty of development now & tomorrow for business applications.
Our dot.net consultant hides technical complexity & ensures deliver of better application. Radix has started development on net framework 4.0 to influence best technology for client projects.
Explore technical verticals of Radix consulting & development services from following sections.
|
Generating JUnit XML output files from FitNesse
gojko
- Posted 3/7/2010 8:37 PM
|
|
I just pushed a small change to JUnit integration support for FitNesse to github; hopefully this should be merged with Uncle Bob’s master branch soon. The change enables you to output test run stats in Junit XML files, which can then be picked up by Hudson, TeamCity and other CI servers and integrated into their [...]
|
Goodbye Http Handler, Hello FileResult
Michael Ceranski
- Posted 3/7/2010 4:46 PM
|
|
If you have been developing applications in ASP.NET MVC then you are probably familiar with the ActionResult class. The ActionResult is the most common type of object returned from an action. When building MVC apps, most of time you will use the ActionResult class. Last week while I was working on my open source project WeBlog, I built an HTTP Handler to serve up images. I started using an HTTP Handler for images because I needed a mechanism to prevent bandwidth leeching. The only bad thing about using an HTTP handler for images is that you end up with some pretty ugly URLS. In my case the URL ended up looking like this: /Image.axd?image=sample.png Luckily, my friend Ron noticed my new HTTP Handler and mentioned that I could have accomplished the same thing with a controller action that returned a FileResult instead. After a bit of investigation, I realized that Ron was absolutely right. I deleted my HTTP Handler and replaced it with this code, which was added to the Home Controller: private string GetContentType(string filename) {
FileInfo file = new FileInfo(filename);
switch (file.Extension.ToUpper()) {
//images
case ".PNG" : return "image/png";
case ".JPG" : return "image/jpeg";
case ".JPEG": return "image/jpeg";
case ".GIF" : return "image/gif";
case ".BMP" : return "image/bmp";
case ".TIFF": return "image/tiff";
default:
throw new NotSupportedException("The Specified File Type Is Not Supported");
}
}
public FileResult GetImage(string id) {
string path = Path.Combine(Engine.GetImageDirectory().FullName, id);
return base.File(path, GetContentType( path ) );
}
Since this code resides in my Home controller I would need to use the URL like “/Home/GetImage/sample.png” to display an image. Admittedly this URL is still a big ugly, so I decided to use a custom route to clean it up. The new custom route is named “Images” and is mapped it to the Home controller’s GetImage method. Here is the entry used in the global.asax file:
routes.MapRoute("Images",
"Images/{id}",
new { controller = "Home", action = "GetImage", id = "" });
Now I can display images by using the following URL:
”/Images/sample.png”
To the end user, this looks like a traditional file path. However, in reality there is no “Images” folder in the root directory. “Images” is just the name of the route being used. In reality, the image files are actually stored in the App_Data/Images folder.
By using a FileResult object with MVC you not only get a pretty URL but you also get a lot of flexibility on where you want your images to reside. You can store images anywhere you want and the URL will never need to change!


|
New and Notable 400
Sam Gentile
- Posted 3/7/2010 12:41 PM
|
|
Number 400!
SOA/REST/M/Oslo
- SOA in a Nutshell - A new JP Morgenthal’s post “The Busy Executive’s Service Oriented Architecture Reference Guide” is a great starting point for gaining a quick understanding of what SOA is without getting too deep into technology jargon and hype
- Don Box Discusses SOAP, XML, REST and M - In this interview from QCon San Francisco 2009, Don Box discusses the history of SOAP, XML, XML Schema, RELAX NG, SOAP and WSDL, REPL, opinions on REST, REST at Microsoft, coexistence of REST and WS-*, the M programming language, M and DSLs, M versus XML/XML
- Is OData the Ubiquitous Language for Application Collaboration? - The Open Data Protocol (OData) specification opens up possibilities to a lot of interesting collaborative use-cases and scenarios. Some of which are highlighted by Douglas Purdy, Pablo Castro and Jon Udell.
- ActAs in WS-Trust 1.4 - Pablo Cibraro talks about a new feature in WS-Trust 1.4; new feature called as “ActAs” for addressing common scenarios where an application needs to call a service on behalf of the logged user or a service needs to call another service on behalf of the original caller.
|
On Small Applications
Udi Dahan - The Software Simplist
- Posted 3/7/2010 5:23 AM
|
|
I hear this too often: “X sounds like a great pattern, but it’s overkill for small applications”. Many patterns have been subjected to this including (but not limited to): SOA, DDD, CQRS, ORM, etc. Often the statement is made by a person without experience in the given pattern (though possibly experienced in other patterns). Let’s [...]
|
Parallelism in .NET – Part 12, More on Task Decomposition
Reed Copsey, Jr.
- Posted 3/5/2010 6:32 PM
|
|
Many tasks can be decomposed using a Data Decomposition approach, but often, this is not appropriate. Frequently, decomposing the problem into distinctive tasks that must be performed is a more natural abstraction.
However, as I mentioned in Part 1, Task Decomposition tends to be a bit more difficult than data decomposition, and can require a bit [...]
|
SQL Saturday #44 – First In California!
Marlon Ribunal
- Posted 3/5/2010 1:28 PM
|
CALL For Speakers
The SQL Saturday event in Southern California is finally here! Call for Speakers is officially open. According to the official record, this is the first ever SQL Saturday event in California and the first one set up since the transfer of SQLSaturday to PASS. I am just happy to be part of this [...]
|
Upcoming Speaking Engagements
Milan Negovan
- Posted 3/5/2010 9:41 AM
|
|
This is a short notice, but still… I'm giving my
IoC and DI with WebForms presentation at the
New York Code Camp tomorrow. Instead of walking away with a "this is only a demo; don't try it at home" excuse, I actually have a read-world example to go through.
There exists an entrenched belief that there's only one way to develop with WebForms, i.e. rely on the crunch of view state, postbacks, session, etc. I beg to differ. You can write cleaner, cohesive, more testable code, and I intend to prove it.
At my session, we will
- talk about what it takes to write highly cohesive, loosely coupled code
- see what Inversion of Control (IoC) and Dependency Injection (DI) are all about
- look at appropriate ways of using an IoC container
If accepted, I also plan on giving this talk at the
Utah Code Camp on March 27 and Richmond Code Camp on May
22. If you are "in the area," please stop by. ;)
ASP.NET consulting with imagination and passion.
Hire me!
|
Stitching git histories
Mauricio Scheffer
- Posted 3/4/2010 9:22 AM
|
|
We finally finished migrating the Castle subversion repository to git. When starting the migration we decided that each project under the Castle umbrella would keep all of its history, which meant including the history from when the projects weren't separate and stand-alone but a single humongous project. This was a problem, as git-svn couldn't follow the project split. I first asked on stackoverflow about this, but didn't get any real solutions. So after a few failed experiments I settled on using grafts and filter-branch. Here's the guide I wrote to migrate each project, I think it could be of help for someone in a similar situation. I already had run basic git-svn migrations of everything so I'll just skip that step. First, clone the original-history project from the read-only URL (to prevent accidentally pushing to it) $ git clone git://github.com/castleproject/castle.git
$ cd castle Add the recent-history project as a remote (with the private read-write URL) and fetch it: $ git remote add recent git@github.com:castleproject/Castle.Facilities.ActiveRecordIntegration.git
$ git fetch recent Launch gitk to see both trees: $ gitk --all Press F2 and select remotes/recent/master  Both histories are unrelated! Take note of the SHA1 of the first commit in the recent-history (in this case, the one that has the description "Creating Facilites new folders and setting up the structure". The SHA1 of this commit in this case is 1ad7a4e10b711d1a58f7ac610078dcdf39b36d08 Search in gitk the exact commit in the original-history where the project was moved to its own repository. The first commit in recent-history has the date 2009-10-20 07:30:08 so it has to be around that time.  Found it! Take note of the SHA1: 3526f1a76f6ee2fb23cb2b402201bab1fc5a5b28 Now we're going to build the graft point. Create a .git/info/grafts file with the SHA1s we wrote down: 1ad7a4e10b711d1a58f7ac610078dcdf39b36d08 3526f1a76f6ee2fb23cb2b402201bab1fc5a5b28 Note that the format is <child SHA1> <parent SHA1> Restart gitk, check that both histories are now related:  Now let's make this permanent with git-filter-branch. First we locate all branches and tags in recent-history. In this case there are two branches: master and svn, and no tags. Create local branches and tags for each of these: $ git branch rmaster recent/master
$ git branch rsvn recent/svn Now we run filter-branch for these heads: </P? $ git filter-branch -- 3526f1a76f6ee2fb23cb2b402201bab1fc5a5b28..rmaster 3526f1a76f6ee2fb23cb2b402201bab1fc5a5b28..rsvn If it complains about a dirty working copy when running filter-branch, reset and retry. Refresh gitk, check that everything's OK:  Remove the graft and the original heads: $ rm -rf .git/info/grafts .git/refs/original Check gitk again, if everything's OK relocate master: $ git reset --hard rmaster The temporary branches can be removed now: $ git branch -d rmaster rsvn And finally push: $ git push -f recent Note that we need to use the -f (force) flag since we rewrote history. Check on github that everything looks good. Hmm, there's an outdated svn branch, let's remove it: $ git push recent :svn On github, check that the committers are correctly mapped, each commit should be linked to the profile of its author.  Now add the build scripts as a submodule: $ git submodule add git://github.com/castleproject/Castle.Buildscripts.git buildscripts Commit and push. That's it. Actually, after all of this we decided to avoid submodules and instead copy the build scripts and build tools to make forking easier for everyone. Also, this guide wasn't applied verbatim for all projects. Some projects were merged into other projects, so these "destination" projects required multiple graft points to merge the other projects' histories.


|
VirtualBox article
DevPinoy.Org
- Posted 3/4/2010 1:25 AM
|
Wow, I haven't updated this blog for quite some time. I'm finding out it's true: Twitter kills blogging. Anyway, my VirtualBox how-to article is out! For those of you who have been hiding under a rock (?), VirtualBox is a freely-available virtualization solution that is now owned by Oracle because of its purchase of Sun. The article is in the LinTech! section of the Philippine Online Chronicles ....(read more)
|
HTPC – Wireless Security Cameras
Rob Chartier
- Posted 3/3/2010 7:24 PM
|
|
Moving along in my adventure with my Home Theatre PC I decided to add in support for my D-Link DCS Wireless Cameras. Here are the steps that I took in order to get that online. 1. Install the Cameras, and configure them appropriately. 2. (Optional) Install the WHS Add-In [More Info]. This allows for Snapshot/Video storage. 3. On your HTPC, run the D-Link D View Cam installation [Direct Download], [Product Page] (See bottom of this post for v3 Info) 4. Walk through the wizard to find and setup your Cameras in the software. Since I changed the passwords on each camera, I had to set each individually once the Wizard found both of them. Here is a preview of my setup: Side Note: If you didn't notice I actually switched from RDP administration for the HTPC over to UltraVNC. I really didn't like how RDP forces the desktop (on the TV) to log off. 5. Next step is to configure your remote to work with EventGhost to essentially Task Switch over to the Dlink View Application. Not covered here is the Logitec remote control setup, but if you are familiar with that application then choose a spare button and map that into EG. I chose Yellow, with a name of “Security”. In EventGhost, I created a new Macro, (Launch Application), and pointed it to: “C:\Program Files\D-Link\D-Link D-ViewCam\Bin\DVC2.0.exe” and a working directory of “C:\Program Files\D-Link\D-Link D-ViewCam\Bin\” Maximized window, normal priority. Now, on your remote point it at your IR Receiver and press the button which you programmed in for “Security”. It should show up in the Log on the left of EventGhost. Click and drag that new event into the new Macro we just created. Binding that event to the action which we want it to take. Note: You may also want to add a “Find Window”, “Bring to Front”, and Maximize actions in that Macro as well. Force it be front and center. Last minute update… After looking around for more information on the DLink D-View Cam software I managed to stumble upon their forums, and specifically one discussion for version 3 of the Software. Download v3 here, Manual. In order to get this running, I first exited the application (right click the system tray icon, exit) and then uninstalled the v2 software and ran the v3 installation. I love the Single Video, Full Screen and Auto Scan set to 5 seconds. Don't forget to update EventGhost to point to the new install. Here is the Screenshot for v3. [backup] [reboot] [test] Its as easy as that to add Security Monitoring to your Home Theater Experience!
|
Computer Books to Read on a Lonely Island
Roland Weigelt
- Posted 3/3/2010 6:38 PM
|
|
I recently had the pleasure to visit this place:  On an island of approx 300x200 meters, snorkeling, swimming, eating, sleeping and relaxing is pretty much all you do. And reading, lots of reading: Two [computer] books that passed my personal “good to read far away from the keyboard” test are: - “Clean Code: A Handbook of Agile Software Craftsmanship”
Robert C. Martin I had this on my bookshelf for quite some time, but never did more than quickly scan the chapters. When you talk to people who have read this book, they usually say “you will not agree on everything the book says, but it is an important book to read” – now I’m one of them. I won’t go into more detail here; the reviews on e.g. Amazon pretty much capture what this book is about, so I recommend you take a look there. - “Pro Silverlight 3 in C#”
Matthew MacDonald Unlike “Clean Code”, this may not a book that would come to one’s mind as something that could be read well away from the computer – after all, it’s dealing with a specific technology and not general concepts. But this book does the walkthrough through the various code samples so well that you don’t need Visual Studio to follow what’s going on. I never had the feeling “Wait, where does this thing come from? If I only could hit F12” (which was what happened to me with one of the early books on WPF).
|
|