Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'LibGit2Sharp/Core/Compat/Lazy.cs')
-rw-r--r--LibGit2Sharp/Core/Compat/Lazy.cs54
1 files changed, 0 insertions, 54 deletions
diff --git a/LibGit2Sharp/Core/Compat/Lazy.cs b/LibGit2Sharp/Core/Compat/Lazy.cs
deleted file mode 100644
index 2f08a24a..00000000
--- a/LibGit2Sharp/Core/Compat/Lazy.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Diagnostics;
-
-namespace LibGit2Sharp.Core.Compat
-{
- /// <summary>
- /// Provides support for lazy initialization.
- /// </summary>
- /// <typeparam name="TType">Specifies the type of object that is being lazily initialized.</typeparam>
- [DebuggerStepThrough]
- public class Lazy<TType>
- {
- private readonly Func<TType> evaluator;
- private TType value;
- private bool hasBeenEvaluated;
- private readonly object padLock = new object();
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Lazy{TType}"/> class.
- /// </summary>
- /// <param name="evaluator">The <see cref="Func{TResult}"/> that will be called to evaluate the value of this Lazy instance.</param>
- public Lazy(Func<TType> evaluator)
- {
- Ensure.ArgumentNotNull(evaluator, "evaluator");
-
- this.evaluator = evaluator;
- }
-
- /// <summary>
- /// Gets the lazily initialized value of the current instance.
- /// </summary>
- public TType Value
- {
- get { return Evaluate(); }
- }
-
- private TType Evaluate()
- {
- if (!hasBeenEvaluated)
- {
- lock (padLock)
- {
- if (!hasBeenEvaluated)
- {
- value = evaluator();
- hasBeenEvaluated = true;
- }
- }
- }
-
- return value;
- }
- }
-}