File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
src/System.Linq.Dynamic.Core/Compatibility Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . Threading ;
2+
3+ #if NET35
4+ namespace System
5+ {
6+ internal class Lazy < T >
7+ {
8+ private readonly Func < T > _valueFactory ;
9+ private readonly object _lock ;
10+
11+ private T ? _value ;
12+ private bool _valueCreated ;
13+
14+ public Lazy ( Func < T > valueFactory , LazyThreadSafetyMode mode )
15+ {
16+ _valueFactory = valueFactory ;
17+ _lock = new object ( ) ;
18+ }
19+
20+ public T Value
21+ {
22+ get
23+ {
24+ lock ( _lock )
25+ {
26+ if ( _valueCreated )
27+ {
28+ return _value ! ;
29+ }
30+
31+ _value = _valueFactory ( ) ;
32+ _valueCreated = true ;
33+ return _value ;
34+ }
35+ }
36+ }
37+
38+ }
39+ }
40+ #endif
Original file line number Diff line number Diff line change 1+ namespace System . Threading
2+ {
3+ internal enum LazyThreadSafetyMode
4+ {
5+ None ,
6+ PublicationOnly ,
7+ ExecutionAndPublication ,
8+ }
9+ }
You can’t perform that action at this time.
0 commit comments