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
|
|
|
EntitySpaces 2010 Release Schedule
Mike Griffin
- Posted 3/11/2010 10:29 PM
|
|
The dates are as follows:
March 29th - Early Adopter Program
The early adopter release will be available to a limited set of EntitySpaces customers
who have a real need for some of the new or enhanced EntitySpaces 2010 features (such
as Silverlight, WCF, Smart Proxies, SQLite, JSON serialization). We are looking for
customers who desire to upgrade to ES2010 now and continue developing through to release.
Prime candidates are new customers working on projects that haven’t shipped yet who
can easily upgrade and begin working with ES2010. If you are interested in participating
in our Early Adopter Program please send an email to earlyadopter@entityspaces.net with
your EntitySpaces user id and how you plan to use EntitySpaces 2010. Not everyone
who sends an email will be chosen to participate. Again, we are looking for users
who are really going to use this version for development. We are seeking about 20
users to participate and they will be hand picked based on the email we receive explaining
how ES2010 will be used. For example, we are interested in Windows Forms, ASP.NET,
Silverlight, and so on, in other words, a good cross section of development. Current
forum participation will also help in being chosen (active users).
Keep in mind that EntitySpaces 2010 will not support .NET 2.0, it’s .NET 3.5 and forward.
We are unsure at this point if .NET 4.0 assemblies will be included in the Early Adopter
Program.
April 19th – Public Beta (customers only)
We are planning on only one beta. This beta will be available to all customers. We
realize that the beta window looks short here but this release will have passed all
of our unit tests and will have been pretty heavily used by those participating in
the Early Adopter Program.
April 29th – Official Release
This is our official release. The EntitySpaces 2010 Trial version will also be available
as well for the general public.
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
|
Low-level SolrNet
Mauricio Scheffer
- Posted 3/11/2010 10:28 PM
|
|
I recently got a question about how to handle multi-faceting in SolrNet, a nice feature of Solr that can be very useful to the end-user. eBay uses a kind of multi-faceting interface. If you know nothing about Solr or SolrNet, read on, this article isn't so much about Solr as API design. The Solr wiki has an example query with multi-faceting: q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&facet=on&facet.field={!ex=dt}doctype
For those of you that are not into Solr, this is just a regular URL query string that is passed to the Solr endpoint. The final URL looks like this (modulo encoding):
http://localhost:9983/solr/select/?q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&facet=on&facet.field={!ex=dt}doctype
And this is how you represent this query in the SolrNet object model:
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Document>>();
ISolrQueryResults<Document> results = solr.Query("mainquery", new QueryOptions {
FilterQueries = new[] {
Query.Field("status").Is("public"),
new LocalParams {{"tag", "dt"}} + Query.Field("doctype").Is("pdf")
},
Facet = new FacetParameters {
Queries = new[] {
new SolrFacetFieldQuery(new LocalParams {{"ex", "dt"}} + "doctype")
}
}
});
We build object models like this one because they're programmable, objects and methods can be programmatically combined to build (or compose) our intention. Like Hibernate's Criteria API.
Opposed to this is the string, and most of the time we hate it because it's opaque, it doesn't have any syntactical meaning within our object-oriented code. It has no programmability, no composability. We use very generic classes to build strings, like StringBuilders or StringWriters, which don't convey any syntactical information about what we're actually doing. If we need to extract information from a string, we have to write a parser, which is not a trivial task. But the string also has its advantages: it's naturally serializable (or should I say already serialized), it can be more readable and more concise. And those are some of the reasons why Hibernate also provides the HQL API. You might be thinking that this dichotomy of objects and strings is really a matter of serialization and deserialization, but I'm talking about human-readable strings here, whereas a serialized format is frequently for machine consumption only.
So if we already know what the query string is, how can we simplify the chunk of code above? Thanks to IoC, we can easily tap into some of SolrNet's "internal" components without worrying about what dependencies they need:
Func<string, string, KeyValuePair<string, string>> kv = (k, v) => new KeyValuePair<string, string>(k, v);
var connection = ServiceLocator.Current.GetInstance<ISolrConnection>();
var xml = connection.Get("/select", new[] {
kv("q", "mainquery"),
kv("fq", "status:public"),
kv("fq", "{!tag=dt}doctype:pdf"),
kv("facet", "on"),
kv("facet.field", "{!ex=dt}doctype"),
});
var parser = ServiceLocator.Current.GetInstance<ISolrQueryResultParser<Document>>();
ISolrQueryResults<Document> results = parser.Parse(xml);
ISolrConnection is just a wrapper over the HTTP request, we give it the querystring parameters and get Solr's XML response, then we feed the response to the parser component and voilà, we have our results.
And since it's just a regular HTTP request, we can go even lower:
using (var web = new WebClient()) {
var xml = web.DownloadString("http://localhost:9983/solr/select/?q=mainquery&fq=status%3Apublic&fq=%7B!tag%3Ddt%7Ddoctype%3Apdf&facet=on&facet.field=%7B!ex%3Ddt%7Ddoctype");
var parser = ServiceLocator.Current.GetInstance<ISolrQueryResultParser<Document>>();
ISolrQueryResults<Document> results = parser.Parse(xml);
}
I'll leave it to you to decide which one to use. Like the choice between HQL and Criteria, sometimes you might prefer one over the other depending on the context. Just keep in mind that these components' interfaces are not as stable as the "really public" documented interfaces, they might have breaking changes more often.


|
WikiPlex v1.3 Released
Matt Hawley
- Posted 3/11/2010 6:35 PM
|
|
[In addition to blogging, I am also using Twitter. Follow me: @matthawley] It's been a many months since the last release of WikiPlex, but its only because there hasn't been a lot of churn recently. I've very happy where WikiPlex is at, and it continues to be a very… (read more)
|
Gallio.Utility.exe considered evil
Oliver Sturm
- Posted 3/11/2010 12:00 PM
|
|
I just blogged about this problem I was having with Gallio/MbUnit. I don’t regard the issue as fixed, but I’ve certainly worked around it.
I found that the delay happened when the tool Gallio.Utility.exe was being run during the startup process of Icarus. I noticed that the same thing happened when I tried to run other included tools like the control panel, and it also happened when using TestDriven to run an MbUnit test from VS. I had the impression that the tool was being run multiple times, but that turned out to be a mistake – the tool was simply running for a rather long time, jumping up and down a bit in the task manager list. I finally ran the tool on its own and found that (a) it has something to do with the plugins that Gallio apparently uses (for purposes unclear to me, I have to admit) and (b) even to just run the tool and display the usage info message in a console, it takes 25 seconds or so.
So, simple solutions are sometimes the best: I deleted Gallio.Utility.exe. Next run of Icarus, it was restored. Okay, MSI is more cleverer than I. Or so it thinks – I went and configured the file access permissions on the file and removed all access permissions. Hah, take that, MSI. Next run, Icarus comes up within about 3 seconds, taking another 2-3 to load my test assembly. Hah!
Running a test through TestDriven from VS takes about 3.9 seconds now, so it’s at least 2 times slower compared to running the same test through the CodeRush test runner. Weird, but then who am I to complain.
Now, could somebody please fix that Utility program before I end up needing it for something?
|
Converting from Blogger to Wordpress
Notorious N.E.R.D
- Posted 3/11/2010 11:20 AM
|
This week I started the hard shift from my old Blogger blog to my new Wordpress blog on my new domain ISerialized.com. There are a couple of aspects of such a shift that makes this a hard decision to do:
Allot of hard work
Leaving the old familiar Blogger tool
Learning Wordpress
Trying to convert my old Feedburner readers [...]
|
Windows Phone 7 Game Development #MIX10
Damir Tomicic
- Posted 3/11/2010 11:01 AM
|
|
Irgendwie können sie es gar nicht abwarten. So lange haben sie schon und nun brennen
die Worte offensichtlich Microsoft-Mitarbeitern auf der Zunge, kämpfen sich den
Weg raus in die Welt. Ich hoffe, es bleiben unter diesen Umständen genug Neuigkeiten
für meine Berichtserstattung aus Las Vegas übrig. :-)
Die erste große Ankündigung zur neuen Entwicklungsplatform für die kommenden Windows
Phone 7 Geräte - DAS Thema der MIX10 Konferenz - erfolgte seitens Eric Rudder
[1], Senior Vice President, Technical Strategy bei Microsoft, auf der TechEd-Konferenz.
Bei der Vorführung stellte er nett auch seine Spielfähigkeiten unter Beweis und
meinte, nach dem er überall fast sofort "gestorben" ist, die Plattform ermöglicht
"same experience on all devices". Mit Visual Studio entwickelt.
Was er kurz zeigte und damit die Katze aus dem Sack liess, erläuterte Charlie Kindel,
die aktuelle Stimme der mobilen Microsoft-Welt, mit einem ausführlichen Beitrag "Different
Means Better" [2] in seinem Blog. Die wichtigste Aussage zitiert:
It won’t come as a surprise to many to learn that the Windows
Phone 7 developer experience builds upon the following GIANTS (among others):
Na also, geht doch! Silverlight, XNA, .NET. Eine vielversprechende Kombination. Sogar
sehr vielversprechend. Nun ist die erste große Konferenz vor der MIX im vollen Gange,
die GDC (Game Developer Conference) in San Francisco, und schon lernen wir weitere
Mitglieder des Teams kennen. Und weitere Details drängen ans Tageslicht.
Andre Vrignaud aka Ozymandias enthüllt in seinem Beitrag "It Has Begun" [3] eine Menge
Details zur Spieleentwicklung auf der Windows Phone 7 Plattform mit dem XNA Framework.
Seine Begeisterung fasst er kurz in zwei Sätzen zusammen:
The thing that’s most exciting to me is that we’re finally able
to show off full-screen 3D titles, rendering in real-time with full hardware acceleration.
All through the 3D functionality we supply in XNA Game Studio 4.0
Und das ist in der Tat etwas Neues: PC, Xbox und ein mobiles Gerät, 3D, Echtzeit,
gleiche Entwicklungsplattform, gemeinsamer Code. Die Aussage und die ersten Demos
wecken sehr hohe Erwartungen und werfen enorm viele Fragen auf, die hoffentlich auf
der MIX10 beantwortet werden können. Es bleibt doch spannend. :-)
Weitere nützliche Blogs sind von Michael Klucher [4] und Shawn Hargreaves [5].
[1] http://www.youtube.com/watch?v=LQv_3fwopo8
[2] http://blogs.msdn.com/ckindel/archive/2010/03/04/different-means-better-with-the-new-windows-phone-developer-experience.aspx
[3] http://www.ozymandias.com/it-has-begun-first-sessions-on-developing-games-for-windows-phone-at-gdc
[4] http://klucher.com/blog/achievement-unlocked-xna-game-studio-4-0-for-windows-phone/
[5] http://blogs.msdn.com/shawnhar/archive/2010/03/10/xna-game-studio-on-windows-phone.aspx
|
System Center Capacity Planner 2007
Colt Kwong
- Posted 3/11/2010 9:29 AM
|
|
With a recent case that I need to design the system infrastructure as well as the hardware specification of a SharePoint farm for a client, so I go and find the SharePoint Capacity Planner (CP) 2007 to stimulate a user model. Before installting the SharePoint CP 2007, System Center CP is a prerequisite but unfortunity the Microsoft download page is _blank_:
Alternatively, I get the installer from a colleague. However, I face another problem while installing it:
The installer has encountered an unexpected error installing this package. This may indicate a problem with the package. The error code is 2738. This issue is happened only in Vista, and the details and solution had been posted on TechNet:
C:\Windows\System32\regsvr32 vbscript.dll
I can download the SharePoint CP and continue my work now. :)
|
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.


|
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.
|
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 >
|
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!
|
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)
|
|