本文整理汇总了C#中Options.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Options.Validate方法的具体用法?C# Options.Validate怎么用?C# Options.Validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options.Validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
///<summary>
/// Runs VB.DOC for the given project
/// </summary>
public override void Run()
{
IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
VBProject project = (VBProject)projectService.CurrentSelectedProject;
VBCompilerParameters compilerParameters = (VBCompilerParameters)project.ActiveConfiguration;
Options options = new Options();
string extension = compilerParameters.CompileTarget == CompileTarget.Exe ? ".dll" : ".exe";
options.AssemblyFile = Path.Combine(compilerParameters.OutputDirectory, compilerParameters.OutputAssembly) + extension;
ArrayList files = new ArrayList();
foreach(ProjectFile file in project.ProjectFiles) {
if(VBDOCConfigurationPanel.IsFileIncluded(file.Name, project)) {
files.Add(file.Name);
}
}
options.Files = (string[])files.ToArray(typeof(string));
options.GlobalImports = compilerParameters.Imports.Split(',');
options.OutputXML = compilerParameters.VBDOCOutputFile;
options.Prefix = compilerParameters.VBDOCCommentPrefix;
options.RootNamespace = compilerParameters.RootNamespace;
ArrayList referenceDirs = new ArrayList();
string mainDirectory = Path.GetDirectoryName(options.AssemblyFile);
foreach(ProjectReference projectFile in project.ProjectReferences) {
if(projectFile.ReferenceType == ReferenceType.Assembly) {
string referenceDir = Path.GetDirectoryName(projectFile.Reference);
if(referenceDir.ToLower() != mainDirectory.ToLower() && referenceDirs.Contains(referenceDir) == false) {
referenceDirs.Add(referenceDir);
}
}
}
StringCollection errors = options.Validate();
if(errors.Count > 0) {
string message = "";
foreach(string description in errors) {
message += description + "\n";
}
MessageBox.Show(message, "Invalid VB.DOC options", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
VBDOCRunner runner = new VBDOCRunner();
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(resolve);
GuiMessageRecipient messageRecipient = new GuiMessageRecipient();
try {
runner.RunVBDOC(options, messageRecipient);
} catch(Exception ex) {
MessageBox.Show("Documentation generation failed:\n" + ex.Message);
} finally {
messageRecipient.Finished();
AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(resolve);
}
}
示例2: MissingUsernameThrowsAnError
public void MissingUsernameThrowsAnError()
{
var options = new Options().Load(new[] { "scope", "url" });
Assert.That(() => options.Validate(), Throws.InstanceOf<Options.InvalidOptionsException>().And.Message.ContainsSubstring("username"));
}
示例3: MissingScopeThrowsAnError
public void MissingScopeThrowsAnError()
{
var options = new Options();
Assert.That(() => options.Validate(), Throws.InstanceOf<Options.InvalidOptionsException>().And.Message.ContainsSubstring("scope"));
}
示例4: AllArgumentsIsValid
public void AllArgumentsIsValid()
{
var options = new Options().Load(new[] { "scope", "url", "username", "password" });
Assert.That(() => options.Validate(), Throws.Nothing);
}
示例5: Main
static void Main(string[] args)
{
PlatformHacks.TrySetProcessName(ThisAssembly.Name);
Options options = new Options();
ICommandLineParser parser = new CommandLineParser();
//if (!Parser.ParseArguments(args, options, Console.Error))
if (!parser.ParseArguments(args, options, Console.Error))
{
Environment.Exit(EXIT_FAILURE);
}
if (!options.Validate())
{
Console.Error.WriteLine("Try '{0} --help' for more information.", ThisAssembly.Name);
Environment.Exit(EXIT_FAILURE);
}
if (options.Verbose)
{
Console.WriteLine(Heading.ToString());
Console.WriteLine();
}
// If the target path is not specified, the program simply list the content of the
// current directory; like dir or ls.
bool success;
if (string.IsNullOrEmpty(options.TargetPath))
{
if (options.Verbose)
{
success = ExecuteIterator(options, new DirectoryIterator.Delegate(FileSystemObjectPrinterVerbose), true);
}
else
{
success = ExecuteIterator(options, new DirectoryIterator.Delegate(FileSystemObjectPrinter), true);
}
}
else
{
success = ExecuteIterator(options,
new DirectoryIterator.Delegate(DirectoryBuilder), false);
}
#region Helper Code while running inside an IDE (uncomment when needed)
//Console.ForegroundColor = ConsoleColor.Green;
//Console.Write(">>>press any key<<<");
//Console.ResetColor();
//Console.ReadKey();
#endregion
Environment.Exit(success ? EXIT_SUCCESS : EXIT_FAILURE_CRITICAL);
}