.NET Core Xamarin Forms

InputTransparent vs IsEnabled in Xamarin Forms

One of the problems in Xamarin Forms is that it is not possible to setup the text colors of disabled elements (elements where IsEnabled property is set to false).
However you do not need to set the IsEnabled property to disable it, there is an alternative property called InputTransparent.
Setting InputTransparent to true (by default it is false) will effectively disable the control by not allowing the user to interact with it.

The only drawback is that there is no visual indicator that the control is disabled, however this can be achieved by manually changing the text or background color of the control when it is disabled in this way.

.NET .NET Core Programming

TIL: Double.Equals works with Double.NaN values

The .NET standard defines that the double value of NaN (Double.NaN) will never be equal to any other Double value, including itself.
In other words:

double first = Double.NaN;
double second = Double.NaN;
bool equal = first == second; // false;

However this does not hold for Double.Equals. Double.Equals checks for object 'Identity' and not object 'Equality'.

double first = Double.NaN;
double second = Double.NaN;
bool equal = first.Equals(second); // true;

This is in general a nice thing if you have a generic methods which rely on object equality. Object.Equals will work even for Double and Single types.

.NET Core

Listing all routes in ASP.NET Core application

It is pretty simple to list all routes configured in your ASP.NET Core application:

  1. Add Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider parameter to your Startup.Configure method.
  2. If you have not done so already also add the ILogger<Startup> parameter to Startup.Configure as well
  3. Loop through all action descriptor items in the IActionDescriptorCollectionProvider and display the log information

Here is an example Startup method:

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger log, Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider actionProvider)
        log.Log(LogLevel.Information, "Configuring application ...");

        /// .... configuration


        log.Log(LogLevel.Information, "Available routes:");
        var routes = actionProvider.ActionDescriptors.Items.Where(x => x.AttributeRouteInfo != null);
        foreach(var route in routes)
            log.Log(LogLevel.Debug, $"{route.AttributeRouteInfo.Template}");

        log.Log(LogLevel.Information, "... finished configuring application");