public MemoryIndexTest() { Snapshot snapshot = new Snapshot(); snapshot.StartTransaction(); ObjectValue object1 = snapshot.CreateObject(null); ObjectValue object2 = snapshot.CreateObject(null); snapshot.CommitTransaction(); variableA = VariableIndex.Create("a", 0); variableA2 = VariableIndex.Create("a", 0); variableB = VariableIndex.Create("b", 0); undefinedVariable = VariableIndex.CreateUnknown(0); fieldA = ObjectIndex.Create(object1, "a"); fieldA2 = ObjectIndex.Create(object1, "a"); fieldB = ObjectIndex.Create(object1, "b"); fieldInDifferentTree = ObjectIndex.Create(object2, "a"); undefinedField = ObjectIndex.CreateUnknown(object1); indexA = variableA.CreateIndex("a"); indexA2 = variableA.CreateIndex("a"); indexB = variableA.CreateIndex("b"); indexInDifferentTree = variableB.CreateIndex("a"); undefinedIndex = variableA.CreateUnknownIndex(); doubleIndex = indexA.CreateIndex("1"); indexInField = fieldA.CreateIndex("1"); }
/// <summary> /// Creates the merge operation for all fields of specified object. /// </summary> /// <param name="objectValue">The object value.</param> private void mergeObject(ObjectValue objectValue) { IObjectDescriptorBuilder builder = Factories.StructuralContainersFactories.ObjectDescriptorFactory.CreateObjectDescriptor(writeableStrucure, objectValue, null, ObjectIndex.CreateUnknown(objectValue)) .Builder(writeableStrucure); ContainerOperations collectVariables = new ContainerOperations(this, builder, builder.UnknownIndex, builder.UnknownIndex); foreach (Snapshot snapshot in sourceSnapshots) { IObjectDescriptor descriptor; if (snapshot.Structure.Readonly.TryGetDescriptor(objectValue, out descriptor)) { collectVariables.CollectIndexes(snapshot, builder.UnknownIndex, descriptor); builder.SetType(descriptor.Type); } else { collectVariables.SetUndefined(); } } collectVariables.MergeContainers(); writeableStrucure.SetDescriptor(objectValue, builder.Build(writeableStrucure)); }