本文整理汇总了C#中ICodeWriter.WriteMethodStart方法的典型用法代码示例。如果您正苦于以下问题:C# ICodeWriter.WriteMethodStart方法的具体用法?C# ICodeWriter.WriteMethodStart怎么用?C# ICodeWriter.WriteMethodStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICodeWriter
的用法示例。
在下文中一共展示了ICodeWriter.WriteMethodStart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertIType
/// <summary>
/// </summary>
/// <param name="ilReader">
/// </param>
/// <param name="codeWriter">
/// </param>
/// <param name="type">
/// </param>
/// <param name="typeDefinition">
/// </param>
/// <param name="genericMethodSpecializatons">
/// </param>
/// <param name="mode">
/// </param>
/// <param name="processGenericMethodsOnly">
/// </param>
private static void ConvertIType(
IlReader ilReader,
ICodeWriter codeWriter,
IType type,
IEnumerable<IMethod> genericMethodSpecializatons,
ConvertingMode mode,
bool processGenericMethodsOnly = false)
{
if (VerboseOutput)
{
Trace.WriteLine(string.Format("Converting {0}, Mode: {1}", type, mode));
}
var typeDefinition = type.IsGenericType ? type.GetTypeDefinition() : null;
var typeSpecialization = type.IsGenericType && !type.IsGenericTypeDefinition ? type : null;
var genericTypeContext = typeDefinition != null || typeSpecialization != null
? MetadataGenericContext.Create(typeDefinition, typeSpecialization)
: null;
if (mode == ConvertingMode.Declaration)
{
if (!codeWriter.IsProcessed(type))
{
WriteTypeDefinition(codeWriter, type, genericTypeContext);
}
codeWriter.WritePostDeclarationsAndInternalDefinitions(type);
codeWriter.WriteBeforeConstructors();
}
if (mode == ConvertingMode.Definition)
{
codeWriter.DisableWrite(true);
if (!processGenericMethodsOnly)
{
// pre process step to get all used undefined structures
foreach (var ctor in IlReader.Constructors(type, codeWriter))
{
codeWriter.WriteConstructorStart(ctor, genericTypeContext);
foreach (var ilCode in ilReader.OpCodes(type.IsGenericType ? ctor.GetMethodDefinition() : ctor, genericTypeContext))
{
codeWriter.Write(ilCode);
}
codeWriter.WriteConstructorEnd(ctor, genericTypeContext);
}
}
codeWriter.DisableWrite(false);
// Actual Write
codeWriter.WriteRequiredTypesForBody();
codeWriter.WriteStoredText();
}
if (mode == ConvertingMode.Declaration)
{
codeWriter.WriteAfterConstructors();
codeWriter.WriteBeforeMethods();
}
if (mode == ConvertingMode.Definition)
{
codeWriter.DisableWrite(true);
// pre process step to get all used undefined structures
foreach (
var method in
IlReader.Methods(type, codeWriter, true).Select(m => MethodBodyBank.GetMethodWithCustomBodyOrDefault(m, codeWriter)))
{
if (!method.IsGenericMethodDefinition && !processGenericMethodsOnly)
{
var genericMethodContext = method.IsGenericMethod
? MetadataGenericContext.Create(typeDefinition, typeSpecialization, method.GetMethodDefinition(), method)
: genericTypeContext;
codeWriter.WriteMethodStart(method, genericMethodContext);
foreach (var ilCode in ilReader.OpCodes(type.IsGenericType ? method.GetMethodDefinition() : method, genericMethodContext))
{
codeWriter.Write(ilCode);
//.........这里部分代码省略.........