Uno Platform now lets you develop for macOS, Windows, and more using the same code

Uno platform wallpaper

Uno Platform announced today that it now supports macOS as a target platform. This new support means that developers can use a single code base to create apps on Windows, iOS, Android, the web, and macOS. According to Uno Platform, this makes it the first and only cross-platform solution to allow the same codebase to run on all these platforms. Uno Platform allows developers to use C# and XAML code to create native apps on several platforms. Rather than running through Electron or emulation, apps that utilize Uno Platform can…

Read More

Multiple output in Azure Functions with C#

Azure Functions Featured Image

In this post I like to analyse how to return multiple output in Azure Functions with C# and Service Bus. If you want more info, in the last week or so, I published some posts about Azure Function in C# or F# like “Create Azure Function in C# Script and Service Bus” or “Creating Azure Function in F#“. You have a platform on Azure and two different services are triggered by a message from Service Bus. At some point, you have an Azure Function doing a procedure that has to…

Read More

Working with CarouselView in Xamarin Forms

microsoft xamarin heros c# iOS Android UWP

Xamarin.Forms code runs on multiple platforms – each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app. CarouselView CarouselView is available in Xamarin.Forms 4.3. However, it is currently experimental and can only be used by adding the following line of code to your AppDelegate class on iOS, or to your MainActivity class on Android, before calling Forms.Init: Prerequisites Visual Studio…

Read More

Using functions as values in F#

Microsoft F# Fsharp

In my previous post, we discussed about immutable data structure. Now, imagine that we want to write a method similar to SumList but that multiplies the numbers rather than adding them. Making this change looks quite easy: we can copy the SumList method and tinker with it. There are only two changes in the modified method: The first change is that we’re using multiplication instead of addition in the branch that does the recursive call ❷. The second change is that the value returned for an empty list is now 1 instead of 0 ❶. This solution works,…

Read More

Lifetime Managers in Unity Container

The unity container manages the lifetime of objects of all the dependencies that it resolves using lifetime managers. Unity container includes different lifetime managers for different purposes. You can specify lifetime manager in RegisterType() method at the time of registering type-mapping. For example, the following code snippet shows registering a type-mapping with TransientLifetimeManager. var container = new UnityContainer() .RegisterType<ICar, BMW>(new TransientLifetimeManager()); The following table lists all the lifetime managers: Lifetime Manager Description TransientLifetimeManager Creates a new object of requested type every time you call Resolve or ResolveAll method. ContainerControlledLifetimeManager Creates…

Read More

Adding an external Microsoft login to IdentityServer4

Microsoft Authenticator Identity

This article shows how to implement a Microsoft Account as an external provider in an IdentityServer4 project using ASP.NET Core Identity with a SQLite database. Setting up the App Platform for the Microsoft Account To setup the app, login using your Microsoft account and open the My Applications link https://apps.dev.microsoft.com/?mkt=en-gb#/appList Click the Add an app button. Give the application a name and add your email. This app is called microsoft_id4_enrico. After you clicked the create button, you need to generate a new password. Save this somewhere for the application configuration.…

Read More

Connect ASP.NET MVC 4.6.2 project to IdentityServer4

I have a website running on ASP.NET MVC 4.5.2. I have an IdentityServer4 server running but when I try and authenticate against it I get an: invalid_request I googled a bit but I can’t find a solution. Finally, I found the way. First, in your IdentityServer4 you have to create a new client: public static IEnumerable GetClients() { return new List<client> { new Client { ClientId = “yourid”, AllowedScopes = new List<string> { “openid” }, AllowedGrantTypes = GrantTypes.Hybrid, RedirectUris = new List { “https://yoururl/signin-oidc” }, } } } When you…

Read More

Create a well formed URI using UriBuilder class with C#

C# .NET language

You can use System.UriBuilder class to build a new well-formed URI. You need to set some property of UriBuilder object’s, like Scheme, Port, Host, Path etc… You can get generated URI using AbsoluteUri Method. // Generate a new URI. UriBuilder objUri = new UriBuilder(); objUri.Scheme = “http”; objUri.Port = 80; objUri.Host = “www.microsoft.com”; objUri.Path = “en-us/default.aspx”; Response.Write(“Genereted URI: ” + objUri.Uri.AbsoluteUri); Happy coding!

Read More

Gravatar Tag Helper for .NET Core 2.1

A tag helper is any class that implements the ITagHelper interface. However, when you create a tag helper, you generally derive from TagHelper, doing so gives you access to the Process method. In your ASP.NET Core project, create a folder to hold the Tag Helpers called TagHelpers. The TagHelpers folder is not required, but it’s a reasonable convention. Now let’s get started writing some simple tag helpers. Tag helpers use a naming convention that targets elements of the root class name (minus the TagHelper portion of the class name). In…

Read More

MongoDb example

Simple example for MongoDB. Save and retrieve data from Azure Cosmos DB. Create an Azure Cosmos Db as MongoDb For creating a new MongoDb on Azure, search from the list of resources, Azure Cosmos Db. Then Add a new database and you see the following screen. Overview When you created a new MongoDb, you see an Overview where there are general information about how many queries the database did (split on insert, update, cancel, query, count, others). Under Connection String you have the connection to use in your application. In…

Read More

What Singleton Pattern is in C# and its implementation

In another post I discussed how to implement Inversion of Control Pattern in C#. In this post I should explain what a singleton is. The singleton pattern is one of the best-known patterns in software engineering. Essentially, a singleton is a class which only allows a single instance of itself to be created and usually gives simple access to that instance. Most commonly, singletons don’t allow any parameters to be specified when creating the instance – as otherwise, a second request for an instance but with a different parameter could…

Read More