Test Driven Development (TDD) helps you to validate your code but something you need to check some result from a json file. Here my solution
Category: C#
Database Connection Resiliency in Entity Framework Core
How to implement database connection resiliency using an inbuilt or custom execution strategy using Entity Framework Core
Transactions with Entity Framework Core
In the last couple of weeks, I was talking about Entity Framework Core for creating a model or call stored procedures. But how to use transactions?
Run Azure Function on a different port
I want to run more than one Azure Function at the same time but each of them on a different port because by default all Azure Functions are starting on port 7071. How can I do that?
Map base class to derive class
I’m facing a problem when I want to cast a base class to a derive class. A derive class is a class that derives from a base class. In this post I explain my solution to this problem.
C# 9: Partial Method Enhancements for Source Generators
Source Generators in C# 9 will allow compiler-extensions to inspect code and then inject additional source code at compile-time
Source Generators enables Compile-Time metaprogramming
Source generators is a new feature of C# 9 that enables compile-time metaprogramming and generating additional source file.
Getting organization list from Xero in C#
Connect your C# application with Xero OAuth 2.0 is not really simple. Here how getting the list of organization from Xero step by step
Getting invoice list from Xero in C#
In this new post I explain the procedure for getting an invoice list from Xero in your C# applications with few lines of code.
Save and retrieve Secret from Azure KeyVault
How to retrieve #key, #secret, certificate from #Azure #KeyVault in C#? A step by step guide to configure your Azure account and start a new C# project
Integrate Xero with C# applications
How integrate Xero in your C# application? This is my guide step by step after spending more than one week to sort it out
Uno Platform now lets you develop for macOS, Windows, and more using the same code
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…
Adding Swagger UI to Azure Function APIs
You can set up Swagger UI in your Azure Function API to allow for providing documentation for your serverless API pretty easily
Multiple output in Azure Functions with C#
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…
Create Azure Function in C# Script and Service Bus
How to create an Azure Function in C# Script using as input and output a message from and to Service Bus Queue step by step
Working with CarouselView in Xamarin Forms
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…
Using functions as values in F#
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,…
Using immutable data structures in F#
An immutable data structure (or object) is a structure whose value doesn’t change after it’s created. When you declare a data structure that contains some values, you store these values in slots, such as a field or value declaration.
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…
Adding an external Microsoft login to IdentityServer4
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.…
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…
Create a well formed URI using UriBuilder class with C#
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!
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…
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…
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…