// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#if NET_4_0 || BOOTSTRAP_NET_4_0
+#if NET_4_0
using System;
return EnsureInitialized (ref target, GetDefaultCtorValue<T>);
}
- public static T EnsureInitialized<T> (ref T target, Func<T> initFunc) where T : class
+ public static T EnsureInitialized<T> (ref T target, Func<T> valueFactory) where T : class
{
- Interlocked.CompareExchange (ref target, initFunc (), null);
+ if (target == null)
+ Interlocked.CompareExchange (ref target, valueFactory (), null);
return target;
}
- public static T EnsureInitialized<T> (ref T target, ref bool initialized, ref object syncRoot)
+ public static T EnsureInitialized<T> (ref T target, ref bool initialized, ref object syncLock)
{
- return EnsureInitialized (ref target, ref initialized, ref syncRoot, GetDefaultCtorValue<T>);
+ return EnsureInitialized (ref target, ref initialized, ref syncLock, GetDefaultCtorValue<T>);
}
- public static T EnsureInitialized<T> (ref T target, ref bool initialized, ref object syncRoot, Func<T> initFunc)
+ public static T EnsureInitialized<T> (ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
{
- lock (syncRoot) {
+ lock (syncLock) {
if (initialized)
return target;
initialized = true;
- return target = initFunc ();
+ return target = valueFactory ();
}
}
+ "public, parameterless constructor.");
}
}
+
+ internal static T GetDefaultValueFactory<T> ()
+ {
+ return default (T);
+ }
}
}
#endif