예제 #1
0
 /// <summary>Reset a value if the specified discriminator is assigned</summary>
 public static void Reset(ref DiscriminatedUnion32 value, int discriminator)
 {
     if (value.Discriminator == discriminator)
     {
         value = default;
     }
 }
예제 #2
0
 /// <summary>Reset a value if the specified discriminator is assigned</summary>
 public static void Reset(ref DiscriminatedUnion32 value, int discriminator)
 {
     if (value.Is(discriminator))
     {
         value = default(DiscriminatedUnion32);
     }
 }
예제 #3
0
        public void BasicUsage()
        {
            DiscriminatedUnion32 union;

            union = new DiscriminatedUnion32(4, 42);
            Assert.True(union.Is(4));
            Assert.Equal(4, union.Discriminator);
            Assert.Equal(42, union.Int32);

            DiscriminatedUnion32.Reset(ref union, 3); // should do nothing
            Assert.True(union.Is(4));
            Assert.Equal(4, union.Discriminator);
            Assert.Equal(42, union.Int32);

            DiscriminatedUnion32.Reset(ref union, 4); // should reset
            Assert.False(union.Is(4));
            Assert.True(union.Is(0));
            //Assert.Equal(0, union.Discriminator);

            //union = new DiscriminatedUnion32(4, 42);

            //union = default;
            //Assert.True(union.Is(0));
            //Assert.Equal(0, union.Discriminator);
        }