0 Comments

UWP.MDI_faster

UWP.MDI is a new library which provides MDI (Multiple document interface) support for UWP applications. The library is completely open source and available with MIT license.

Background

MDI (Multiple Document Interface) was popular user interface paradigm in Windows Forms era. MDI allows one window to host multiple child windows. Each window can be resized and moved around.

When WPF was released, it didn't contain support for MDI interfaces and the situation didn't change when WinRT and UWP were released.

UWP.MDI has two targets:

  1. To provide comprehensive MDI support for UWP applications.
  2. To provide MDI support in such a way that those familiar with Windows Forms' MDI support feel at home.

Getting started

Getting started with UWP.MDI aims to be simple:

  1. Create a blank uwp application
  2. Add MDIContainer into the MainForm
  3. Add UserControl
  4. Show UserControl by creating a new instance of it and calling MyUserControl.Show()

The easiest way to get learn more is to clone the project repository (https://github.com/mikoskinen/UWP.MDI) and to launch the sample application. The sample contains the MDI container and couple child windows.

Known issues

The library has few known issues. Main thing is making sure that everything works nicely with your MVVM framework of choice. The UWP.MDI library is implemented in such a way that you can continue using for example Caliburn.Micro, but there’s currently no available sample for that.

Links

UWP.MDI is available from GitHub: https://github.com/mikoskinen/UWP.MDI

0 Comments

I released NSQLFormatter few years ago (actually it’s more than few years ago, back in 2011.). As a reminder, NSQLFormatter is "an open-source SQL Beautifier written with C#".

In 2015 the library was released as a Portable Class Libray. There's now a new version which targets .NET Standard 1.3. This version is supported by about every currently supported .NET platform, including .NET Core, Mono and .NET Framework 4.6.1.

Let me know if you encounter any issues with the project.

GitHub: https://github.com/mikoskinen/NSQLFormatter-dotnet

NuGet: https://www.nuget.org/packages/NSQLFormatter/

0 Comments

logoAzure Blob Bridge for IFTTT provides an easy way to use Azure Blob storage as a IFTTT output Channel (action). For introduction of the project, you can read the Azure Blob Bridge for IFTTT: Introduction.

This post includes a step-by-step guide for using Azure Blob Bridge for IFTTT. The guide is split in two parts:

  • Deploying Azure Blob Bridge for IFTTT
  • Creating a IFTTT recipe using the Maker Channel

By following this tutorial you will connect the BBC’s RSSwith your Azure Blob Storage.

TL;DR

  1. Deploy Azure Blob Bridge for IFTTT using the Deploy to Azure button: https://github.com/mikoskinen/AzureBlobBridgeIFTTT
  2. Use IFTTT’s Maker Channel to POST to bridge

Requirements

You need the following things to work through this tutorial:

  • Working Azure subscription
  • Azure Storage account
  • IFTTT Account connected to the Maker Channel

Deploying Azure Blob Bridge for IFTTT

The goal for Azure Blob Bridge for IFTTT’s deployment process is to be as simple as possible. The steps include:

  1. Visit the bridge’s home page at GitHub: https://github.com/mikoskinen/AzureBlobBridgeIFTTT
  2. Click the “Deploy to Azure” Button
  3. Configure the required settings
  4. Click Next
  5. Click Deploy
  6. All set

1. Open the Azure Blob Bridge site

Visit https://github.com/mikoskinen/AzureBlobBridgeIFTTT with your browser:

image

2. Click the Deploy to Azure button

image

3. Configure the required the settings

The hardest part is configuring the settings. The Deploy to Azure page contains three (3) settings which you must manually configure, others are automatically set by the site. The manually configured settings are highlighted here:

image

ApiKey decides how the bridge is reached. Example: ApiKey = "hello" -> Your API works through http://yourdomain.com/api/hello.

In this guide we will use MyBridgeKey.

Container is the name of your Azure Blob Storage container where the blobs will be stored. The container will be automatically created if it’s missing.

In this guide we will use mybridgecontainer. (note: you cannot use upper case character)

Storage Connection Stringis used to connect the bridge to your Azure Blob Storage. The connection string is available through Azure portal’s Storage Accounts blade. From Manage, click Keys and copy the Secondary connection string:

image

In this tutorial we will be deploying the Azure Blob Bridge for IFTTT to the West Europe, using the site name MyAzureBlobBridge. Our full configuration is shown here:

image

4. Click Next

After clicking Next, the deploy site will show you that only a Website resource is created:

image

5. Click Deploy

Select Deploy and wait the site to do it’s magic:

image

It should take less than a minute to complete:

image

6. All set

Deployment completed and shows you the Browse link. Click it to make sure that everything is working correctly. You should see text “Good to go!” if everything is up and running. If you see an error, make sure that the configuration is set correctly.

image

Now we have a working Azure Blob Bridge for IFTTT. It’s time to setup the IFTTT.

Other alternatives for deployment

If you don’t want to use the “Deploy to Azure” button, you can clone the repo, create the Azure Web Site manually, set Web.config for the required configuration and push your repo to site.

Creating a IFTTT recipe using the Maker Channel

IFTTT makes it easy to connect to our newly set Azure blob bridge. The steps include:

  1. Create a new recipe
  2. Configure the IF-part (source Channel / trigger)
  3. Configure the Then-part (output Channel / action)

1. Create a new recipe

Start by selecting Create a Recipefrom My Recipes page:

image

Click “this” to start configuration:

image

2. Configure the IF-part (source Channel / trigger)

In this tutorial we will be using RSS Feed as a Trigger:

image

Select “Feed” and then click “New feed item”. This way the trigger is automatically run everytime a new item is posted into the RSS feed.

image

After selecting the “New feed item”, you must fill in your desired RSS source. For this tutorial we will be using BBC’s RSS feed as that gets updated quite often. Fill in the address: http://feeds.bbci.co.uk/news/system/latest_published_content/rss.xml

image

And finally select “Create Trigger”. You trigger is now ready.

3. Configure the Then-part (output Channel / action)

The trigger is now ready so it’s time to set the output channel or the action. Select “that” to continue:

image

IFTTT lists all the available action channels. We will use Maker Channel to connect to our newly created Azure Blob Bridge.

image

Select Maker. The “Make a web request” is the only available option so continue by selecting it:

image

Now we must configure Maker so that it’s connected to our bridge.

image

In the first part of the tutorial, we published the Azure Blob Bridge for IFTTT to url http://myazureblobbridge.azurewebsites.net/ and we used the Api Key MyBridgeKey. This means that the bridge is available through URL http://myazureblobbridge.azurewebsites.net/api/MyBridgeKey/. Fill that in.

The bridge accepts POST requests, so select POST in Method.

We want to store the new items as JSON-files, so select application/json in Content Type.

Finally, the body is used to configure the content of the new Azure Blob. We want to store the URL and the Title of the news item. To save them in correct JSON-format, fill in the following text in Body:

{ "Title":"{{EntryTitle}}", "URL":"{{EntryUrl}}" }

The complete configuration is shown here:

image

To finish the tutorial, select “Create Action” and then “Create Recipe”.

image

And you’re done!

image

Final Words

By following this tutorial you have connected the BBC’s RSS with your Azure Blob Storage. As the BBC feed is updated quite often, you should soon see new blobs in your Azure Blob storage. As an example, here’s the content of the blob 635859502521919728.dat, as created by the recipe:

{
	"Title": "Device 'goes off' at shopping centre",
	"URL": "http://www.bbc.co.uk/news/uk-england-lancashire-35122044#sa-ns_mchannel=rss&ns_source=PublicRSS20-sa"
}

Using RSS as a trigger is just a one example of how you can use Azure Blob Bridge for IFTTT. IFTTT contains more than 240 channels which now can be connected with the Azure Blob storage.

0 Comments

logoAzure Blob Bridge for IFTTT provides an easy way to use Azure Blob storage as a IFTTT destination Channel.

In this post I’ll introduce you to the Azure Blob Bridge for IFTTT project. I will follow up with a tutorial which will include:

  • Deploying Azure Blob Bridge for IFTTT
  • Creating a IFTTT recipe using the Maker channel

Background

IFTTT is a web-based service that allows users to create chains of simple conditional statements, called "recipes", which are triggered based on changes to other web services such as Gmail, Facebook, Instagram, and Pinterest. IFTTT is an abbreviation of "If This Then That"…

https://en.wikipedia.org/wiki/IFTTT

Wikipedia's description of IFTTT is accurate: It allows you to chain web services together. For example, I’ve been using it to write new posts from Feedly into our Wordpress.

Unfortunately IFTTT doesn't currently provide Channel for Azure Blob storage. Azure Blob Bridge for IFTTT -project can be used to work around the limitation. The project works as an output Channel (“action”) for IFTTT. Using Azure Blob Bridge for IFTTT as a Trigger is coming later.

Implementation

Azure Blob Bridge works by providing HTTP POST API for uploading blobs to your Azure Storage Account. The project is implemented using Nancy and C#.

The project creates a POST uri based on your configuration’s apiKey. For example, if you set your apiKey to “myKey”, you can access the bridge through /api/myKey/.

The new blob will be created from the request’s content (body). Content-type is set if provided in request headers. File name is automatically generated using DateTime.UtcNow.Ticks + ".dat".

Usage with HTTP POST

To write a blob to your Azure Blob storage, send a HTTP POST Request to the Azure Blob Bridge for IFTT:

POST http://myapp.domain.com/api/apikey HTTP/1.1
Content-Length: 38
Content-type: Application/json

{"author":"hello", "text":"mycontent"}

Configuration

You need to define three configuration settings, either through the Azure Deploy or through Web.config:

  • apiKey = Api key is used to define the URL for your api. NOTE: Use only valid URI characters. Example: apiKey = "hello" -> Your API works through http://yourdomain.com/api/hello
  • storageConnectionString = The Azure Storage connection string. Example: DefaultEndpointsProtocol=https;AccountName=mystoragewe;AccountKey=wjN544545444233rwsdsdddddkkkkkkk999999999923wu3zJXSoBJ4LAWBbtEYKqbwjIQ==
  • container = The Azure container where files will be written. NOTE: Use only valid container character (so no upper cases or numbers). If container is missing, it will be automatically created as private. Example: mycontainer

Code

The Azure Blob Bridge for IFTTT is available through GitHub as an open source project.

License

The project is distributed under the terms of the MIT License (see mit.txt).

0 Comments

NXMLFormatter is an open-source XML Formatter and beautifier written with C#. The DLL is available as a portable class library, so you can use it from UWP, ASP.NET etc.

Usage

  1. Add reference to NXMLFormatter.dll.
  2. var formattedXML = NXMLFormatter.Formatter.Format(originalXML);

Project doesn't have any external references and it uses only the features provided by the .NET Framework.

NuGet

NXMLFormatter is available through the NuGet with the package name NXMLFormatter. Type "install-package NXMLFormatter" to install it.

Example

Input
<catalog><book id="bk101"><author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description>
</book>
<book id="bk102">   <author>Ralls, Kim</author>   <title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description></book>
<book id="bk103">   <author>Corets, Eva</author>   <title>Maeve Ascendant</title>   <genre>Fantasy</genre>
   <price>5.95</price>   <publish_date>2000-11-17</publish_date>
   <description>After the collapse of a nanotechnology society in England, the young survivors lay the 
   foundation for a new society.</description></book></catalog>
Output
<catalog>
  <book
    id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
    <description>An in-depth look at creating applications with XML.</description>
  </book>
  <book
    id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-12-16</publish_date>
    <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>
  </book>
  <book
    id="bk103">
    <author>Corets, Eva</author>
    <title>Maeve Ascendant</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-11-17</publish_date>
    <description>After the collapse of a nanotechnology society in England, the young survivors lay the 
   foundation for a new society.</description>
  </book>
</catalog>

Implementation

Under the covers the library uses XmlWriter to format the code.

Licenses

The library is distributed under the terms of the MIT License (see mit.txt).

Source code

NXMLFormatter’s source code is available from GitHub.