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; } } }