Reflection vs. Metadata

Here are some old notes I had about Reflection vs. the raw IMetadata Import interfaces. They’re from a while ago (before CLR 4.0 was shipped!), but still relevant. Better to share late than never! Quick reminder on the two APIs I’m comparing here: Reflection is the managed API (System.Type and friends) for reading metadata. The…

2

Converting between Azure Tables and CSV

I published a nuget package (CsvTools.Azure) to easily read/write CSVs to azure blobs and tables.  It builds on the CSV reader, also on Nuget (see CsvTools) and GitHub (https://github.com/MikeStall/DataTable ). Azure Tables are very powerful, but can be tricky to use. I wanted something that: handled basic scenarios, such as uploading a CSV file to…

0

Strong binding for CSV reader

  I updated my open source CSV reader to provide parsing rows back into strongly typed objects. You can get it from Nuget as CsvTools 1.0.6. For example, suppose we have a CSV file “test.csv” like so: name, species, favorite fruit, score Kermit, Frog, apples, 18% Ms. Piggy, Pig, pears, 22% Fozzy, Bear, bananas, 19.4%…

2

Per-controller configuration in WebAPI

We’ve just added support for WebAPI to provide per-controller-type configuration. WebAPI has a HttpConfiguration object that provides configuration such as: route table Dependency resolver for specifying services list of Formatters, ModelBinders, and other parameter binding settings. list of message handlers, However, a specific controller may need its own specific services. And so we’ve added per-controller-type…

0

WebAPI Parameter binding under the hood

I wrote about WebAPI’s parameter binding at a high level before. Here’s what’s happening under the hood. The most fundamental object for binding parameters from a request in WebAPI is a HttpParameterBinding. This binds a single parameter. The binding is created upfront and then is invoked across requests. This means the binding must be determined…

0

Excel on Azure

  I amended my open-source CsvTools with an Excel reader. Once I read the excel worksheet into a datatable, I can use all the data table operators from the core CsvTools, including enumeration, Linq over the rows, analysis, mutation, and saving back out as a CSV. So this gives be a Linq-to-Excel on Azure experience,…

6

How to create a custom value provider in WebAPI

Here’s how you can easily customize WebAPI parameter binding to include values from source other than the url.  The short answer is that you add a custom ValueProvider and use Model Binding, just like in MVC. ValueProviders are used to provide values for simple types and match on parameter name.  ValueProviders serve up raw pieces…

0

How to bind to custom objects in action signatures in MVC/WebAPI

MVC provides several ways for binding your own arbitrary parameter types.  I’ll describe some common MVC ways and then show how this applies to WebAPI too. You can view this as a MVC-to-WebAPI migration guide.  (Related reading: How WebAPI binds parameters ) Say we have a complex type, Location, which just has an X and…

3

MVC Style parameter binding for WebAPI

I described earlier how WebAPI binds parameters. The entire parameter binding behavior is determined by the IActionValueBinder interface and can be swapped out. The default implementation is DefaultActionValueBinder. Here’s another IActionValueBinder that provides MVC parameter binding semantics. This lets you do things that you can’t do in WebAPI’s default binder, specifically: ModelBinds everything, including the…

5

How WebAPI does Parameter Binding

Here’s an overview of how WebAPI binds parameters to an action method.  I’ll describe how parameters can be read, the set of rules that determine which technique is used, and then provide some examples.   [update] Parameter binding is ultimately about taking a HTTP request and converting it into .NET types so that you can…

9