Changing the supported media types of the default media formatters in the ASP.NET Web API client library

January 15, 2014 Leave a comment

A couple of days ago, I encountered an issue when calling a REST service. The REST service was returning JSON data, but the content type in the HTTP header was set to “text/javascript”. This caused the default JSON formatter of the ASP.NET Web API client not to recognize the data (he expects “application/json”). It took me a while to find this proper solution as I wanted to avoid creating a custom formatter, but the ASP.NET Web API client library allows to modify the supported content types for the default content formatters.

HttpClient client = new HttpClient();

MediaTypeFormatterCollection formatters = new MediaTypeFormatterCollection();
formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/javascript"));

HttpResponseMessage response = await client.GetAsync(url);
SearchResult result = await response.Content.ReadAsAsync(formatters);
Categories: ASP.NET Web API, C#, REST

Compiled Zip package for Jace 0.8.4

January 8, 2014 Leave a comment

Jace.NET is a mathematical calculation engine for .NET that can parse and execute strings containing mathematical formulas. More information on Jace can be found in previous articles published on this blog or in the following codeproject article: http://www.codeproject.com/Articles/682589/Jace-NET-Just-another-calculation-engine-for-NET.

Previously, the only way to obtain an already compiled version of Jace.Net was to use NuGet. Although I am still convinced that nowadays the recommended way to add frameworks to Visual Studio projects should be NuGet, I understand that this is not always possible. Especially in enterprise environments. For people in such situations, I have created a zip based version of Jace.NET. This zip package contains compiled versions of Jace for .NET 4.x, Windows Store, Windows Phone 7 and Windows Phone 8.

The zip version can be downloaded using the following link: https://github.com/pieterderycke/Jace/releases/download/0.8.4/Jace.0.8.4.zip.

All future zip packages will be published on the following GitHub page: https://github.com/pieterderycke/Jace/releases.

The assemblies in the zip package are currently not strongly signed. If you would rather prefer strongly singed assemblies, you can let me know by mail or by leaving a comment.

Categories: C#, Jace.NET

Release of Jace.NET 0.8.3

August 28, 2013 Leave a comment

A new version of Jace.NET has been released that includes fixes for two bugs that were identified by Mikael Palmblad. It is recommended for all users to upgrade. The latest version of Jace.NET can be found on GitHub and NuGet

https://github.com/pieterderycke/Jace

https://www.nuget.org/packages/Jace

Besides the bugfixes, two additional functions were added to Jace.NET: ifless and ifmore. Both functions accept four parameters:

ifless(a, b, c, d)
If a > b then return c else d

ifmore(a, b, c, d)
If a > b then returns c else d

Categories: Jace.NET

Calc#: a calculator for Windows Store

August 19, 2013 Leave a comment

Recently, I decided to have a look at Windows Store app development. The result is Calc#; a free calculator app based on Jace.NET (the calculation engine for .NET I have built in my free time). Calc# supports the calculation of all possible mathematical formulas. These formulas can contain variables and mathematical functions such as sine, cosine, arcsine, natural logarithm, common logarithm, square root …

CalcSharp

The design philosophy behind Calc# was: less is more. The UI contains the strict minimum that is needed to deliver a great user experience (or at least what I taught a calculator really needs).

Please download my app from the Windows Store and let me know your feedback 🙂

download_CalcSharp

Categories: Jace.NET, Windows 8

GIT support in Synology DSM 4.3 Beta

July 15, 2013 3 comments

A couple of days ago, Synology released the open beta of DSM 4.3. Somewhere hidden in the release notes there was mentioned that the NAS now officially supports the hosting of GIT repositories. This is great news for all programmers.

GIT support is activated by installing the respective package from the package center. Unfortunately the graphical configuration options are for the moment quite limited. The included configuration tool only supports granting GIT access to specific users.

git_server

The creation of new repositories must be done using SSH (do not forget to activate SSH support in the control panel!).

mkdir /volume<your prefered volume>/<your repository name>
cd /volume<your prefered volume>/<your repository name>
git init

What is lacking to make GIT support great?

Synology, if you read this. Consider adding the following features before DSM 4.3 goes final:

1) Make it possible to create new repositories graphically.

2) File Stations displays the created GIT repositories, but it should add an overlay icon to the folder to indicate that it is a GIT repository.

git_file_station

3) The current implementation only supports GIT over SSH. Unfortunately the official GIT plugin of Microsoft for Visual Studio 2012/2013 only supports GIT over HTTPS. Why not add support for GIT over HTTPS? (Please note: a workaround for this limitation is to checkout the server branch using the command line; use Visual Studio on the local branch and resync changes to the NAS using the command line. Although this is a workable solution. It is not ideal)

4) Allow file station to show the history of files in a GIT repository.

5) Allow to see network graphs of the GIT repositories (similar to what GitHub allows)

Categories: Review

PowerShell Dev Tip: Counting the number of lines in a VS project

Yesterday, I was confronted with the issue that I had to know the number of lines in a C# project to estimate the complexity of a rewrite. In order to get the job done, I wrote a little PowerShell script that counts all the source lines in a given project folder. Writing this in the PowerShell is remarkable easy thanks to the Measure-Object command.

Get-ChildItem -recurse -filter "*.cs" . | Foreach-Object {
	$lines = Get-Content $_.FullName | Measure-Object -line
	$fileAnalysis = New-Object -TypeName PSObject
	$fileAnalysis | Add-Member -MemberType NoteProperty -Name "Name" -Value $_.FullName
	$fileAnalysis | Add-Member -MemberType NoteProperty -Name "Lines" -Value $lines.Lines
	Write-Output $fileAnalysis
} | Export-Csv -NoTypeInformation -Delimiter ";" result.csv
Categories: PowerShell

Jace.NET 0.8.1 released

I am happy to anounce that Jace.NET 0.8.1 has been released with support for the unary minus operation. No breaking changes were done to the API.

The new version is uploaded to the official NuGet repository: https://www.nuget.org/packages/Jace. The source can be found on GitHub: https://github.com/pieterderycke/Jace.

Jace.NET runs on .NET 4.0 and higher, WinRT, Windows Phone 7 and Windows Phone 8.

Categories: Jace.NET