1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
- #pragma warning disable 0420
5
4
6
- // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
7
- //
8
- //
9
- //
10
5
// --------------------------------------------------------------------------------------
11
6
//
12
7
// A class that provides a simple, lightweight implementation of lazy initialization,
15
10
//
16
11
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
17
12
18
- using System . Runtime ;
19
- using System . Runtime . InteropServices ;
20
- using System . Security ;
13
+ #pragma warning disable 0420
14
+
21
15
using System . Diagnostics ;
16
+ using System . Runtime . ExceptionServices ;
17
+ using System . Runtime . InteropServices ;
22
18
using System . Runtime . Serialization ;
23
19
using System . Threading ;
24
- using System . Diagnostics . Contracts ;
25
- using System . Runtime . ExceptionServices ;
26
20
27
21
namespace System
28
22
{
@@ -155,7 +149,7 @@ internal static LazyHelper Create(LazyThreadSafetyMode mode, bool useDefaultCons
155
149
return new LazyHelper ( state ) ;
156
150
157
151
default :
158
- throw new ArgumentOutOfRangeException ( nameof ( mode ) , Environment . GetResourceString ( " Lazy_ctor_ModeInvalid" ) ) ;
152
+ throw new ArgumentOutOfRangeException ( nameof ( mode ) , SR . Lazy_ctor_ModeInvalid ) ;
159
153
}
160
154
}
161
155
@@ -167,7 +161,7 @@ internal static object CreateViaDefaultConstructor(Type type)
167
161
}
168
162
catch ( MissingMethodException )
169
163
{
170
- throw new MissingMemberException ( Environment . GetResourceString ( " Lazy_CreateValue_NoParameterlessCtorForT" ) ) ;
164
+ throw new MissingMemberException ( SR . Lazy_CreateValue_NoParameterlessCtorForT ) ;
171
165
}
172
166
}
173
167
@@ -329,7 +323,7 @@ private void ViaFactory(LazyThreadSafetyMode mode)
329
323
{
330
324
Func < T > factory = _factory ;
331
325
if ( factory == null )
332
- throw new InvalidOperationException ( Environment . GetResourceString ( " Lazy_Value_RecursiveCallsToValue" ) ) ;
326
+ throw new InvalidOperationException ( SR . Lazy_Value_RecursiveCallsToValue ) ;
333
327
_factory = null ;
334
328
335
329
_value = factory ( ) ;
@@ -464,7 +458,7 @@ private void OnSerializing(StreamingContext context)
464
458
/// </exception>
465
459
public override string ToString ( )
466
460
{
467
- return IsValueCreated ? Value . ToString ( ) : Environment . GetResourceString ( " Lazy_ToString_ValueNotCreated" ) ;
461
+ return IsValueCreated ? Value . ToString ( ) : SR . Lazy_ToString_ValueNotCreated ;
468
462
}
469
463
470
464
/// <summary>Gets the value of the Lazy<T> for debugging display purposes.</summary>
@@ -531,38 +525,38 @@ internal T ValueForDebugDisplay
531
525
internal sealed class System_LazyDebugView < T >
532
526
{
533
527
//The Lazy object being viewed.
534
- private readonly Lazy < T > m_lazy ;
528
+ private readonly Lazy < T > _lazy ;
535
529
536
530
/// <summary>Constructs a new debugger view object for the provided Lazy object.</summary>
537
531
/// <param name="lazy">A Lazy object to browse in the debugger.</param>
538
532
public System_LazyDebugView ( Lazy < T > lazy )
539
533
{
540
- m_lazy = lazy ;
534
+ _lazy = lazy ;
541
535
}
542
536
543
537
/// <summary>Returns whether the Lazy object is initialized or not.</summary>
544
538
public bool IsValueCreated
545
539
{
546
- get { return m_lazy . IsValueCreated ; }
540
+ get { return _lazy . IsValueCreated ; }
547
541
}
548
542
549
543
/// <summary>Returns the value of the Lazy object.</summary>
550
544
public T Value
551
545
{
552
546
get
553
- { return m_lazy . ValueForDebugDisplay ; }
547
+ { return _lazy . ValueForDebugDisplay ; }
554
548
}
555
549
556
550
/// <summary>Returns the execution mode of the Lazy object</summary>
557
551
public LazyThreadSafetyMode ? Mode
558
552
{
559
- get { return m_lazy . Mode ; }
553
+ get { return _lazy . Mode ; }
560
554
}
561
555
562
556
/// <summary>Returns the execution mode of the Lazy object</summary>
563
557
public bool IsValueFaulted
564
558
{
565
- get { return m_lazy . IsValueFaulted ; }
559
+ get { return _lazy . IsValueFaulted ; }
566
560
}
567
561
}
568
562
}
0 commit comments