How does TimeService for Ninject WCF Extensions work?

I have a .NET 4.0 WCF service that I am trying to configure for ninject. I downloaded the WCF extension for ninject and looked at the TimeService example. Everything looks quite simple, but I don’t see how ninject does its job correctly, since a constructor with a construction without parameters manually introduces a dependency.

 public TimeService()
    : this(new SystemClock())
{
}

public TimeService( ISystemClock systemClock )
{
    _systemClock = systemClock;
}

As far as I understand, this code will never use the ninject binding. The first constructor will call the second constructor if I have not provided any parameters. When in testing and I pass my object layout, the second constructor will be called. I am new to WCF and ninject, so I apologize if I am missing anything obvious!

Can anyone explain?

thank

+3
1

Ninject , . , Ninject ISystemClock, Ninject .

, , , , - . , ISystemClock , . , - ISystemClock, Ninject .

, SystemClock, , , , ISystemClock , , , SystemClock . Ninject , ISystemClock.

Edit

, , TimeService:

[ServiceBehavior( InstanceContextMode = InstanceContextMode.Single )]

, , - Ninject . , .

+2

Source: https://habr.com/ru/post/1772676/


All Articles