Created
February 23, 2017 13:18
-
-
Save mterwoord/fed8ea6b4b210aa4366e8fdf4c3bfcec to your computer and use it in GitHub Desktop.
Conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using TerWoord.Framework.Contracts.JetBrains.Annotations; | |
namespace TerWoord.Framework | |
{ | |
[DebuggerDisplay("{Value}")] | |
public sealed class ValueContainer<T> | |
{ | |
public ValueContainer(T initialValue = default(T)) | |
{ | |
Value = initialValue; | |
} | |
public T Value | |
{ | |
get; | |
set; | |
} | |
public static implicit operator T([NotNull] ValueContainer<T> container) | |
{ | |
if (container == null) | |
{ | |
throw new ArgumentNullException(nameof(container)); | |
} | |
return container.Value; | |
} | |
public static implicit operator ValueContainer<T>(T value) | |
{ | |
return new ValueContainer<T>(value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment