private void AddNewSegment(object obj) { NewSegment.ToDoId = SelectedToDo.ActCode; NewSegment.UserId = CurrentUser.UserId; Type theType = NewSegment.GetType(); if (theType == typeof(ConstantTranTextSegment)) { NewSegment.SegmentType = "Constant"; var newSegment = NewSegment as ConstantTranTextSegment; newSegment.ConstantText = newSegment.ConstantText.Replace("'", "''"); model.InsertNewSegment(newSegment); } if (theType == typeof(UserInputTranTextSegment)) { NewSegment.SegmentType = "UserInput"; var newSegment = NewSegment as UserInputTranTextSegment; newSegment.InputLabel = newSegment.InputLabel.Replace("'", "''"); model.InsertNewSegment(newSegment); } if (theType == typeof(ToDoPropertyTranTextSegment)) { NewSegment.SegmentType = "ToDoProperty"; ((ToDoPropertyTranTextSegment)NewSegment).ToDoPropertyName = SelectedToDoProperty; model.InsertNewSegment(NewSegment as ToDoPropertyTranTextSegment); } TranTextSegments = GetUserTranTextSegments(); NewSegments = null; }
public Partition(long capacity, long count, int maxSegmentCapacity) { Debug.Assert(capacity >= 0); Debug.Assert(count >= 0); Debug.Assert(maxSegmentCapacity > 0); Debug.Assert(count <= capacity); Initialize(); Capacity = capacity; Count = count; MaxSegmentCapacity = maxSegmentCapacity; SegmentTable = new List <ISegment <T> >(); ISegment <T> NewSegment; long RemainingCapacity = capacity; long RemainingCount = count; int effectiveExtended; while (RemainingCapacity > MaxSegmentCapacity) { long SegmentCount = RemainingCount; if (SegmentCount > MaxSegmentCapacity) { SegmentCount = MaxSegmentCapacity; } NewSegment = CreateMaxCapacitySegment(); NewSegment.MakeRoom(0, (int)SegmentCount, out effectiveExtended); SegmentTable.Add(NewSegment); RemainingCapacity -= MaxSegmentCapacity; RemainingCount -= SegmentCount; } NewSegment = CreateSegment((int)RemainingCapacity); NewSegment.MakeRoom(0, (int)RemainingCount, out effectiveExtended); SegmentTable.Add(NewSegment); InitCache(); Debug.Assert(Capacity == capacity); Debug.Assert(Count == count); Debug.Assert(!IsValidPosition(0, 0, false) || IsValidPosition(0, 0, true)); Debug.Assert(!IsValidPosition(0, SegmentTable[0].Count + 1, true)); Debug.Assert(SegmentTable.Count > 0); Debug.Assert(SegmentTable[0].ToString() != null); // For code coverage. #if DEBUG AssertInvariant(); #endif }