Skip to content

Tag: NoBrainer

C#/.NET 0

[NoBrainer] Simplifying and Speeding Up Testing in Sparx Enterprise Architect

Today’s post will be rather quick. I will show you how a unit/integration test class that can interact with real model data in Sparx Enterprise Architect. Beyond the well known Interop.EA assembly there is another assembly called SparxSystems.Repository that provides the intersting feature to connect to a running EA instance: Services.GetRepository(). We can use this to write unit/integration tests that […]

C#/.NET 0

Getting Instance by Type Name in StructureMap

Ever since we are using StructureMap we are also using this as a cheap replacement for Managed Extensibility Framework (MEF), as it allows us to scan arbitrary assembly paths for additional types to inject. As we are also dealing with configuration sections where we specify which plugins or types we want to use in a specific environment, we are tasked […]

C#/.NET 0

[NoBrainer] Cascading Lambda Expression in C#

While Converting ODataQueryOptions into LINQ Expressions I needed to cascade different Lambda Expressions via AND and OR. In this post I describe a way on how to easily combine them via a boxing class with operator overriding. The Problem Cascading lambda expressions should be as easy as using a + or && operator: A boxing class However, as by default […]

C#/.NET 0

[NoBrainer] C# and IEnumerable.ForEach

By default we cannot use ForEach() on IEnumerable but only on List. However, with extension methods to the rescue, it is easy to roll your own: Regarding the implementation I saw a few options: I could implement ForEach() with a traditional for loop, parallelise the operation, use ToList() to convert the list or other LINQ extensions such as Any() and […]

PowerShell 0

[NoBrainer] Start-Sleep takes longer that it seems

While doing some tests with our new TraceListener and log server I did some tests where I wanted to find out how long the log server would take to start accepting messages. So I started to constantly send messages from the console: When I looked at the server logs I noticed that the arriving messages came in unusually slow. So […]

PowerShell 0

[NoBrainer] Getting constructor information with PowerShell 5 easily

Before PowerShell 5 we had to revert to reflection to be able to display constructor information in PowerShell (see Get-Constructor Fun for details). And because we used that functionality so often we created a Cmdlet Get-Constructor that is part of our biz.dfch.PS.System.Utilities module. However with PowerShell 5 this is obsolete as it is now built into the language and runtime […]

PowerShell 0

[NoBrainer] Avoiding Concurrency Exceptions when working with a DataServiceContext in PowerShell

When working with a DataServiceContext from PowerShell you might run into concurrency update situations after updating entities via SaveChanges. This is due to the behaviour of the DataServiceContext ChangeTracker which will not reflect changes performed by the server (as a result of our update operation). Let me illustrate this with a quick example: Suppose we have a Catalogue entity where […]

C#/.NET 0

[NoBrainer] PUT/PATCH/MERGE with OData Service Client

Visual Studio supports the generation of data service clients (Service references) for OData services. A data service client is a .NET class that contains methods for accessing the OData service and gets generated based on the metadata provided by the OData service. The client acts as a proxy and translates the method calls into HTTP requests. Mike Wasson describes in […]