Country tag helper–part 1


What I want to do is to create a Country Tag Helper for core.

Something like

<select asp-country=”true”

and then list all countries in this select. More, it should be localized ( Germany vs Allemagne). That means 1 or more resource files 


First I need initial data: The WorldBank API gives us the names and I have made a project that inspects that API.

To retrieve data in resource format , it is simple:

 var r = new CountriesRepository();
            var arr = r.GetCountries().Result.
                Select(it =>
                $"<data name = \"{it.iso2Code}\" xml:space=\"preserve\" >" +

                $"<value>{}</value>" +
            var s = string.Join(Environment.NewLine, arr);
            File.WriteAllText(@"D:\c.txt", s);


Then we could copy paste into resources:

 <data name = "AW" xml:space="preserve" ><value>Aruba</value></data>
  <data name = "AF" xml:space="preserve" ><value>Afghanistan</value></data>
  <data name = "AO" xml:space="preserve" ><value>Angola</value></data>


Now I want to make a list of those names – so I need this code to translate between C# generated code from resource

public static string AD {
            get {
                return ResourceManager.GetString("AD", resourceCulture);
public static string AE {
            get {
                return ResourceManager.GetString("AE", resourceCulture);


and a list of names to be put into select.

Reflection to the rescue:

  var t =typeof( ResCTH);
            properties= t.GetProperties(
                BindingFlags.Public |
                BindingFlags.Static |
            CountryISO = properties
                .Select(it => it.Name)


The code is on github and I will improve next time.

Friday links 226

  1. Top 15 Underutilized Features of .NET
  2. Top 15 Underutilized Features of .NET Part 2
  3. Louis Davidson : Getting the difference between two sets of like data
  4. App-vNext/Polly: Polly is a .NET 3.5 / 4.0 / 4.5 / PCL library that allows developers to express transient exception handling policies such as Retry, Retry Forever, Wait and Retry or Circuit Breaker in a fluent manner.
  5. dbelmont/ExpressionBuilder
  6. Youtube Downloader in One Easy Class – CodeProject
  7. Career Guide for the New Developer
  8. Harvard psychologist Amy Cuddy says people judge you on 2 criteria – Business Insider
  9. StructureMap – Supported Lifecycles
  10. Jquery Ajax Request and MVC detailed « A Programmer with Microsoft tools
  11. Friendly, Readable Expression Trees
  12. 18F — Software maintenance is an anti-pattern
  13. Getting Started with Bower – Treehouse Blog
  14. NuGet Package of the Week: ASP.NET Web API Caching with CacheCow and CacheOutput – Scott Hanselman
  15. Less Than Dot – Blog – MVVM Validation with KnockoutJS – Don’t put it in the View/HTML
  16. WEIRD – RationalWiki
  17. C# 7 Feature Proposal: Local Functions – Bill Wagner
  18. Dubai is set to unveil spectacular floating apartments with underwater rooms
  19. Software has bugs. This is normal. — Signal v. Noise — Medium
  20.    Visual Studio: How to create a solution template with multiple projects – Jayway
  21. Avoiding the Service Locator Pattern in ASP.NET Core
  22. Service Locator is an Anti-Pattern
  23. Service Locator violates SOLID
  24. Service Locator violates encapsulation
  25. Service Locator: roles vs. mechanics
  26. Suremaker/LightBDD: Lightweight Behavior Driven Development test framework
  27. John L. Miller’s answer to Google: How does Google provide so much online storage for Youtube videos? – Quora
  28. John L. Miller’s answer to What is the best way to read software documentation? – Quora

    Making any call to a function of an object thread safe



    I was wondering how to modify old code to support threads /task .

    So I was making a small project about making any function of an object thread safe.

    NuGet Package at :

    The solution contain tests and 2 console project for .NET Core and .NET Framework 4.5.1

    The usage is pretty easy

    Let’s say you have this

    Calculation c = new Calculation();

    And you want


    to be thread safe

    In the Package Manager Console write:

    Install-Package ThreadSafeObject

    Then modify your code to:

    Calculation c = new Calculation();
    dynamic ts = new ThreadSafe(c);

    It is a toy project- however, it has tests to prove it is correct.

    You can download the code source from

    PowerBI custom visualization–part 2




    Now I wanted to give a try of each new visualization.  There are 89 visualization on .

    I have played with last of them – without R integrations – 24 – and the .pbix file can be downloaded from!Aordxu1LWKDZgopsf3vS3IZx2UHOgQ  – you need just PowerBI Desktop.

    The visualizations are















    You can see here:

    The model item passed into the dictionary is of type ‘[]’ , but this dictionary requires a model item of type ‘[]’


    I am tired of how many times I found this question on forums. So , if  you encounter this error

    The model item passed into the dictionary is of type ‘xxx’, but this dictionary requires a model item of type ‘yyy’

    with the variation

    The model item passed into the dictionary is of type ‘xxx’, but this dictionary requires a model item of type ‘System.Collections.Generic.IEnumerable`1[xxx]’

    then read on.

    ASP.NET MVC is plain and simple. The user enters an url in the browser. A Controller class is made from this request and an Action answer to the url request . The Action   gathers a Model from business logic and gives the Model to the View. The View has a Model also and generates HTML from the Model  .


    Now let’s get to the code .

    The action looks like

    public ActionResult MyAction(parameters){

    MyModelClassNameFromTheAction modelAction =   // gathers the Model –

    return View(modelAction)


    The View looks like:

    @model MyModelClassNameFromTheView

    ….( html from the MyModelFromTheView )


    If the 2 class names ( including namespaces) are not the same( and   MyModelClassNameFromTheAction  does not inherit from  , then the error occurs. Practically , MVC is saying : How can I match the 2 classes ?



    Usually, you change the Action.

    1. You may have inadvertently return the wrong view from the Action. Solution: return View(“~/<folders>/another razor.cshtml”) .

    2.  You may have inadvertently return the wrong model . Solution :Solution: return View(another model.) . E.g. the View has as Model  IeNumerable<Model> and in the action you

    return Model. The solution is changing

    return View(Model)


    return View( new[](Model));

    Friday links 223

    1. Testing With a Fake DbContext |
    2. {Dev}School Program – ING Romania
    3. Getting Started Guide | Visa Developer
    4. BitomatiQE_ContinuousIntegration #30 Console [Jenkins]
    5. kzu/NuDoq: A standalone API to read .NET XML documentation files and optionally augment it with reflection information.
    6. daattali/beautiful-jekyll: Build a beautiful and simple website in literally minutes. Demo at
    7. ES6 Arrow Functions: The New Fat & Concise Syntax in JavaScript
    8. ExportData
    9. "Let’s Encrypt" Azure Web Apps the Free and Easy Way | GoorooThink Tech News | Articles | Skills Analytics | Gooroo
    10. Momentum – Chrome Web Store
    11. Writing Tests doesn’t have to be extra work – Evangelism – Blog
    12. Development With A Dot – Encoded JavaScript in ASP.NET MVC Core
    13. Hypertext Transfer Protocol (HTTP) Status Code Registry
    14. Write code that is easy to delete, not easy to… — programming is terrible
    15. jstedfast/MailKit: A cross-platform .NET library for IMAP, POP3, and SMTP.
    16. Capitalism Promotes Equality | Foundation for Economic Education
    17. 100 Insanely Interesting People You Should Know — Unmistakable Creative — Medium
    18. Windowing Functions: Tell me when that changes. – SQLServerCentral
    19. 10 Tips for Mobile Photography
    20. Tutorial: Server Broadcast with SignalR 2 | The ASP.NET Site
    21. Nick Craver – Stack Overflow: The Architecture – 2016 Edition
    22. Oracle JET – Data Visualizations
    23. How Just Opening an MS Word Doc Can Hijack Every File On Your System