示例#1
0
        private int disp5(MyDisposable d, MyDisposable d2)
        {
            try
            {
                using (d)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                using (d2)
                {
                    try {
                        if (d2 != null)
                        {
                            return(0);
                        }

                        return(1);
                    }
                    finally
                    {
                        d2.finallyVisited = true;
                    }
                }
            }
            finally
            {
                d.finallyVisited = true;
            }
        }
示例#2
0
        public void test1()
        {
            var d = new MyDisposable();
            var r = disp(d);

            AssertEquals("Result not correct", 0, r);
            AssertTrue("Disposed not called", d.disposed);
        }
示例#3
0
        public void test1()
        {
            var d = new MyDisposable();
            var r = disp(d);

            AssertEquals("Result not correct", 0, r);
            AssertTrue("Disposed not called", d.disposed);
        }
示例#4
0
        public void test4()
        {
            var d = new MyDisposable();
            var r = disp4(d);

            AssertEquals("Result not correct", 0, r);
            AssertTrue("Disposed not called", d.disposed);
            AssertTrue("Finally not called", d.finallyVisited);
        }
示例#5
0
        public void _test4()
        {
            var d = new MyDisposable();
            var r = disp4(d);

            AssertEquals("Result not correct", 0, r);
            AssertTrue("Disposed not called", d.disposed);
            AssertTrue("Finally not called", d.finallyVisited);
        }
示例#6
0
        private int disp(MyDisposable d)
        {
            using (d)
            {
                if (d != null)
                    return 0;

                return 1;
            }
        }
示例#7
0
        public void _test5()
        {
            var d = new MyDisposable();
            var d2 = new MyDisposable();
            var r = disp5(d, d2);

            AssertEquals("Result not correct", 0, r);
            AssertTrue("Disposed not called", d.disposed);
            AssertTrue("Disposed (2) not called", d2.disposed);
            AssertTrue("Finally not called", d.finallyVisited);
        }
示例#8
0
        public void test3()
        {
            var d  = new MyDisposable();
            var d2 = new MyDisposable();
            var r  = disp3(d, d2);

            AssertEquals("Result not correct", 0, r);
            AssertTrue("Disposed not called", d.disposed);
            AssertTrue("Disposed (2) not called", d2.disposed);
            AssertTrue("Finally not called", d.finallyVisited);
        }
示例#9
0
        private int disp(MyDisposable d)
        {
            using (d)
            {
                if (d != null)
                {
                    return(0);
                }

                return(1);
            }
        }
示例#10
0
        private int disp2(MyDisposable d)
        {
			try 
			{
				using (d)
				{
					if (d != null)
						return 0;

					return 1;
				}
			} 
			finally
			{
				d.finallyVisited = true;
			}
        }
示例#11
0
        private int disp2(MyDisposable d)
        {
            try
            {
                using (d)
                {
                    if (d != null)
                    {
                        return(0);
                    }

                    return(1);
                }
            }
            finally
            {
                d.finallyVisited = true;
            }
        }
示例#12
0
 private int disp4(MyDisposable d)
 {
     try
     {
         d.finallyVisited = false;
         using (d)
         {
             throw new ArgumentException();
         }
         return(1);
     }
     catch (ArgumentException)
     {
         return(0);
     }
     finally
     {
         d.finallyVisited = true;
     }
 }
示例#13
0
        private int disp3(MyDisposable d, MyDisposable d2)
        {
            using (d)
            {
                try {
                    if (d != null)
                    {
                        return(0);
                    }

                    return(1);
                }
                finally
                {
                    d.finallyVisited = true;
                    using (d2)
                    {
                        d2.finallyVisited = true;
                    }
                }
            }
        }
示例#14
0
        private int disp3(MyDisposable d, MyDisposable d2)
        {
			using (d)
			{
				try {
					if (d != null)
						return 0;

					return 1;
				} 
				finally 
				{
					d.finallyVisited = true;
					using (d2)
					{
						d2.finallyVisited = true;
					}
				}
			}
        }
示例#15
0
        private int disp5(MyDisposable d, MyDisposable d2)
        {
			try
			{
				using (d)
				{
					throw new Exception();
				}
			}
			catch (Exception)
			{
				using (d2)
				{
					try {
						if (d2 != null)
							return 0;

						return 1;
					} 
					finally 
					{
						d2.finallyVisited = true;
					}
				}
			}
			finally 
			{
				d.finallyVisited = true;
			}
        }
示例#16
0
        private int disp4(MyDisposable d)
        {
			try
			{
				d.finallyVisited = false;
				using (d)
				{
					throw new ArgumentException();
				}
				return 1;
			}
			catch (ArgumentException)
			{
				return 0;
			}
			finally 
			{
				d.finallyVisited = true;
			}
        }