Just Simply Code

Another developer blog

  • Home
  • About
  • Register
  • Policy

Generics

Generic abstract class implementing another generic class and multiple interfaces with constraint

11 September 2022 / Leave a Comment

In one of my recent projects, I needed to create a new generic abstract class which implements another generic class and a couple other interfaces. I also needed to restrict the generic type in this generic abstract class to a specific type This is not something I commonly need to do so I was not … [Read more…]

Posted in: Uncategorised Tagged: .Net Core, Generics

Dynamically call an async generic method using Reflection

10 May 2020 / Leave a Comment

In the last post, I showed how to dynamically get an instance of the generic type from DI container. In this post, I’m going to show how to call a generic method from that instance of the generic type dynamically using Reflection. From the last post, this is what the generic interface looks like I’m … [Read more…]

Posted in: Uncategorised Tagged: .Net Core, Generics, Reflection

Dynamically getting generic type from DI container

26 April 2020 / Leave a Comment

I have a generic interface called IConverter which accepts one type of object and returns a different type. There are many different implementations of this interface and they are all registered in the DI container (see last post on how to automatically register all implementations of a generic interface in DI container). However, where this … [Read more…]

Posted in: Uncategorised Tagged: .Net Core, Dependency Injection, Generics

Generic key based factory

6 July 2019 / Leave a Comment

I often find myself adding some sort factory in almost every project I’ve ever worked on. Let’s say we have a pizza price checker factory that returns a validator to check if the price is valid based on a particular type of pizza. It would look something like below However, if you have other similar … [Read more…]

Posted in: Uncategorised Tagged: Factories, Generics

Search Posts

Recent Posts

  • Override IHttpRequestBodyDetectionFeature.CanHaveBodyOverride value in .NET Core Web API
  • Allow empty request body in PUT and POST HTTP requests in .NET Core Web API
  • Modify request body with middleware in .NET Core Web API
  • Running MS Orleans on AWS ECS
  • Respect leading and trailing spaces when querying SQL Server
Support my blog here!Support my blog!

Archives

  • July 2024
  • June 2024
  • July 2023
  • April 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • October 2017
  • September 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • July 2016
  • June 2016
  • March 2016
  • February 2016
  • January 2016

Copyright © 2025 Just Simply Code.

Me WordPress Theme by themehall.com