예제 #1
0
        internal static RefStructsRoxor CreateRefStruct()
        {
            RefStructsRoxor rsrxr = new RefStructsRoxor(false);

            if (!rsrxr.IsValid)
            {
                throw new InvalidOperationException();
            }
            return(rsrxr);
        }
예제 #2
0
        public static bool DoBadStuffWithStruct()
        {
            RefStructsRoxor badNaughty         = CreateDisposableRefStruct();
            bool            wasValid           = badNaughty.IsValid;
            bool            wasDisposedAtFirst = badNaughty.IsValid;

            Console.WriteLine($@"badNaughty was valid at first: {wasValid}.");
            Console.WriteLine($@"badNaughty was disposed at first: {wasDisposedAtFirst}.");
            badNaughty.Dispose();
            bool isValidAfterDispose    = badNaughty.IsValid;
            bool isDisposedAfterDispose = badNaughty.IsDisposed;

            Console.WriteLine($@"badNaughty was valid after Dispose: {isValidAfterDispose}.");
            Console.WriteLine($@"badNaughty was disposed after Dispose: {isDisposedAfterDispose}.");

            return(wasValid && !wasDisposedAtFirst && !isValidAfterDispose && isDisposedAfterDispose);
        }
예제 #3
0
 public static RefStructsRoxor CreateDisposableRefStruct() => RefStructsRoxor.CreateRefStruct();