我正在创建一个可以从 dicom 文件中读取的类。这基本上是一个包含大量对象的二进制文件。我想创建一个可以做到这一点的实体类。所以我设计了以下。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Medicom
{
public class DDocument : IEnumerable<DDataElement>
{
/// <summary>
/// Creates a new DDocument from a file.
/// </summary>
/// <param name="path">The path of the file to load </param>
/// <returns>An DDocument that contains the Dicom information from the file</returns>
public static DDocument Load(string path)
{
return DDocument.Load(new FileStream(path, FileMode.Open));
}
/// <summary>
/// Creates a new XDocument instance by using the specified stream.
/// </summary>
/// <param name="stream">The stream that contains the Dicom information.</param>
/// <returns>An DDocument that contains the Dicom information from the stream.</returns>
public static DDocument Load(Stream stream)
{
//Logic here to read the whole stream and List<DDataElement> Data with all the data
}
/// <summary>
/// Gets or sets a list with MetaInformation containing DDataElements
/// </summary>
public List<DDataElement> Data
{
get;
set;
}
/// <summary>
/// Returns an enumerator that can be used to iterate through the DDocument
/// </summary>
/// <returns>An IEnumerator that can be used to iterate through the DDocument</returns>
public IEnumerator<DDataElement> GetEnumerator()
{
foreach (DDataElement dataElement in Data)
{
yield return dataElement;
}
}
}
}
我想知道你是怎么想的。你会在这门课上做出什么改变吗?