本文整理汇总了C#中Parse.ParseFile方法的典型用法代码示例。如果您正苦于以下问题:C# Parse.ParseFile方法的具体用法?C# Parse.ParseFile怎么用?C# Parse.ParseFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse
的用法示例。
在下文中一共展示了Parse.ParseFile方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Parse myParser = new Parse();
string[] filenames = { "test1.cir", "multiparams.cir", "test2.cir", "test3.cir", "q2n222a.cir", "missing.cir", "nocircuit.cir",
"shortSubcircuit.cir", "bogusName.cir", "bogusparams1.cir", "firstLineCommentTest.cir",
"nameCharsTestFail.cir", "nameCharsTestPass.cir", "braceTest.cir" };
foreach( string filename in filenames )
{
try
{
ComponentInfo result = myParser.ParseFile(filename );
Console.WriteLine("Parsing file '{0}' found {1}",
filename, result.ToString() );
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("ParseFile( {0} ) error:", filename);
Console.WriteLine(e.Message);
}
}
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
示例2: bogusparams1
public void bogusparams1()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "bogusparams1.cir");
ComponentInfo result = new ComponentInfo();
var exception = Assert.Throws<Exception>(delegate
{
result = myParser.ParseFile(filename);
});
Assert.True(exception.Message.Contains("needs an equals sign"));
}
示例3: braceTest
public void braceTest()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "braceTest.cir");
ComponentInfo result = new ComponentInfo();
var exception = Assert.Throws<Exception>(delegate
{
result = myParser.ParseFile(filename);
});
Assert.True(exception.Message.Contains("brace-expression parameter"));
}
示例4: shortSubcircuit
public void shortSubcircuit()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "shortSubcircuit.cir");
ComponentInfo result = new ComponentInfo();
var exception = Assert.Throws<Exception>(delegate
{
result = myParser.ParseFile(filename);
});
Assert.True(exception.Message.Contains("Not enough fields"));
}
示例5: bogusName
public void bogusName()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "bogusName.cir");
ComponentInfo result = new ComponentInfo();
var exception = Assert.Throws<Exception>(delegate
{
result = myParser.ParseFile(filename);
});
Assert.True(exception.Message.Contains("not a valid model name"));
}
示例6: nameCharsTestPass
public void nameCharsTestPass()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "nameCharsTestPass.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "AaBbCXxYyZz!#$%[0189]_",
elementType = 'X',
parameters = new Dictionary<String, String>()
{
},
pins = new List<string>()
{
"1",
"2"
}
};
Assert.True(result.Equals(expected));
}
示例7: missing
public void missing()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "missing.cir");
ComponentInfo result = new ComponentInfo();
var exception = Assert.Throws<Exception>(delegate
{
result = myParser.ParseFile(filename);
});
Assert.True(exception.Message.Contains("does not exist"));
}
示例8: q2n222a
public void q2n222a()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "q2n222a.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "Q2N222A",
elementType = 'Q',
parameters = new Dictionary<String, String>()
{
},
pins = new List<string>()
{
"COLLECTOR",
"BASE",
"EMITTER"
}
};
Assert.True(result.Equals(expected));
}
示例9: firstLineCommentTest
public void firstLineCommentTest()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "firstLineCommentTest.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "RES_2ndLineComponent",
elementType = 'X',
parameters = new Dictionary<String, String>()
{
},
pins = new List<string>()
{
"1",
"2"
}
};
Assert.True(result.Equals(expected));
}
示例10: multiparams
public void multiparams()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "multiparams.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "RES_MP",
elementType = 'X',
parameters = new Dictionary<String, String>()
{
{"RVAL", "1.0k"},
{"LVAL", "800pH"}
},
pins = new List<string>()
{
"1",
"2"
}
};
Assert.True(result.Equals(expected));
}
示例11: test3
public void test3()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "test3.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "RES_0603_330",
elementType = 'R',
parameters = new Dictionary<String, String>()
{
},
pins = new List<string>()
{
"PIN1",
"PIN2"
}
};
Assert.True(result.Equals(expected));
}
示例12: test2
public void test2()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "test2.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "DB9",
elementType = 'X',
parameters = new Dictionary<String, String>()
{
},
pins = new List<string>()
{
"PIN1",
"PIN2",
"PIN3",
"PIN4",
"PIN5",
"PIN6",
"PIN7",
"PIN8",
"PIN9"
}
};
Assert.True(result.Equals(expected));
}
示例13: test01
public void test01()
{
Parse myParser = new Parse();
string filename = Path.Combine(Path_TestModels, "L_LINEAR.cir");
ComponentInfo result = myParser.ParseFile(filename);
ComponentInfo expected = new ComponentInfo()
{
name = "L_LINEAR",
elementType = 'X',
parameters = new Dictionary<String, String>()
{
{"Inductance", "10e-6"},
{"Rs", "0.01"},
{"Cp", "2e-12"},
{"Rp", "300e3"},
},
pins = new List<string>()
{
"1",
"2"
}
};
Assert.True(result.Equals(expected));
}
示例14: ImportSpiceModel
public void ImportSpiceModel(CyPhy.Component component, String path_SpiceFile = null)
{
ComponentInfo ci = new ComponentInfo();
Boolean ownLogger = false;
if (Logger == null)
{
ownLogger = true;
Logger = new CyPhyGUIs.GMELogger(component.Impl.Project, "SpiceModelImport");
}
if (path_SpiceFile == null)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.CheckFileExists = true;
ofd.DefaultExt = "*.cir";
ofd.Multiselect = false;
ofd.Filter = "CIR (*.cir)|*.cir|All files (*.*)|*.*";
DialogResult dr = ofd.ShowDialog();
if (dr == DialogResult.OK)
{
path_SpiceFile = ofd.FileName;
}
else
{
Logger.WriteError("No file was selected. SPICE Model Import will not complete.");
if (ownLogger)
{
Logger.Dispose();
Logger = null;
}
return;
}
}
if (String.IsNullOrWhiteSpace(path_SpiceFile))
{
Logger.WriteError("SPICE Model Path of \"{0}\" isn't valid.", path_SpiceFile);
if (ownLogger)
{
Logger.Dispose();
Logger = null;
}
return;
}
}
try
{
Parse myParse = new Parse();
ci = myParse.ParseFile(path_SpiceFile);
}
catch( Exception e )
{
Logger.WriteError("Error parsing '{0}': {1}", path_SpiceFile, e.Message);
if (ownLogger)
{
Logger.Dispose();
Logger = null;
}
return;
}
//-----------------------------------------------------------------------------------
//
// At this point, the SPICE model file has been parsed and component info extracted.
//
// 'ci' has the SPICE component information.
// 'component' is the GME component that the SPICE info will be added to.
// 'path_SpiceFile' is the complete path and filename of the ".CIR" file.
//
//------------------------------------------------------------------------------------
//// Clean up the classifications.
//// This doesn't really belong here; it's just temporary to fix components on 4/1/2014.
//string[] sArray = component.Attributes.Classifications.Replace( "/", ".").Split( '.' );
//int sArrayLength = sArray.GetLength(0);
//string s = "";
//for (int i = 0; i < sArrayLength; i++)
//{
// string ss = sArray[i].ToLower().Trim().Replace( ' ', '_');
// ss = ss.Replace("(", "").Replace(")", "");
// s += ss.Replace( "_&_", "_and_" );
// if (i + 1 < sArrayLength)
// {
// s += ".";
// }
//}
//component.Attributes.Classifications = s;
// Find the visual coordinates of where the new SPICE model should be placed.
getNewModelInitialCoordinates(component, out m_startX, out m_startY);
//.........这里部分代码省略.........