本文整理汇总了C#中CompilationFlags.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# CompilationFlags.HasFlag方法的具体用法?C# CompilationFlags.HasFlag怎么用?C# CompilationFlags.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompilationFlags
的用法示例。
在下文中一共展示了CompilationFlags.HasFlag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static CmdLineCompilerContext Create(string sourcePath, CompilationFlags flags)
{
string outputFile;
IEmitter emitter;
if (flags.HasFlag(CompilationFlags.Assembly))
{
outputFile = Path.ChangeExtension(sourcePath, "il");
emitter = new TextEmitter(outputFile);
}
else
{
outputFile = Path.ChangeExtension(sourcePath, "exe");
emitter = new PeEmitter(outputFile, flags);
}
Stream inputFile = File.Open(sourcePath, FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(inputFile);
return new CmdLineCompilerContext(sourcePath, inputFile, reader, emitter, flags);
}
示例2: TryParseArgs
private static bool TryParseArgs(string[] args, out string sourceFile, out CompilationFlags flags)
{
sourceFile = null;
flags = 0;
if (args.Length < 1)
return false;
foreach (string arg in args)
{
string normalizedArg = arg.ToUpper();
switch (normalizedArg)
{
case "/32":
flags |= CompilationFlags.Platform32;
break;
case "/64":
flags |= CompilationFlags.Platform64;
break;
case "/NODEBUG":
flags |= CompilationFlags.NoDebug;
break;
case "/ASM":
flags |= CompilationFlags.Assembly;
break;
default:
if (normalizedArg.StartsWith("/"))
{
Console.WriteLine("Unrecognized option {0}", normalizedArg);
return false;
}
if (!File.Exists(arg))
{
Console.WriteLine("Source file '{0}' not found", arg);
return false;
}
if (sourceFile != null)
{
Console.WriteLine("Multiple source files specified. Only one file is supported");
return false;
}
sourceFile = arg;
break;
}
}
if (flags.HasFlag(CompilationFlags.Platform32) && flags.HasFlag(CompilationFlags.Platform64))
{
Console.WriteLine("Both 32-bit and 64-bit platforms specified. Only one platform is supported");
return false;
}
if (!flags.HasFlag(CompilationFlags.Platform32) && !flags.HasFlag(CompilationFlags.Platform64))
flags |= CompilationFlags.Platform32;
if (sourceFile == null)
return false;
return true;
}
示例3: PeEmitter
/// <summary>
/// Initializes a new instance of the PeEmitter class.
/// Use this constructor to when generating an in-memory PE file
/// </summary>
/// <param name="flags">Compiler flags</param>
public PeEmitter(CompilationFlags flags)
: this(GetPathToTempFile(flags.HasFlag(CompilationFlags.WriteDll) ? "dll" : "exe"), flags)
{
_deleteOutputOnClose = true;
}