I'm coding an MVC internet application and there is a question regarding lazy initialization.
My work code before lazy initialization:
Announcement:
Personal Validation Service Verification Service;
Start:
Verification Service = New Verification Service (Normal Multiplayer Repository);
I'm trying this code:
Announcement:
Private idle < Validation Services & gt; ValidationService;
Start:
Verification service = new lazy & lt; Validation Services & gt; (General multiplayer repository);
Here is an error:
Error 125 is the best overloaded method matching for System.Lazy.Lazy (System.Threading.LazyThreadSafetyMode) is invalid Logic
I have seen, but I do not know what is wrong.
The lazy constructor is expected to Func
which validation service
specifies:
verification service = new lazy and lieutenant; ValidationService & gt; (() = & Gt; New Verification Service (Generic repository));
This would be equivalent:
verification service = new lazy & lt; Validation Services & gt; (Some method); Personal Legalization Service Some Methods () {Return the New Verification Service (this.genericMultipleRepository); }
Note that you can not pass the parameter genericMultipleRepository
as if it is assumed using a lambda expression.
No comments:
Post a Comment