private void InitializeLocationsIfNecessary() { if (Locations == null) { Locations = new LazinatorDictionary <T, LazinatorList <WInt32> >(); } }
private LazinatorDictionary <WInt32, Example> GetDictionary() { LazinatorDictionary <WInt32, Example> d = new LazinatorDictionary <WInt32, Example>(); for (int i = 0; i < dictsize; i++) { d[i] = GetTypicalExample(); } return(d); }
public void CanAccessCopiedItemAfterEnsureUpToDate() { LazinatorDictionary <WInt32, Example> d = GetDictionary(); d.SerializeLazinator(); // OwnedMemory for this and d[0] share allocation ID of 0. As the original source, this will not be automatically disposed. Example e = d[0]; d[0] = GetTypicalExample(); d.SerializeLazinator(); // allocation ID 0 is not disposed. var x = e.MyChild1; }
public void CloneWithoutBuffer_LazinatorDictionary() { LazinatorDictionary <WInt32, Example> GetDictionary() { LazinatorDictionary <WInt32, Example> d = new LazinatorDictionary <WInt32, Example>(); d[23] = GetExample(1); d[0] = GetExample(2); return(d); } VerifyCloningEquivalence(() => GetDictionary()); }
private void LazinateLocations() { if (LazinatorMemoryStorage.Length == 0) { _Locations = null; } else { LazinatorMemory childData = GetChildSlice(LazinatorMemoryStorage, _Locations_ByteIndex, _Locations_ByteLength, null); _Locations = DeserializationFactory.Instance.CreateBaseOrDerivedType(211, (c, p) => new LazinatorDictionary <T, LazinatorList <WInt32> >(c, p), childData, this); } _Locations_Accessed = true; }
public void ObjectDisposedExceptionAvoidedByCloneToIndependentBuffer() { LazinatorDictionary <WInt32, Example> d = GetDictionary(); d[0].SerializeLazinator(); // OwnedMemory has allocation ID of 0. d.SerializeLazinator(); // OwnedMemory for this and d[0] share allocation ID of 1 Example e = d[0].CloneLazinatorTyped(IncludeChildrenMode.IncludeAllChildren, CloneBufferOptions.IndependentBuffers); d[0] = GetTypicalExample(); d.SerializeLazinator(); // allocation ID 1 disposed. Action a = () => { var x = e.MyChild1; }; a.Should().NotThrow <ObjectDisposedException>(); }
public void ObjectDisposedExceptionThrownOnItemRemovedFromHierarchy() { LazinatorDictionary <WInt32, Example> d = GetDictionary(); //same effect if both of the following lines are included //d.UpdateStoredBuffer(); //d[0].MyChar = 'q'; d[0].SerializeLazinator(); // OwnedMemory has allocation ID of 0. d.SerializeLazinator(); // OwnedMemory for this and d[0] share allocation ID of 1 Example e = d[0]; d[0] = GetTypicalExample(); d.LazinatorMemoryStorage.Dispose(); Action a = () => { var x = e.MyChild1.LazinatorMemoryStorage.SingleMemoryChunk.ReadOnlyMemory; }; // note that error occurs only when looking at underlying memory a.Should().Throw <ObjectDisposedException>(); }