public static void Open(int collectionCount = 1) { SequentialModel <DataType> .Close(); SequentialModel <DataType> .IsOpened = true; #if LOG_DEBUG ClosableDebugger.Open(CLASSNAME); #endif// LOG_DEBUG ModelDisposer.Regist(typeof(SequentialModel <DataType>), SequentialModel <DataType> .Close); var colls = SequentialModel <DataType> .collections = new Collection[collectionCount]; for (int n = 0, cnt = colls.Length; n < cnt; ++n) { colls[n] = new Collection(n); } }
public static void Setup(IEnumerable <DataType> datas, int collectionIndex = 0, Condition cond = null, Comparison <DataType> sortComparer = null) { try { if (!SequentialModel <DataType> .IsOpened) { throw new Exception("not opened"); } if (null == datas) { throw new NullReferenceException("datas is null"); } var coll = SequentialModel <DataType> .GetCollection(collectionIndex); if (null == coll) { throw new ArgumentOutOfRangeException("invalid collectionIndex"); } var list = coll.__InternalAccessList(); var enumerator = datas.GetEnumerator(); while (enumerator.MoveNext()) { var data = enumerator.Current; if (null == data) { throw new NullReferenceException("data(element) is null"); } if (null == cond || cond(data)) { list.Add(data); } } if (null != sortComparer) { list.Sort(sortComparer); } } catch (Exception e) { string args = string.Format("{0}, {1}, {2}, {3}", ModelException.ToStringOrNull(datas), collectionIndex, ModelException.ToStringOrNull(cond), ModelException.ToStringOrNull(sortComparer)); ModelException me = new ModelException(CLASSNAME, "Setup", args, e); if (null != ModelException.ExceptHandler) { ModelException.ExceptHandler(me); } else { throw me; } } }