• chevron_right

      Use multiple implementations of an interface in ASP.NET Core

      pubsub.slavino.sk / infoworldcom · Monday, 23 November, 2020 - 11:00 edit

    The built-in support for dependency injection in ASP.NET Core is great. However, dealing with multiple implementations of an interface when working with dependency injection in ASP.NET Core is a bit tricky. In this article I’ll show you how to dynamically select a service from such an implementation in ASP.NET Core.

    To work with the code examples provided in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here .

    [ Also on InfoWorld: 6 Windows desktop utilities every software developer needs ]

    Create an ASP.NET Core MVC project in Visual Studio

    First off, let’s create an ASP.NET Core Web Application MVC project in Visual Studio 2019. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.NET Core MVC project in Visual Studio.

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • chevron_right

      How to use RecyclableMemoryStream in .NET Core

      pubsub.slavino.sk / infoworldcom · Monday, 16 November, 2020 - 11:00 edit

    Microsoft.IO.RecyclableMemoryStream is a high-performance library designed to improve application performance when working with streams. It is a replacement for MemoryStream and provides better performance than MemoryStream instances.

    You can use RecyclableMemoryStream to eliminate LOH (large object heap) allocations and avoid memory fragmentation and memory leaks. This article talks about the Microsoft.IO.RecyclableMemoryStream library, its purpose, and how it can be used in .NET Core applications to boost application performance.

    [ Also on InfoWorld: 6 Windows desktop utilities every software developer needs ]

    To work with the code examples provided in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here .

    To read this article in full, please click here


    Značky: #Rozne, #C#

    • chevron_right

      How to create route constraints in ASP.NET Core

      pubsub.slavino.sk / infoworldcom · Monday, 5 October, 2020 - 10:00 edit

    Route constraints in ASP.NET Core are used to filter out or restrict unwanted data from reaching your controller actions. For a primer on routing in ASP.NET Core, you can refer to my previous article on attribute-based routing versus convention-based routing in ASP.NET Core. This article goes beyond the basics to explore the advanced operations using route constraints.

    To work with the code examples provided in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here .

    To read this article in full, please click here


    Značky: #Rozne, #C#

    • chevron_right

      How to manage user secrets in ASP.NET Core

      pubsub.slavino.sk / infoworldcom · Monday, 28 September, 2020 - 10:00 edit

    When working with ASP.NET web applications, you will want to protect certain pieces of application data, called user secrets, that should not be shared with others. Your user secrets might include a database connection string that also contains the user ID and the password for the database. You might also want to refrain from sharing information such as access keys, API keys, and connection information details for cloud services such as Azure or AWS.

    However, when you share your project with others this secret information also will be shared. How can we prevent this? A feature in ASP.NET Core named User Secrets allows you to store user secrets outside your project tree in a JSON file, and can even be managed using a command-line tool called the Secrets Manager. This article talks about how you can work with the User Secrets API in ASP.NET Core.

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • chevron_right

      How to use immutability in C#

      Joydip Kanjilal · pubsub.slavino.sk / infoworldcom · Monday, 29 June, 2020 - 10:00 edit

    Immutability is a feature of functional programming languages that makes programs easier to write, test, and maintain. However, immutability is not supported by many imperative programming languages. Until recently, C# did not support immutability out-of-the-box.

    That changes with the introduction of records in C# 9, which is available for preview in .NET 5 . However, we can implement immutability in earlier versions of C# by using the System.Collections.Immutable namespace, which is available as a NuGet package.

    [ Also on InfoWorld: What’s new in Microsoft .NET 5? ]

    An immutable object is defined as an object that cannot be changed after it has been created. For many use cases, such as Data Transfer Objects , immutability is a desirable feature. This article discusses why we might want to take advantage of immutability and how we can implement immutability in C#.

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • chevron_right

      What’s new in Microsoft .NET 5

      Paul Krill · pubsub.slavino.sk / infoworldcom · Friday, 26 June, 2020 - 22:12 edit

    Microsoft has published a sixth preview of .NET 5 . Preview 6 removes WinRT support, adds support for Windows Forms on Windows ARM64 devices, and continues to extend RyuJIT code quality improvements.

    Microsoft has said that .NET 5 would be feature-complete by Preview 7. .NET 5 is a merger of .NET Framework and .NET Core that is intended to unify the .NET platform. The new platform is due for general availability November 10, 2020.

    [ Also on InfoWorld: The best free programming courses during quarantine ]

    High-level goals for .NET 5 include providing a unified .NET SDK experience, with a single BCL (base class library) across all .NET 5 applications, and with support for both native and web applications across multiple operating systems. A single .NET 5 native application project would support targets such as Windows, Microsoft Duo (Android), and Apple iOS using native controls on those platforms.

    To read this article in full, please click here


    Značky: #C#, #Rozne