本文整理汇总了C#中Surface.ParseContent方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.ParseContent方法的具体用法?C# Surface.ParseContent怎么用?C# Surface.ParseContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.ParseContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFile
public bool ReadFile(string FileName)
{
m_fileName = FileName;
FileInfo finfo = new FileInfo(m_fileName);
//is the file really there?
if (!finfo.Exists)
return false;
Surfaces = new List<Surface>();
string[] FileLines;
string fullFile;
//Use a read-only filestream in case we have any write conflicts
using (var fs = new FileStream(m_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var sr = new StreamReader(fs))
fullFile = sr.ReadToEnd();
FileLines = fullFile.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
FileLines = StripComments(FileLines);
int lineNum = 0;
this.Title = FileLines[0];//pull the title line, always the first
double.TryParse(FileLines[1], out Mach);//mach number is the second line
for( int i=2; i<5;i++)
{
double[] headerArgs = PullArgs(FileLines[i]);
if (headerArgs.Length == 3)
{
if (i == 2)//third line is the symmetry
{
IYSym = headerArgs[0];
IZSym = headerArgs[1];
ZSym = headerArgs[2];
}
else if (i == 3)//forth line is the reference sizes
{
Sref = headerArgs[0];
Cref = headerArgs[1];
Bref = headerArgs[2];
}
else if (i == 4)//fifth non-blank/non-comment line is C.G. locations
{
Xref = headerArgs[0];
Yref = headerArgs[1];
Zref = headerArgs[2];
}
}
}
//special for the optional CDp parameter, if we can parse it as a number, good, otherwise continue down to the surfaces
if (double.TryParse(FileLines[5], out CDp))
lineNum = 6;
else lineNum = 5;
List<int> KeyLines = new List<int>();
List<string> KeyWords = new List<string>();
for (int i = lineNum; i < FileLines.Length; i++)
{
if (FileLines[i].ToUpperInvariant().StartsWith("SURF"))
{
KeyLines.Add(i);
KeyWords.Add("SURF");
}
else if (FileLines[i].ToUpperInvariant().StartsWith("BODY"))
{
KeyLines.Add(i);
KeyWords.Add("BODY");
}
else if (FileLines[i].ToUpperInvariant().StartsWith("SECT"))
{
KeyLines.Add(i);
KeyWords.Add("SECT");
}
}
for( int i=0; i<KeyLines.Count; i++)
{
int length = i == KeyLines.Count-1 ? FileLines.Length - KeyLines[i] : KeyLines[i+1] - KeyLines[i];
string[] content = new string[length];
for( int j=0; j<content.Length; j++)
content[j] = FileLines[KeyLines[i]+j];
if(KeyWords[i] == "SURF")
{
//should have code somewhere to handle if the surfaces have the same name.
Surface surf = new Surface(content[1], this);
surf.ParseContent(content);
this.Surfaces.Add(surf);
}
else if(KeyWords[i] == "SECT")
{
Surface.Section sec = new Surface.Section(this.Surfaces[Surfaces.Count - 1]);
sec.ParseContent(content);
this.Surfaces[Surfaces.Count - 1].Sections.Add(sec);
//.........这里部分代码省略.........