public static IDataChunk[] ReadFrom(string fileName, Type type, object[] args) { ArrayList list; if (fileName == null) { throw new ArgumentNullException("fileName"); } if (fileName == string.Empty) { throw new ArgumentException("fileName"); } if (!File.Exists(fileName)) { throw new FileNotFoundException(Powerasp.Enterprise.Core.SR.FileNotFound, fileName); } if (type == null) { throw new ArgumentNullException("type"); } FileStream input = null; BinaryReader reader = null; if (args == null) { args = new object[0]; } Type[] types = ReflectionUtil.ConvertTo(args); ConstructorInfo constructor = type.GetConstructor(types); if (constructor == null) { throw new ArgumentException("type"); } try { input = File.OpenRead(fileName); reader = new BinaryReader(input); list = new ArrayList(); while (input.Position != input.Length) { IDataChunk chunk = constructor.Invoke(args) as IDataChunk; if (chunk == null) { throw new InvalidCastException(""); } chunk.ReadData(reader); list.Add(chunk); } } finally { if (reader != null) { try { reader.Close(); } catch { } reader = null; } if (input != null) { try { input.Close(); } catch { } input = null; } } return((IDataChunk[])list.ToArray(typeof(IDataChunk))); }