Exemplo n.º 1
0
        private static void Reset()
        {
            ActiveWorld world = FlexUtility.DeserializeToObject(_savedState) as ActiveWorld;

            List <InstancePair> correspondings;
            List <Instance>     removedInstances;
            List <Instance>     newInstances;

            List <Instance> newChildren = new List <Instance>();
            List <Instance> oldChildren = new List <Instance>();

            LoadResetInstanceHelper(_context.ActiveWorld.World, world.World, newChildren, oldChildren);

            newInstances     = newChildren.Where(x => !oldChildren.Any(y => x.Equals(y))).ToList();
            removedInstances = oldChildren.Where(x => !newChildren.Any(y => x.Equals(y))).ToList();
            correspondings   = oldChildren.Join(newChildren, x => x, y => y, (x, y) =>
            {
                return(new InstancePair(x, y));
            }).ToList();

            foreach (Instance newInstance in newInstances)
            {
                newInstance.Cleanup();
            }

            foreach (Instance removedInstance in removedInstances)
            {
                /*
                 * Implement
                 */
            }

            foreach (InstancePair instancePair in correspondings)
            {
                ObjectSave save = new ObjectSave(instancePair.Old, instancePair.Current, instancePair.Current.GetType());
                save.Reset();
                try
                {
                    InstancePair oldParent = correspondings.Where(x => x.Old.equals(instancePair.Old.parent)).FirstOrDefault();
                    if (oldParent != null && oldParent.Current != null)
                    {
                        instancePair.Current.parent = oldParent.Current;
                    }
                }
                catch { }
                instancePair.Current.Reload();
            }

            ResetInstance(world.Sky, _context.ActiveWorld.Sky);
        }
Exemplo n.º 2
0
 public bool NextInstanceExists()
 {
     try {
         rwLockTabBar.AcquireWriterLock(-1);
         while (sdInstancePair.Count > 0)
         {
             IntPtr       ptr;
             InstancePair pair = sdInstancePair.Peek(out ptr);
             if (((pair.tabBar != null) && pair.tabBar.IsHandleCreated) && (PInvoke.IsWindow(pair.hwnd) && PInvoke.IsWindow(ptr)))
             {
                 return(true);
             }
             sdInstancePair.Pop();
         }
     }
     finally {
         rwLockTabBar.ReleaseWriterLock();
     }
     return(false);
 }
Exemplo n.º 3
0
        private void VerifyEquality(EqualitySpecifications spec, BinaryCompareDelegate comparer, MethodInfo methodInfo, InstancePair pair)
        {
            bool actual   = comparer(pair.First, pair.Second);
            bool expected = !(pair.AreEquivalent ^ spec.ExpectedEquality);

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(expected, actual),
                                    innerFailures => new AssertionFailureBuilder(
                                        "The equality comparison between left and right values did not produce the expected result.")
                                    .AddRawLabeledValue("Left Value", pair.First)
                                    .AddRawLabeledValue("Right Value", pair.Second)
                                    .AddRawLabeledValue("Expected Result", expected)
                                    .AddRawLabeledValue("Actual Result", actual)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }
Exemplo n.º 4
0
        private void VerifyComparison <TResult>(ComparisonSpecifications <TResult> spec, ComparerDelegate <TResult> comparer, MethodInfo methodInfo, InstancePair pair)
        {
            string actual   = spec.FormatResult(comparer(pair.First, pair.Second));
            string expected = spec.FormatResult(spec.AdjustExpectedEquivalence(pair.Equivalence));

            AssertionHelper.Explain(() =>
                                    Assert.AreEqual(expected, actual),
                                    innerFailures => new AssertionFailureBuilder("The comparison between left and right values did not produce the expected result.")
                                    .AddRawLabeledValue("Left Value", pair.First)
                                    .AddRawLabeledValue("Right Value", pair.Second)
                                    .AddRawLabeledValue("Expected Result", expected)
                                    .AddRawLabeledValue("Actual Result", actual)
                                    .SetStackTrace(Context.GetStackTraceData())
                                    .AddInnerFailures(innerFailures)
                                    .ToAssertionFailure());
        }