Skip to content

Instantly share code, notes, and snippets.

View nikaburu's full-sized avatar

Herman Starzhynski nikaburu

  • Dublin, Ireland
View GitHub Profile
@shanselman
shanselman / Dockerfile
Last active November 10, 2023 19:17
Smarter ASP.NET Core Docker File
FROM microsoft/dotnet:2.0-sdk as builder
RUN mkdir -p /root/src/app/aspnetcoreapp
WORKDIR /root/src/app/aspnetcoreapp
#copy just the project file over
# this prevents additional extraneous restores
# and allows us to resuse the intermediate layer
# This only happens again if we change the csproj.
# This means WAY faster builds!
@jennings
jennings / WcfExtensibilityPoints.md
Last active September 26, 2020 06:09
I can never remember how to extend WCF in the ways that I want.

A good summary of all the extensibility points: https://blogs.msdn.microsoft.com/carlosfigueira/2011/03/14/wcf-extensibility/

Doing stuff before/after calls

Use IOperationInvoker if you need to do "runtime-y" things, such as replacing the current SynchronizationContext (perhaps with one that restores OperationContext after an await...).

But! You can only apply an IOperationInvoker from an IOperationBehavior, not from a IServiceBehavior. If you try to assign an operation invoker from a service behavior, WCF will eventually just overwrite it. If you want to apply an IOperationInvoker to every operation in a contract, you can write an IServiceBehavior which applies the IOperationBehavior to every operation.

You can have an attribute which can apply to a whole service, or to a single operation:

@jand187
jand187 / Generic builder with extensions
Last active November 3, 2021 18:14
Generic builder with extensions
public class GenericBuilder<TEntity> where TEntity : new()
{
private readonly List<Func<TEntity, object>> setters;
public GenericBuilder()
{
setters = new List<Func<TEntity, object>>();
}
public GenericBuilder<TEntity> With(params Func<TEntity, object>[] props)