public void SendEnums(MyColor color, MyFlags flags)
 {
     if (IsEnabled())
     {
         WriteEvent(1, (int)color, (int)flags);
     }
 }                                                                                                               // Cast enums to int for efficient logging.
예제 #2
0
        public void Ex1_Enum()
        {
            MyFlags f1 = MyFlags.Flag1 | MyFlags.Flag2 | MyFlags.Flag3;

            if ((f1 & MyFlags.Flag1) == MyFlags.Flag1)
            {
                Console.WriteLine("Flag f1: {0}", f1);
            }

            if ((f1 & MyFlags.Flag2) == MyFlags.Flag2)
            {
                Console.WriteLine("Flag f2: {0}", f1);
            }

            if ((f1 & MyFlags.Flag3) == MyFlags.Flag3)
            {
                Console.WriteLine("Flag f3: {0}", f1);
            }

            if ((f1 & MyFlags.Flag4) == MyFlags.Flag4)
            {
                Console.WriteLine("Flag f4: {0}", f1);
            }

            Console.WriteLine("Flag raw: {0}", (byte)f1);
        }
예제 #3
0
        static void Main(string[] args)
        {
            MyFlags fooBar = MyFlags.Foo | MyFlags.Bar | MyFlags.New;
            MyFlags newBar = MyFlags.New;

            if ((fooBar & MyFlags.Foo) == MyFlags.Foo)
            {
                Console.WriteLine("Item has Foo flag set");
            }
            if ((fooBar & MyFlags.Baz) == MyFlags.Baz)
            {
                //this will not be printed
                Console.WriteLine("Item has bar flag set");
            }
            if ((fooBar & MyFlags.New) == MyFlags.New)
            {
                //this will  be printed
                Console.WriteLine("Item has new flag set");
            }
            if ((newBar & MyFlags.New) == MyFlags.New)
            {
                //this will  be printed

                Console.WriteLine("Item has new flag  again set");
            }
        }
예제 #4
0
    static void Main(string[] args)
    {
        MyFlags flags = MyFlags.Foo | MyFlags.Baz;
        MyFlags isBar = MyFlags.Bar & flags;

        Console.WriteLine(isBar);
    }
예제 #5
0
        static void Main(string[] args)
        {
            MyFlags flag = MyFlags.A | MyFlags.B;

            Console.WriteLine(flag.IsFlagSet(MyFlags.A));
            Console.WriteLine(EnumExtensions.IsFlagSet(flag, MyFlags.C));
            Console.ReadLine();
        }
    static void Main(string[] args)
    {
        MyFlags fooBar = MyFlags.Foo | MyFlags.Bar;

        if (fooBar.HasFlag(MyFlags.Foo))
        {
            Console.WriteLine("Item has Foo flag set");
        }
    }
예제 #7
0
    public static void Main()
    {
        MyFlags fooBar = MyFlags.Foo | MyFlags.Bar;

        if (fooBar.HasFlag(MyFlags.Foo))
        {
            Console.WriteLine("Item has Foo flag set");
        }
        DoSomething(MyFlags.Bar | MyFlags.Baz);
    }
예제 #8
0
 public static void CheckFlags(MyFlags flags)
 {
     if (flags.HasFlag(MyFlags.Foo))
     {
         Console.WriteLine("Item has Foo flag set");
     }
     if (flags.HasFlag(MyFlags.Bar))
     {
         Console.WriteLine("Item has Bar flag set");
     }
     if (flags.HasFlag(MyFlags.Baz))
     {
         Console.WriteLine("Item has Baz flag set");
     }
 }
예제 #9
0
 public static void DoSomething(MyFlags flags)
 {
     if (flags.HasFlag(MyFlags.Foo))
     {
         DoFoo();
     }
     if (flags.HasFlag(MyFlags.Bar))
     {
         DoBar();
     }
     if (flags.HasFlag(MyFlags.Baz))
     {
         DoBaz();
     }
 }
예제 #10
0
        static void Main(string[] args)
        {
            MyFlags myFlag = MyFlags.Flag2;

            if ((myFlag & MyFlags.Flag2) == MyFlags.Flag2)
            {
                Console.WriteLine("true");
            }
            if ((myFlag & MyFlags.Flag3) == MyFlags.Flag3)

            {
                Console.WriteLine("true");
            }
            Console.ReadKey();
        }
예제 #11
0
        async Task Run(MyFlags flags, Type expectedException = null, ClientAndServerParameters parameters = null, Action <ClientAndServer> action = null)
        {
            if (parameters == null)
            {
                parameters = GetDefaultParameters();
            }

            try {
                if (Configuration.EnableDebugging)
                {
                    parameters.EnableDebugging = true;
                }
                using (var connection = (ClientAndServer)await Factory.Start(parameters)) {
                    if (action != null)
                    {
                        action(connection);
                    }
                    var handler = new MyConnectionHandler(connection, flags);
                    await handler.Run();
                }
                if (expectedException != null)
                {
                    Assert.Fail("Expected an exception of type {0}", expectedException);
                }
            } catch (Exception ex) {
                if (expectedException != null)
                {
                    Assert.That(ex, Is.InstanceOf(expectedException));
                }
                else
                {
                    DebugHelper.WriteLine("ERROR: {0} {1}", ex.GetType(), ex);
                    throw;
                }
            }
        }
 public void SendEnumsEvent16(MyColor a, MyFlags b)
 {
     this.WriteEvent(3, a, b);
 }
 public void SendEnumsEvent17(MyColor a, MyFlags b)
 {
     this.WriteEvent(5, (int)a, (int)b);
 }
예제 #14
0
        static void Main(string[] args)
        {
            int?a = 4;
            int?b = 5;
            int?c = Convert.ToInt32(Convert.ToString(21, 8));

            Console.WriteLine(a ?? b ?? c);
            Console.WriteLine(a.GetType().ToString());
            Console.WriteLine(c.GetType().ToString());


            ShowAttributes(typeof(Program));
            ShowAttributes(typeof(MyFlags));

            MyFlags flag = new MyFlags();

            flag = MyFlags.Black | MyFlags.Blue | MyFlags.Red;
            Console.WriteLine(flag.ToString());

            Console.WriteLine(RuntimeEnvironment.GetSystemVersion());

            Console.WriteLine(Environment.OSVersion.Version.Major);
            #region
            // int[] source = { 1,2,3,4,5,6,7,8,9,10};
            // int[] dest=new int[source.Length];
            // Array.Copy(source, dest, 3);
            // foreach (var item in dest)
            // {
            //     Console.WriteLine(item);
            // }
            // Console.WriteLine("\n\n");
            // Array.ForEach(source, item => Console.WriteLine(item));
            //var modByThree= Array.FindAll(source, (item) => item % 3 == 0);
            //Array.ForEach(modByThree, item => Console.WriteLine(item));



            //int[][] jag ={
            //                 new[]{1,2,3},
            //                 new[]{3,4,6}
            //             };
            //Console.WriteLine(jag.ToString());
            #endregion


            #region

            //int testCount = 20;
            //Stopwatch sw;
            //// 二维数组
            //int[,] a2Dim = new int[ElementCount, ElementCount];

            ////二维的数组的竖着
            //int[][] aJagged=new int[ElementCount][];
            //for (int i = 0; i <aJagged.GetUpperBound(0); i++)
            //{
            //    aJagged[i]=new int[ElementCount];
            //}

            ////1、使用安全方法访问所有数组元素
            //sw = Stopwatch.StartNew();
            //for (int i = 0; i < testCount; i++)
            //{
            //    SafeDimArrayAccess(a2Dim);
            //}
            //Console.WriteLine("使用安全方法访问数组用时" + sw.Elapsed);

            ////2、使用交错数组访问所有数组元素
            //sw = Stopwatch.StartNew();
            //for (int i = 0; i < testCount; i++)
            //{
            //    SafeJaggedArrayAccess(aJagged);
            //}
            //Console.WriteLine("使用交错数组访问数组用时" + sw.Elapsed);


            ////3、使用不安全方法访问所有数组元素
            //sw = Stopwatch.StartNew();
            //for (int i = 0; i < testCount; i++)
            //{
            //    UnSafe2DimArrayAccess(a2Dim);
            //}
            //Console.WriteLine("使用不安全方法访问数组用时" + sw.Elapsed);

            #endregion


            #region
            //StackallocDemo();
            //InlineArrayDemo();
            #endregion

            #region
            Action action = null;
            action += new Action(Program.MyVoidNoneMethod1);
            action += new Action(Program.MyVoidNoneMethod2);
            action += Program.MyVoidNoneMethod2;
            action += new Action(new Program().MyInsMethod3);

            action.Invoke();
            var list = action.GetInvocationList();
            foreach (var item in list)
            {
                ((Action)item).Invoke();
                item.DynamicInvoke(null);
            }
            //Console.WriteLine(action.Target.ToString());
            Console.WriteLine(action.Method.Name);

            //action -= new Program().MyVoidNoneMethod1;
            //action -= new Action(new Program().MyVoidNoneMethod1);
            action  = (Action)Delegate.Remove(action, new Action(Program.MyVoidNoneMethod1));
            action -= new Action(new Program().MyInsMethod3);
            action.Invoke();
            var list2 = action.GetInvocationList();
            foreach (var item in list2)
            {
                ((Action)item).Invoke();
                item.DynamicInvoke(null);
            }
            //Console.WriteLine(action.Target.ToString());
            // Console.WriteLine(action.Method.Name);
            #endregion



            Console.WriteLine("over");
            Console.ReadLine();
        }
예제 #15
0
 public void SendEnumsEvent17(MyColor a, MyFlags b)
 {
     this.WriteEvent(5, (int)a, (int)b);
 }
예제 #16
0
 public void EventFlags(MyFlags x)
 {
     WriteEvent(21, (int)x);
 }
예제 #17
0
    public static void Main()
    {
        MyFlags e = MyFlags.C | MyFlags.D;

        switch (e)
        {
        case var t when e.HasFlag(MyFlags.C | MyFlags.D) && !e.HasFlag(MyFlags.A | MyFlags.B):
            Console.Out.WriteLine(t);

            break;

        case var t when e.HasFlag(MyFlags.A | MyFlags.B) && !e.HasFlag(MyFlags.C | MyFlags.D):
            Console.Out.WriteLine(t);

            break;

        case MyFlags.B:
        case MyFlags.A:
            Console.Out.WriteLine("A | B");
            break;

        case MyFlags.All:
            Console.Out.WriteLine("ALL");
            break;

        default:
            break;
        }

        string str = "2";

        switch (str)
        {
        case "1":
            Console.Out.WriteLine("Case 1");
            break;

        case "2":
            Console.Out.WriteLine("Case 2");
            break;
        }

        object obj = new String("");

        switch (obj)
        {
        case Array arr:
            break;

        case IEnumerable <int> ieInt:
            break;

        case IList lst:
            break;

        case String s:
            break;

        case null:
            break;

        default:
            break;
        }
    }
 public static MyFlags A(this MyFlags myFlags)
 {
     return(myFlags | MyFlags.A);
 }
예제 #19
0
 public void EventFlags(MyFlags x) { WriteEvent(20, (int)x); }
예제 #20
0
 public MyConnectionHandler(IClientAndServer connection, MyFlags flags)
     : base(connection.Server, connection.Client)
 {
     Flags = flags;
 }
예제 #21
0
 public static int FlagsZeroParameter(MyFlags param1 = 0)
 {
     Assert.Equal(MyFlags.Zero, param1);
     return(0);
 }
예제 #22
0
파일: AllTests.cs 프로젝트: mreinart/ice
        public static async Task RunAsync(TestHelper helper)
        {
            Communicator communicator = helper.Communicator;

            var proxy = ITestIntfPrx.Parse(helper.GetTestProxy("test", 0), communicator);

            System.IO.TextWriter output = helper.Output;

            output.Write("testing enum values... ");
            output.Flush();

            TestHelper.Assert((int)ByteEnum.benum1 == 0);
            TestHelper.Assert((int)ByteEnum.benum2 == 1);
            TestHelper.Assert((int)ByteEnum.benum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ByteEnum.benum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ByteEnum.benum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum7 == Constants.IntConst1);
            TestHelper.Assert((int)ByteEnum.benum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum9 == Constants.LongConst1);
            TestHelper.Assert((int)ByteEnum.benum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum11 == Constants.ByteConst2);

            TestHelper.Assert((int)ShortEnum.senum1 == 3);
            TestHelper.Assert((int)ShortEnum.senum2 == 4);
            TestHelper.Assert((int)ShortEnum.senum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ShortEnum.senum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ShortEnum.senum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum7 == Constants.IntConst1);
            TestHelper.Assert((int)ShortEnum.senum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum9 == Constants.LongConst1);
            TestHelper.Assert((int)ShortEnum.senum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum11 == Constants.ShortConst2);

            TestHelper.Assert((int)IntEnum.ienum1 == 0);
            TestHelper.Assert((int)IntEnum.ienum2 == 1);
            TestHelper.Assert((int)IntEnum.ienum3 == Constants.ByteConst1);
            TestHelper.Assert((int)IntEnum.ienum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum5 == Constants.ShortConst1);
            TestHelper.Assert((int)IntEnum.ienum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum7 == Constants.IntConst1);
            TestHelper.Assert((int)IntEnum.ienum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum9 == Constants.LongConst1);
            TestHelper.Assert((int)IntEnum.ienum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum11 == Constants.IntConst2);
            TestHelper.Assert((int)IntEnum.ienum12 == Constants.LongConst2);

            TestHelper.Assert((int)SimpleEnum.red == 0);
            TestHelper.Assert((int)SimpleEnum.green == 1);
            TestHelper.Assert((int)SimpleEnum.blue == 2);

            output.WriteLine("ok");

            output.Write("testing enum operations... ");
            output.Flush();
            {
                (ByteEnum r, ByteEnum o) = proxy.OpByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.OpByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
            }

            {
                // 42 does not correspond to a ByteEnum enumerator, so we expect failure since ByteEnum is checked.
                try
                {
                    _ = proxy.OpByte((ByteEnum)42);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException) // unhandled dispatch exception
                {
                    // expected
                }
            }

            {
                (ByteEnum? r, ByteEnum? o) = proxy.OpTaggedByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.OpTaggedByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
                (r, o) = proxy.OpTaggedByte(null);
                TestHelper.Assert(r == null && o == null);
            }

            {
                try
                {
                    _ = proxy.OpTaggedByte((ByteEnum)42);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException) // unhandled dispatch exception
                {
                    // expected
                }
            }

            {
                (ShortEnum r, ShortEnum o) = proxy.OpShort(ShortEnum.senum1);
                TestHelper.Assert(r == ShortEnum.senum1 && o == ShortEnum.senum1);
                (r, o) = proxy.OpShort(ShortEnum.senum11);
                TestHelper.Assert(r == ShortEnum.senum11 && o == ShortEnum.senum11);
            }

            {
                (IntEnum r, IntEnum o) = proxy.OpInt(IntEnum.ienum1);
                TestHelper.Assert(r == IntEnum.ienum1 && o == IntEnum.ienum1);
                (r, o) = proxy.OpInt(IntEnum.ienum11);
                TestHelper.Assert(r == IntEnum.ienum11 && o == IntEnum.ienum11);
                (r, o) = proxy.OpInt(IntEnum.ienum12);
                TestHelper.Assert(r == IntEnum.ienum12 && o == IntEnum.ienum12);
            }

            {
                (SimpleEnum r, SimpleEnum o) = proxy.OpSimple(SimpleEnum.green);
                TestHelper.Assert(r == SimpleEnum.green && o == SimpleEnum.green);
            }

            {
                (FLByteEnum r, FLByteEnum o) = proxy.OpFLByte(FLByteEnum.benum1);
                TestHelper.Assert(r == FLByteEnum.benum1 && o == FLByteEnum.benum1);
                (r, o) = proxy.OpFLByte(FLByteEnum.benum11);
                TestHelper.Assert(r == FLByteEnum.benum11 && o == FLByteEnum.benum11);
            }

            {
                (FLByteEnum? r, FLByteEnum? o) = proxy.OpTaggedFLByte(FLByteEnum.benum1);
                TestHelper.Assert(r == FLByteEnum.benum1 && o == FLByteEnum.benum1);
                (r, o) = proxy.OpTaggedFLByte(FLByteEnum.benum11);
                TestHelper.Assert(r == FLByteEnum.benum11 && o == FLByteEnum.benum11);
                (r, o) = proxy.OpTaggedFLByte(null);
                TestHelper.Assert(r == null && o == null);
            }

            {
                (FLShortEnum r, FLShortEnum o) = proxy.OpFLShort(FLShortEnum.senum1);
                TestHelper.Assert(r == FLShortEnum.senum1 && o == FLShortEnum.senum1);
                (r, o) = proxy.OpFLShort(FLShortEnum.senum11);
                TestHelper.Assert(r == FLShortEnum.senum11 && o == FLShortEnum.senum11);
            }

            {
                (FLUShortEnum r, FLUShortEnum o) = proxy.OpFLUShort(FLUShortEnum.senum1);
                TestHelper.Assert(r == FLUShortEnum.senum1 && o == FLUShortEnum.senum1);
                (r, o) = proxy.OpFLUShort(FLUShortEnum.senum11);
                TestHelper.Assert(r == FLUShortEnum.senum11 && o == FLUShortEnum.senum11);
            }

            {
                (FLIntEnum r, FLIntEnum o) = proxy.OpFLInt(FLIntEnum.ienum1);
                TestHelper.Assert(r == FLIntEnum.ienum1 && o == FLIntEnum.ienum1);
                (r, o) = proxy.OpFLInt(FLIntEnum.ienum11);
                TestHelper.Assert(r == FLIntEnum.ienum11 && o == FLIntEnum.ienum11);
                (r, o) = proxy.OpFLInt(FLIntEnum.ienum12);
                TestHelper.Assert(r == FLIntEnum.ienum12 && o == FLIntEnum.ienum12);
            }

            {
                (FLUIntEnum r, FLUIntEnum o) = proxy.OpFLUInt(FLUIntEnum.ienum1);
                TestHelper.Assert(r == FLUIntEnum.ienum1 && o == FLUIntEnum.ienum1);
                (r, o) = proxy.OpFLUInt(FLUIntEnum.ienum11);
                TestHelper.Assert(r == FLUIntEnum.ienum11 && o == FLUIntEnum.ienum11);
                (r, o) = proxy.OpFLUInt(FLUIntEnum.ienum12);
                TestHelper.Assert(r == FLUIntEnum.ienum12 && o == FLUIntEnum.ienum12);
            }

            {
                (FLSimpleEnum r, FLSimpleEnum o) = proxy.OpFLSimple(FLSimpleEnum.green);
                TestHelper.Assert(r == FLSimpleEnum.green && o == FLSimpleEnum.green);
            }

            output.WriteLine("ok");

            output.Write("testing enum sequences operations... ");
            output.Flush();

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[] b3, ByteEnum[] b2) = proxy.OpByteSeq(b1);
                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));
            }

            {
                var b1 = new ByteEnum[12]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    (ByteEnum)42,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                try
                {
                    _ = proxy.OpByteSeq(b1);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException)
                {
                    // expected
                }
            }

            {
                var s1 = new ShortEnum[11]
                {
                    ShortEnum.senum1,
                    ShortEnum.senum2,
                    ShortEnum.senum3,
                    ShortEnum.senum4,
                    ShortEnum.senum5,
                    ShortEnum.senum6,
                    ShortEnum.senum7,
                    ShortEnum.senum8,
                    ShortEnum.senum9,
                    ShortEnum.senum10,
                    ShortEnum.senum11
                };

                (ShortEnum[] s3, ShortEnum[] s2) = proxy.OpShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var i1 = new IntEnum[11]
                {
                    IntEnum.ienum1,
                    IntEnum.ienum2,
                    IntEnum.ienum3,
                    IntEnum.ienum4,
                    IntEnum.ienum5,
                    IntEnum.ienum6,
                    IntEnum.ienum7,
                    IntEnum.ienum8,
                    IntEnum.ienum9,
                    IntEnum.ienum10,
                    IntEnum.ienum11
                };

                (IntEnum[] i3, IntEnum[] i2) = proxy.OpIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var s1 = new SimpleEnum[3]
                {
                    SimpleEnum.red,
                    SimpleEnum.green,
                    SimpleEnum.blue
                };

                (SimpleEnum[] s3, SimpleEnum[] s2) = proxy.OpSimpleSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var b1 = new FLByteEnum[11]
                {
                    FLByteEnum.benum1,
                    FLByteEnum.benum2,
                    FLByteEnum.benum3,
                    FLByteEnum.benum4,
                    FLByteEnum.benum5,
                    FLByteEnum.benum6,
                    FLByteEnum.benum7,
                    FLByteEnum.benum8,
                    FLByteEnum.benum9,
                    FLByteEnum.benum10,
                    FLByteEnum.benum11
                };

                (FLByteEnum[] b3, FLByteEnum[] b2) = proxy.OpFLByteSeq(b1);
                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));
            }

            {
                var s1 = new FLShortEnum[11]
                {
                    FLShortEnum.senum1,
                    FLShortEnum.senum2,
                    FLShortEnum.senum3,
                    FLShortEnum.senum4,
                    FLShortEnum.senum5,
                    FLShortEnum.senum6,
                    FLShortEnum.senum7,
                    FLShortEnum.senum8,
                    FLShortEnum.senum9,
                    FLShortEnum.senum10,
                    FLShortEnum.senum11
                };

                (FLShortEnum[] s3, FLShortEnum[] s2) = proxy.OpFLShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var s1 = new FLUShortEnum[11]
                {
                    FLUShortEnum.senum1,
                    FLUShortEnum.senum2,
                    FLUShortEnum.senum3,
                    FLUShortEnum.senum4,
                    FLUShortEnum.senum5,
                    FLUShortEnum.senum6,
                    FLUShortEnum.senum7,
                    FLUShortEnum.senum8,
                    FLUShortEnum.senum9,
                    FLUShortEnum.senum10,
                    FLUShortEnum.senum11
                };

                (FLUShortEnum[] s3, FLUShortEnum[] s2) = proxy.OpFLUShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var i1 = new FLIntEnum[11]
                {
                    FLIntEnum.ienum1,
                    FLIntEnum.ienum2,
                    FLIntEnum.ienum3,
                    FLIntEnum.ienum4,
                    FLIntEnum.ienum5,
                    FLIntEnum.ienum6,
                    FLIntEnum.ienum7,
                    FLIntEnum.ienum8,
                    FLIntEnum.ienum9,
                    FLIntEnum.ienum10,
                    FLIntEnum.ienum11
                };

                (FLIntEnum[] i3, FLIntEnum[] i2) = proxy.OpFLIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var i1 = new FLUIntEnum[11]
                {
                    FLUIntEnum.ienum1,
                    FLUIntEnum.ienum2,
                    FLUIntEnum.ienum3,
                    FLUIntEnum.ienum4,
                    FLUIntEnum.ienum5,
                    FLUIntEnum.ienum6,
                    FLUIntEnum.ienum7,
                    FLUIntEnum.ienum8,
                    FLUIntEnum.ienum9,
                    FLUIntEnum.ienum10,
                    FLUIntEnum.ienum11
                };

                (FLUIntEnum[] i3, FLUIntEnum[] i2) = proxy.OpFLUIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var s1 = new FLSimpleEnum[3]
                {
                    FLSimpleEnum.red,
                    FLSimpleEnum.green,
                    FLSimpleEnum.blue
                };

                (FLSimpleEnum[] s3, FLSimpleEnum[] s2) = proxy.OpFLSimpleSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[]? b3, ByteEnum[]? b2) = proxy.OpTaggedByteSeq(b1);
                TestHelper.Assert(b2 != null && b3 != null);

                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));

                (b3, b2) = proxy.OpTaggedByteSeq(null);
                TestHelper.Assert(b2 == null && b3 == null);
            }

            {
                var b1 = new ByteEnum[12]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    (ByteEnum)42,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                try
                {
                    _ = proxy.OpTaggedByteSeq(b1);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException)
                {
                    // expected
                }
            }

            {
                var b1 = new FLByteEnum[11]
                {
                    FLByteEnum.benum1,
                    FLByteEnum.benum2,
                    FLByteEnum.benum3,
                    FLByteEnum.benum4,
                    FLByteEnum.benum5,
                    FLByteEnum.benum6,
                    FLByteEnum.benum7,
                    FLByteEnum.benum8,
                    FLByteEnum.benum9,
                    FLByteEnum.benum10,
                    FLByteEnum.benum11
                };

                (FLByteEnum[]? b3, FLByteEnum[]? b2) = proxy.OpTaggedFLByteSeq(b1);
                TestHelper.Assert(b2 != null && b3 != null);

                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));

                (b3, b2) = proxy.OpTaggedFLByteSeq(null);
                TestHelper.Assert(b2 == null && b3 == null);
            }

            {
                var i1 = new FLIntEnum[11]
                {
                    FLIntEnum.ienum1,
                    FLIntEnum.ienum2,
                    FLIntEnum.ienum3,
                    FLIntEnum.ienum4,
                    FLIntEnum.ienum5,
                    FLIntEnum.ienum6,
                    FLIntEnum.ienum7,
                    FLIntEnum.ienum8,
                    FLIntEnum.ienum9,
                    FLIntEnum.ienum10,
                    FLIntEnum.ienum11
                };

                (FLIntEnum[]? i3, FLIntEnum[]? i2) = proxy.OpTaggedFLIntSeq(i1);
                TestHelper.Assert(i2 != null && i3 != null);

                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));

                (i3, i2) = proxy.OpTaggedFLIntSeq(null);
                TestHelper.Assert(i2 == null && i3 == null);
            }

            output.WriteLine("ok");

            output.Write("testing unchecked enums... ");
            output.Flush();
            {
                (MyFlags r, MyFlags f2) = proxy.OpMyFlags(MyFlags.E31);
                TestHelper.Assert(r == MyFlags.E31 && f2 == r);
                (r, f2) = proxy.OpMyFlags(MyFlags.E10 | MyFlags.E11);
                TestHelper.Assert(r == (MyFlags.E10 | MyFlags.E11) && f2 == r);
            }

            output.Flush();
            {
                (MyFlags? r, MyFlags? f2) = proxy.OpTaggedMyFlags(null);
                TestHelper.Assert(r == null && f2 == r);
                (r, f2) = proxy.OpTaggedMyFlags(MyFlags.E10 | MyFlags.E11);
                TestHelper.Assert(r == (MyFlags.E10 | MyFlags.E11) && f2 == r);
            }

            output.Flush();
            {
                var myFlagsSeq = new MyFlags[] { MyFlags.E10, MyFlags.E0, MyFlags.E5 | MyFlags.E6 };
                (MyFlags[] r, MyFlags[] f2) = proxy.OpMyFlagsSeq(myFlagsSeq);
                TestHelper.Assert(r.SequenceEqual(myFlagsSeq) && f2.SequenceEqual(myFlagsSeq));
            }

            output.Flush();
            {
                var myFlagsSeq = new MyFlags[] { MyFlags.E10, MyFlags.E0, MyFlags.E5 | MyFlags.E6 };
                (MyFlags[]? r, MyFlags[]? f2) = proxy.OpTaggedMyFlagsSeq(myFlagsSeq);
                TestHelper.Assert(r !.SequenceEqual(myFlagsSeq) && f2 !.SequenceEqual(myFlagsSeq));
            }

            output.WriteLine("ok");
            await proxy.ShutdownAsync();
        }
 public void SendEnumsEvent15(MyColor color, MyFlags flags) 
 {
     this.WriteEvent(15, (int)color, (int)flags);
 }
예제 #24
0
 public static void AddTo(this MyFlags add, ref MyFlags addTo)
 {
     addTo = addTo | add;
 }
예제 #25
0
 public void SendEnums(MyColor color, MyFlags flags) {
     if(IsEnabled())  
         WriteEvent(1, (int) color, (int) flags); 
 } // Cast enums to int for efficient logging.
예제 #26
0
 static extern void testmf3(MyFlags val);
예제 #27
0
			public MyConnectionHandler (IClientAndServer connection, MyFlags flags)
				: base (connection.Server, connection.Client)
			{
				Flags = flags;
			}
예제 #28
0
 public static MyFlags Add(this MyFlags me, MyFlags toAdd)
 {
     return(me | toAdd);
 }
예제 #29
0
 public void EventFlags1(MyFlags x) { WriteEvent(21, x); }
예제 #30
0
		async Task Run (MyFlags flags, Type expectedException = null, ClientAndServerParameters parameters = null, Action<ClientAndServer> action = null)
		{
			if (parameters == null)
				parameters = GetDefaultParameters ();

			try {
				if (Configuration.EnableDebugging)
					parameters.EnableDebugging = true;
				using (var connection = (ClientAndServer)await Factory.Start (parameters)) {
					if (action != null)
						action (connection);
					var handler = new MyConnectionHandler (connection, flags);
					await handler.Run ();
				}
				if (expectedException != null)
					Assert.Fail ("Expected an exception of type {0}", expectedException);
			} catch (Exception ex) {
				if (expectedException != null) {
					Assert.That (ex, Is.InstanceOf (expectedException));
				} else {
					DebugHelper.WriteLine ("ERROR: {0} {1}", ex.GetType (), ex);
					throw;
				}
			}
		}
예제 #31
0
 public void EventFlags1(MyFlags x)
 {
     WriteEvent(22, x);
 }
예제 #32
0
 public void SendEnumsEvent16(MyColor a, MyFlags b)
 {
     this.WriteEvent(3, a, b);
 }
예제 #33
0
 public static int FlagsTwoParameter(MyFlags param1)
 {
     Assert.Equal(MyFlags.Two, param1);
     return(0);
 }
예제 #34
0
 public string MyMethod(MyFlags enm)
 {
     return(((long)enm).ToString());
 }
예제 #35
0
 public void SendEnumsEvent15(MyColor color, MyFlags flags)
 {
     this.WriteEvent(15, (int)color, (int)flags);
 }
 public static MyFlags B(this MyFlags myFlags)
 {
     return(myFlags | MyFlags.B);
 }