public ControlFlowElementData this[CanBeNull] IControlFlowElement element]
 {
     set
     {
         if (element != null)
             this[element.Id] = value;
     }
     get { return element != null ? this[element.Id] : null; }
 }
Exemple #2
0
    public bool Equals(CanBeNull <T> that)
    {
        if (that.hasValue != this.hasValue)
        {
            return(false);
        }

        if (!hasValue)
        {
            return(true);
        }

        return(val.Equals(that.val));
    }
Exemple #3
0
    public static void Main()
    {
        CanBeNull <int> nint1 = CanBeNull <int> .NULL;
        CanBeNull <int> nint2 = new CanBeNull <int>(3);
        CanBeNull <int> nint3 = new CanBeNull <int>(5);

        Console.WriteLine("nint1: {0}", nint1);
        Console.WriteLine("nint2: {0}", nint2);
        Console.WriteLine("nint3: {0}", nint3);
        Console.WriteLine("nint1: {0}", nint1.GetValueOrDefault(-1));

        Console.WriteLine(nint1.Equals(null));
        Console.WriteLine(nint2.Equals(new CanBeNull <int>(3)));

        Console.WriteLine();

        Nullable <int> nnint1 = null;
        Nullable <int> nnint2 = new Nullable <int>(3);
        Nullable <int> nnint3 = new Nullable <int>(5);

        Console.WriteLine("nint1: {0}", nnint1);
        Console.WriteLine("nint2: {0}", nnint2);
        Console.WriteLine("nint3: {0}", nnint3);
        Console.WriteLine("nint1: {0}", nnint1.GetValueOrDefault(-1));

        Console.WriteLine(nnint1.Equals(null));
        Console.WriteLine(nnint2.Equals(new Nullable <int>(3)));

        Console.WriteLine();

        int?nnnint1 = null;
        int?nnnint2 = 3;
        int?nnnint3 = 5;

        Console.WriteLine("nint1: {0}", nnnint1);
        Console.WriteLine("nint2: {0}", nnnint2);
        Console.WriteLine("nint3: {0}", nnnint3);
        Console.WriteLine("nint1: {0}", nnnint1 ?? -1);

        Console.WriteLine(nnint1.Equals(null));
        Console.WriteLine(nnint2.Equals(new Nullable <int>(3)));
    }
 public void WorksWithReferenceTypes()
 {
     var x = new CanBeNull<string>("hello");
 }
 public void AssignsNullValueCorrectly()
 {
     const string input = "hello";
     var x = new CanBeNull<string>(input);
     Assert.That(x.Value, Is.SameAs(input));
 }
 public void AssignsNonNullValueCorrectly()
 {
     const string input = null;
     var x = new CanBeNull<string>(input);
     Assert.That(x.Value, Is.Null);
 }
Exemple #7
0
 public NullabilityAttributeMetadataNames GetMetadataNames()
 {
     return(new NullabilityAttributeMetadataNames(NotNull.GetFullMetadataName(), CanBeNull.GetFullMetadataName(),
                                                  ItemNotNull.GetFullMetadataName(), ItemCanBeNull.GetFullMetadataName()));
 }